Documentation de SFML 2.0

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
String.hpp
1 
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef SFML_STRING_HPP
26 #define SFML_STRING_HPP
27 
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <locale>
33 #include <string>
34 
35 
36 namespace sf
37 {
43 class SFML_SYSTEM_API String
44 {
45 public :
46 
48  // Types
50  typedef std::basic_string<Uint32>::iterator Iterator;
51  typedef std::basic_string<Uint32>::const_iterator ConstIterator;
52 
54  // Static member data
56  static const std::size_t InvalidPos;
57 
64  String();
65 
76  String(char ansiChar, const std::locale& locale = std::locale());
77 
84  String(wchar_t wideChar);
85 
92  String(Uint32 utf32Char);
93 
104  String(const char* ansiString, const std::locale& locale = std::locale());
105 
116  String(const std::string& ansiString, const std::locale& locale = std::locale());
117 
124  String(const wchar_t* wideString);
125 
132  String(const std::wstring& wideString);
133 
140  String(const Uint32* utf32String);
141 
148  String(const std::basic_string<Uint32>& utf32String);
149 
156  String(const String& copy);
157 
173  operator std::string() const;
174 
188  operator std::wstring() const;
189 
205  std::string toAnsiString(const std::locale& locale = std::locale()) const;
206 
218  std::wstring toWideString() const;
219 
228  String& operator =(const String& right);
229 
238  String& operator +=(const String& right);
239 
251  Uint32 operator [](std::size_t index) const;
252 
264  Uint32& operator [](std::size_t index);
265 
274  void clear();
275 
284  std::size_t getSize() const;
285 
294  bool isEmpty() const;
295 
306  void erase(std::size_t position, std::size_t count = 1);
307 
318  void insert(std::size_t position, const String& str);
319 
332  std::size_t find(const String& str, std::size_t start = 0) const;
333 
345  const Uint32* getData() const;
346 
355  Iterator begin();
356 
365  ConstIterator begin() const;
366 
379  Iterator end();
380 
393  ConstIterator end() const;
394 
395 private :
396 
397  friend SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
398  friend SFML_SYSTEM_API bool operator <(const String& left, const String& right);
399 
401  // Member data
403  std::basic_string<Uint32> m_string;
404 };
405 
416 SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
417 
428 SFML_SYSTEM_API bool operator !=(const String& left, const String& right);
429 
440 SFML_SYSTEM_API bool operator <(const String& left, const String& right);
441 
452 SFML_SYSTEM_API bool operator >(const String& left, const String& right);
453 
464 SFML_SYSTEM_API bool operator <=(const String& left, const String& right);
465 
476 SFML_SYSTEM_API bool operator >=(const String& left, const String& right);
477 
488 SFML_SYSTEM_API String operator +(const String& left, const String& right);
489 
490 } // namespace sf
491 
492 
493 #endif // SFML_STRING_HPP
494 
495