mFrame
載入中...
搜尋中...
無符合項目
Strings.h
1
8#ifndef MFRAME_F115800B_0B0A_4795_ABFB_A37BD1DE2055
9#define MFRAME_F115800B_0B0A_4795_ABFB_A37BD1DE2055
10
11/* ***************************************************************************************
12 * Include
13 */
14
15//----------------------------------------------------------------------------------------
16#include "./../lang/Memory.h"
17#include "./../lang/Readable.h"
18
19/* ***************************************************************************************
20 * Namespace
21 */
22namespace ufm::lang {
23 class Strings;
24} // namespace ufm::lang
25
26/* ***************************************************************************************
27 * Class/Interface/Struct
28 */
29
34 /* *************************************************************************************
35 * Variable
36 */
37
38 /* *************************************************************************************
39 * Abstract Method
40 */
41
42 /* *************************************************************************************
43 * Construct Method
44 */
45 public:
50 Strings(ufm::lang::Memory memory) noexcept;
51
57 inline Strings(void* pointer, int size) : Strings(Memory(pointer, size)) {
58 return;
59 }
60
65 Strings(const char* str);
66
67 template <size_t N>
68 inline Strings(const char (&str)[N]) : Strings(str, static_cast<int>(N)) {
69 return;
70 }
71
77 return;
78 }
79
84 Strings(Strings&& other) noexcept = default;
85
90 Strings(Strings& other) noexcept = default;
91
95 virtual ~Strings(void) override;
96
97 /* *************************************************************************************
98 * Operator Method
99 */
100 public:
106 inline Strings& operator+=(const char ch) {
107 return this->append(ch);
108 }
109
115 inline Strings& operator+=(const char* str) {
116 return this->append(str);
117 }
118
126 return this->append(readable);
127 }
128
135 inline Strings& operator+=(int i) {
136 return this->append(i);
137 }
138
145 inline Strings& operator+=(double d) {
146 return this->append(d);
147 }
148
154 inline Strings& operator=(const char* str) {
155 this->set(str);
156 return *this;
157 }
158
164 inline char& operator[](int index) {
165 return *this->pointer<char>(index);
166 }
167
168 /* *************************************************************************************
169 * Override Method - ufm::lang::Data
170 */
171 public:
172 virtual int hashcode(void) const override;
173
174 /* *************************************************************************************
175 * Override Method - ufm::lang::Data
176 */
177 public:
178 virtual int hashdata(void) const override;
179
180 /* *************************************************************************************
181 * Public Method
182 */
183 public:
189 inline bool isEmpty(void) const {
190 return (this->size() == 0);
191 }
192
196 void clear(void);
197
202 int size(void) const;
203
211 int bufferSize(void);
212
219 int scanFormat(const char* format, ...);
220
228 int format(const char* format, va_list arg);
229
237 int format(const char* format, ...);
238
242 void convertUpper(void);
243
247 void convertLower(void);
248
253 Strings toUpper(void) const;
254
259 Strings toLower(void) const;
260
265 Strings clone(void) const;
266
273 Strings clone(int length) const;
274
281 Strings clone(int offset, int length) const;
282
289 int replace(char oldChar, char newChar);
290
296 Strings& append(const char c);
297
303 Strings& append(const char* str);
304
312
319 Strings& append(int value);
320
327 Strings& append(double value);
328
335 Strings& append(bool boolena);
336
342 Strings& set(const char* str);
343
350
357
358 /* *************************************************************************************
359 * Protected Method
360 */
361
362 /* *************************************************************************************
363 * Private Method
364 */
365
366 /* *************************************************************************************
367 * Static Variable
368 */
369
370 /* *************************************************************************************
371 * Static Method
372 */
373 public:
378 static Strings empty(void);
379
387 static Strings format(int bufferSize, const char* format, ...);
388
394 static int getLength(const char* src);
395
401 static int getHashcode(const char* src);
402};
403
404/* ***************************************************************************************
405 * End of file
406 */
407
408#endif /* MFRAME_F115800B_0B0A_4795_ABFB_A37BD1DE2055 */
int length(void) const
取得資料長度
Definition Data.h:153
動態記憶體管理類別
Definition Memory.h:38
E * pointer(void) const
模板方法,取得內部指標並轉換為指定型態(不指定偏移)
Definition Pointer.h:398
字串類別,提供字串操作和記憶體管理功能
Definition Strings.h:33
Strings & append(int value)
在字串尾端新增一個整數
Strings(Strings &&other) noexcept=default
複製建構字串物件
Strings & append(double value)
在字串尾端新增一個浮點數
void convertLower(void)
將字串轉換為小寫
Strings(ufm::lang::Memory memory) noexcept
建構字串物件
Strings & operator+=(const char *str)
插入字串至尾端
Definition Strings.h:115
Strings toLower(void) const
取得小寫字串
Strings & operator+=(ufm::lang::Readable &readable)
插入可讀取物件至尾端
Definition Strings.h:125
Strings & append(const char *str)
在字串尾端新增一個字串
int format(const char *format,...)
virtual int hashdata(void) const override
計算資料雜湊值
static Strings format(int bufferSize, const char *format,...)
格式化字串
static int getHashcode(const char *src)
取得字串的哈希碼
int replace(char oldChar, char newChar)
替換字串中的指定字元
Strings toUpper(void) const
取得大寫字串
int hashcodeUpperCast(void)
以全大寫的形式取得哈希碼
Strings clone(void) const
複製字串
Strings & set(const char *str)
設定字串
Strings(Strings &other) noexcept=default
複製建構字串物件
bool isEmpty(void) const
判斷字串是否為空
Definition Strings.h:189
virtual int hashcode(void) const override
返回對象的哈希碼值。支持這種方法是為了散列表,如HashMap提供的那樣。
Strings & append(ufm::lang::Readable &readable)
在字串尾端新增一個可讀取物件
int size(void) const
取得字串長度
int bufferSize(void)
取的字串原始空間大小
Strings & append(bool boolena)
在字串尾端新增一個布林值
void clear(void)
清除字串內容
Strings & operator=(const char *str)
設定字串
Definition Strings.h:154
Strings & operator+=(double d)
插入浮點數至尾端
Definition Strings.h:145
void convertUpper(void)
將字串轉換為大寫
static Strings empty(void)
取得空字串
Strings & append(const char c)
在字串尾端新增一個字元
Strings & operator+=(const char ch)
插入字元至尾端
Definition Strings.h:106
int hashcodeLowerCast(void)
以全小寫的形式取得哈希碼
int scanFormat(const char *format,...)
從字串中掃描並解析格式化數據
Strings & operator+=(int i)
插入整數至尾端
Definition Strings.h:135
Strings(int length)
建構字串物件
Definition Strings.h:76
virtual ~Strings(void) override
解構字串物件
Strings(const char *str)
建構字串物件
Strings clone(int length) const
int format(const char *format, va_list arg)
Strings(void *pointer, int size)
建構字串物件
Definition Strings.h:57
Strings clone(int offset, int length) const
char & operator[](int index)
取得指定索引的字元
Definition Strings.h:164
static int getLength(const char *src)
取得字串長度
Definition Appendable.h:23
[Interface] 定義資料讀取介面
Definition Readable.h:46