OpenLexocad  27.1
String.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ostream>
4 #include <string>
5 #include <xstring>
6 
7 
8 
9 class QString;
10 
11 namespace App
12 {
13 class StringTool;
14 
15 }
16 
17 namespace Base
18 {
23 class LX_BASE_EXPORT String
24 {
25 public:
26  friend class StringTool;
27  friend class ::App::StringTool;
28 
30  // //
31  // --------------------- BEGIN API --------------------- //
32  // //
33  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
34  // //
36 
38  String();
40  String(const std::wstring& s);
42  String(const QString& s);
44  String(const wchar_t* s);
46  // String::String(unsigned short const * s);
48  String(const Base::String& s);
49 
50  bool operator==(const Base::String& other) const;
51 
52  bool operator!=(const Base::String& other) const;
53  bool operator<(const Base::String& other) const;
54  bool operator>(const Base::String& other) const;
55  Base::String& operator=(const Base::String& rhs);
56  Base::String operator+(const Base::String& other) const;
57  Base::String& operator+=(const Base::String& other);
58 
59  inline int size() const;
60  inline int lenght() const;
61  inline bool empty() const;
62  // Returns a newly constructed Base::String object with its value initialized to a copy of a substring of this object.
63  Base::String substr(size_t pos = 0, size_t len = std::string::npos) const;
64 
66  std::wstring toWString() const;
68  const wchar_t* c_str() const { return _utf16string.c_str(); }
69 
70  bool isEqual(const Base::String& other) const;
71 
72  // Refactoring, for the first, let do the compiler the work
73  // inline operator std::string() const ;
74 
76  // //
77  // ---------------------- END API ---------------------- //
78  // //
80 
81  friend LX_BASE_EXPORT std::ostream& operator<<(std::ostream& o, const Base::String& s);
82 
83 private:
84  // Remark: Using wstring on windows OS is ok, since it uses 2bytes/UTF-16 only.
85  // On Unix we should consider using a different string since it uses 4bytes/UCS-4.
86  std::wstring _utf16string;
87 };
88 } // namespace Base
Definition: StringTool.h:26
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) ENTT_NOEXCEPT
Compares two hashed strings.
Definition: entt.hpp:570
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:23
DualNumber operator+(DualNumber a, DualNumber b)
Definition: DualNumber.h:51
const wchar_t * c_str() const
Returns wchar_t array.
Definition: String.h:68
Definition: AbstractXMLReader.h:5
LX_GEOM_EXPORT std::ostream & operator<<(std::ostream &o, const Geom::Vec &vec)