ezEngine  Milestone 7
String.h
1 #pragma once
2 
3 #include <Foundation/Strings/StringUtils.h>
4 #include <Foundation/Strings/StringView.h>
5 #include <Foundation/Strings/Implementation/StringBase.h>
6 #include <Foundation/Strings/StringConversion.h>
7 #include <Foundation/Containers/HybridArray.h>
8 
9 class ezStringBuilder;
10 class ezStreamReaderBase;
11 
25 template <ezUInt16 Size>
26 class ezHybridStringBase : public ezStringBase<ezHybridStringBase<Size> >
27 {
28 protected:
29 
31  ezHybridStringBase(ezAllocatorBase* pAllocator); // [tested]
32 
34  ezHybridStringBase(const ezHybridStringBase& rhs, ezAllocatorBase* pAllocator); // [tested]
35 
37  ezHybridStringBase(ezHybridStringBase&& rhs, ezAllocatorBase* pAllocator); // [tested]
38 
40  ezHybridStringBase(const char* rhs, ezAllocatorBase* pAllocator); // [tested]
41 
43  ezHybridStringBase(const wchar_t* rhs, ezAllocatorBase* pAllocator); // [tested]
44 
46  ezHybridStringBase(const ezStringView& rhs, ezAllocatorBase* pAllocator); // [tested]
47 
49  ezHybridStringBase(const ezStringBuilder& rhs, ezAllocatorBase* pAllocator); // [tested]
50 
52  ezHybridStringBase(ezStringBuilder&& rhs, ezAllocatorBase* pAllocator); // [tested]
53 
55  ~ezHybridStringBase(); // [tested]
56 
58  void operator=(const ezHybridStringBase& rhs); // [tested]
59 
61  void operator=(ezHybridStringBase&& rhs); // [tested]
62 
64  void operator=(const char* rhs); // [tested]
65 
67  void operator=(const wchar_t* rhs); // [tested]
68 
70  void operator=(const ezStringView& rhs); // [tested]
71 
73  void operator=(const ezStringBuilder& rhs); // [tested]
74 
76  void operator=(ezStringBuilder&& rhs); // [tested]
77 
78 public:
79 
81  operator ezStringView() const; // [tested]
82 
84  operator const char*() const { return GetData(); }
85 
89  void Clear(); // [tested]
90 
92  const char* GetData() const; // [tested]
93 
95  ezUInt32 GetElementCount() const; // [tested]
96 
98  ezUInt32 GetCharacterCount() const; // [tested]
99 
104  ezStringView GetSubString(ezUInt32 uiFirstCharacter, ezUInt32 uiNumCharacters) const; // [tested]
105 
110  ezStringView GetFirst(ezUInt32 uiNumCharacters) const; // [tested]
111 
116  ezStringView GetLast(ezUInt32 uiNumCharacters) const; // [tested]
117 
119  void ReadAll(ezStreamReaderBase& Stream);
120 
122  ezUInt64 GetHeapMemoryUsage() const { return m_Data.GetHeapMemoryUsage(); }
123 
124 private:
125  friend class ezStringBuilder;
126 
128  ezUInt32 m_uiCharacterCount;
129 };
130 
131 
133 template <ezUInt16 Size, typename AllocatorWrapper = ezDefaultAllocatorWrapper>
134 class ezHybridString : public ezHybridStringBase<Size>
135 {
136 public:
137  ezHybridString();
138  ezHybridString(ezAllocatorBase* pAllocator);
139 
142  ezHybridString(const char* rhs);
143  ezHybridString(const wchar_t* rhs);
144  ezHybridString(const ezStringView& rhs);
145  ezHybridString(const ezStringBuilder& rhs);
147 
150 
151 
152  void operator=(const ezHybridString<Size, AllocatorWrapper>& rhs);
153  void operator=(const ezHybridStringBase<Size>& rhs);
154  void operator=(const char* szString);
155  void operator=(const wchar_t* szString);
156  void operator=(const ezStringView& rhs);
157  void operator=(const ezStringBuilder& rhs);
158  void operator=(ezStringBuilder&& rhs);
159 
160  void operator=(ezHybridString<Size, AllocatorWrapper>&& rhs);
161  void operator=(ezHybridStringBase<Size>&& rhs);
162 };
163 
164 
174 
175 #include <Foundation/Strings/Implementation/String_inl.h>
176