OpenLexocad  28.0
String.h
Go to the documentation of this file.
1 #pragma once
2 #include <string>
3 
4 
5 
6 class QString;
7 namespace App
8 {
9 class StringTool;
10 }
11 
12 namespace Base
13 {
17 class LX_BASE_EXPORT String
18 {
19 public:
20  friend class StringTool;
21  friend class ::App::StringTool;
22 
24  // //
25  // --------------------- BEGIN API --------------------- //
26  // //
27  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
28  // //
30 
32  String();
34  String(const std::wstring& s);
36  String(const QString& s);
38  String(const wchar_t* s);
40  // String::String(unsigned short const * s);
42  String(const Base::String& s);
43 
44  bool operator==(const Base::String& other) const;
45 
46  bool operator!=(const Base::String& other) const;
47  bool operator<(const Base::String& other) const;
48  bool operator>(const Base::String& other) const;
50  Base::String operator+(const Base::String& other) const;
52 
53  inline int size() const;
54  inline int lenght() const;
55  inline bool empty() const;
56  // Returns a newly constructed Base::String object with its value initialized to a copy of a substring of this object.
57  Base::String substr(size_t pos = 0, size_t len = std::string::npos) const;
58 
60  std::wstring toWString() const;
62  const wchar_t* c_str() const { return _utf16string.c_str(); }
63 
64  bool isEqual(const Base::String& other) const;
65 
66  // Refactoring, for the first, let do the compiler the work
67  // inline operator std::string() const ;
68 
70  // //
71  // ---------------------- END API ---------------------- //
72  // //
74 
75  bool startsWith(const Base::String& other) const;
76  bool contains(const Base::String& other) const;
77 
78  friend LX_BASE_EXPORT std::ostream& operator<<(std::ostream& o, const Base::String& s);
79 
80 private:
81  // Remark: Using wstring on windows OS is ok, since it uses 2bytes/UTF-16 only.
82  // On Unix we should consider using a different string since it uses 4bytes/UCS-4.
83  std::wstring _utf16string;
84 };
85 LX_BASE_EXPORT std::ostream& operator<<(std::ostream& o, const Base::String& s);
86 } // namespace Base
Base::String::toWString
std::wstring toWString() const
Returns Base::String as a std::wstring.
Base::String::operator==
bool operator==(const Base::String &other) const
Base::String::c_str
const wchar_t * c_str() const
Returns wchar_t array.
Definition: String.h:62
Base::String::operator+
Base::String operator+(const Base::String &other) const
Base::String::String
String(const wchar_t *s)
Constructs a string from an array of wchar_t.
Base::String::operator=
Base::String & operator=(const Base::String &rhs)
Base::String::size
int size() const
Base::StringTool
Definition: StringTool.h:13
Base::String::operator>
bool operator>(const Base::String &other) const
Base::String::String
String(const std::wstring &s)
Constructs a string from a std::wstring.
Base::String::operator<<
friend LX_BASE_EXPORT std::ostream & operator<<(std::ostream &o, const Base::String &s)
Base::String::lenght
int lenght() const
Base::String::substr
Base::String substr(size_t pos=0, size_t len=std::string::npos) const
Base::String::String
String()
Constructs an empty string.
Base::String::startsWith
bool startsWith(const Base::String &other) const
Base::String::operator<
bool operator<(const Base::String &other) const
Base::String::contains
bool contains(const Base::String &other) const
Base::operator<<
LX_BASE_EXPORT std::ostream & operator<<(std::ostream &o, const Base::Color &color)
Base::String::operator+=
Base::String & operator+=(const Base::String &other)
Base::String::operator!=
bool operator!=(const Base::String &other) const
Base::String::String
String(const QString &s)
Constructs a string from a QString.
Base::String
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
Base::String::String
String(const Base::String &s)
Constructs a string from an array of wchar_t.
Base::String::isEqual
bool isEqual(const Base::String &other) const
Base
Definition: AbstractXMLReader.h:5
Base::String::empty
bool empty() const