OpenLexocad  27.0
String.h
Go to the documentation of this file.
1 #pragma once
2 #pragma warning(disable : 4251)
3 
4 #include <Base/base_defines.h>
5 #include <wchar.h>
6 #include <wctype.h>
7 
8 #include <iostream>
9 #include <ostream>
10 #include <string>
11 #include <xstring>
12 
13 
14 
15 class QString;
16 
17 namespace App
18 {
19 class StringTool;
20 
21 }
22 
23 namespace Base
24 {
30 {
31 public:
32  friend class StringTool;
33  friend class ::App::StringTool;
34 
36  // //
37  // --------------------- BEGIN API --------------------- //
38  // //
39  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
40  // //
42 
44  String();
46  String(const std::wstring& s);
48  String(const QString& s);
50  String(const wchar_t* s);
52  // String::String(unsigned short const * s);
54  String(const Base::String& s);
55 
56  bool operator==(const Base::String& other) const;
57 
58  bool operator!=(const Base::String& other) const;
59  bool operator<(const Base::String& other) const;
60  bool operator>(const Base::String& other) const;
61  Base::String& operator=(const Base::String& rhs);
62  Base::String operator+(const Base::String& other) const;
63  Base::String& operator+=(const Base::String& other);
64 
65  inline int size() const;
66  inline int lenght() const;
67  inline bool empty() const;
68  // Returns a newly constructed Base::String object with its value initialized to a copy of a substring of this object.
69  Base::String substr(size_t pos = 0, size_t len = std::string::npos) const;
70 
72  std::wstring toWString() const;
74  const wchar_t* c_str() const { return _utf16string.c_str(); }
75 
76  bool isEqual(const Base::String& other) const;
77 
78  // Refactoring, for the first, let do the compiler the work
79  // inline operator std::string() const ;
80 
82  // //
83  // ---------------------- END API ---------------------- //
84  // //
86 
87  friend BASE_EXPORT std::ostream& operator<<(std::ostream& o, const Base::String& s);
88 
89 private:
90  // Remark: Using wstring on windows OS is ok, since it uses 2bytes/UTF-16 only.
91  // On Unix we should consider using a different string since it uses 4bytes/UCS-4.
92  std::wstring _utf16string;
93 };
94 } // namespace Base
#define BASE_EXPORT
Definition: base_defines.h:12
Definition: StringTool.h:27
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:29
const wchar_t * c_str() const
Returns wchar_t array.
Definition: String.h:74
GEOM_EXPORT std::ostream & operator<<(std::ostream &o, const Geom::Vec &vec)
Definition: AbstractXMLReader.h:8