MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / CharString

Class CharString

modules/gui/gui/src/backend/text_server/ustring.h:145–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143/*************************************************************************/
144
145class CharString
146{
147 CowData<char> _cowdata;
148 static const char _null;
149
150public:
151 _FORCE_INLINE_ char* ptrw() { return _cowdata.ptrw(); }
152 _FORCE_INLINE_ const char* ptr() const { return _cowdata.ptr(); }
153 _FORCE_INLINE_ int size() const { return _cowdata.size(); }
154 Error resize(int p_size) { return _cowdata.resize(p_size); }
155
156 _FORCE_INLINE_ char get(int p_index) const { return _cowdata.get(p_index); }
157 _FORCE_INLINE_ void set(int p_index, const char& p_elem) { _cowdata.set(p_index, p_elem); }
158 _FORCE_INLINE_ const char& operator[](int p_index) const
159 {
160 if (unlikely(p_index == _cowdata.size()))
161 {
162 return _null;
163 }
164
165 return _cowdata.get(p_index);
166 }
167 _FORCE_INLINE_ CharProxy<char> operator[](int p_index) { return CharProxy<char>(p_index, _cowdata); }
168
169 _FORCE_INLINE_ CharString() {}
170 _FORCE_INLINE_ CharString(const CharString& p_str) { _cowdata._ref(p_str._cowdata); }
171 _FORCE_INLINE_ void operator=(const CharString& p_str) { _cowdata._ref(p_str._cowdata); }
172 _FORCE_INLINE_ CharString(const char* p_cstr) { copy_from(p_cstr); }
173
174 void operator=(const char* p_cstr);
175 bool operator<(const CharString& p_right) const;
176 bool operator==(const CharString& p_right) const;
177 CharString& operator+=(char p_char);
178 int length() const { return size() ? size() - 1 : 0; }
179 const char* get_data() const;
180 operator const char*() const { return get_data(); };
181
182protected:
183 void copy_from(const char* p_cstr);
184};
185
186/*************************************************************************/
187/* String */

Callers

nothing calls this directly

Calls 3

get_dataFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected