acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_str.h
1#pragma once
2
3
4//#include "string.h"
5
6
7
8
9//struct end_of_line_and_next_line
10//{
11//
12// const_char_pointer end_of_line;
13// const_char_pointer next_line;
14//
15//};
16
17
18
19template < typename TYPE_CHAR >
21{
22public:
23
24 TYPE_CHAR cha[8];
25
26};
27
28
29template < >
30class single_char < ::ansi_character >
31{
32public:
33
34 ::ansi_character cha[6];
35
36};
37
38
39template < >
40class single_char < ::wd16_character >
41{
42public:
43
44 ::wd16_character cha[2];
45
46};
47
48
49template < >
50class single_char < ::wd32_character >
51{
52public:
53
54 ::wd32_character cha[1];
55
56};
57
58
59class CLASS_DECL_ACME str
60{
61public:
62
63
64 enum enum_pad
65 {
66
67 e_pad_left,
68 e_pad_right
69
70 };
71
72
73
75
76
77
78 //inline ::i32 compare_ignore_case(const ::string & left, const ::string & right, size_t len = 0);
79 //inline bool equal_ignore_case(const ::string & left, const ::string & right, size_t len = 0);
80
81
82 static bool trimmed_is_empty(const ::scoped_string & scopedstr);
83
84
85 template < prototype_character CHAR_TYPE >
86 static inline string_base < const CHAR_TYPE * > repeat(const CHAR_TYPE * psz, character_count c);
87
88 //extern enum_error g_eerror;
89
90
91
92 static inline ::i32 compare_ignore_case(const string & left, const string & right, size_t len = 0);
93 static inline bool equal_ignore_case(const string & left, const string & right, size_t len = 0);
94
95
96 static void increment_digit_letter(string & str);
97
98 static void copy(string & str, const ::scoped_string & scopedstr, ::i32 iCount);
99
100 static string replace_with(const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstr, character_count iStart = 0);
101 static string case_insensitive_replace_with(const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstr, character_count iStart = 0);
102 static ::collection::count replace_with_ci_count(const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstr, character_count iStart = 0);
103 static ::collection::count utf8_replace_with(string & str, const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstrOld, character_count iStart = 0);
104 static string utf8_replace_with(const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstr, character_count iStart = 0);
105
106 static inline string find_replace(const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstr, character_count iStart = 0)
107 {
108 return replace_with(scopedstrNew, scopedstrOld, scopedstr, iStart);
109 }
110 static inline string case_insensitive_find_replace(const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstr, character_count iStart = 0)
111 {
112 return case_insensitive_replace_with(scopedstrNew, scopedstrOld, scopedstr, iStart);
113 }
114 static inline ::collection::count case_insensitive_find_replace_count(const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstr, character_count iStart = 0)
115 {
116 return replace_with_ci_count(scopedstrNew, scopedstrOld, scopedstr, iStart);
117 }
118 static inline ::collection::count utf8_find_replace(string & str, const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstrNew, character_count iStart = 0)
119 {
120 return utf8_replace_with(str, scopedstrNew, scopedstrOld, iStart);
121 }
122 static inline string utf8_find_replace(const ::scoped_string & scopedstrOld, const ::scoped_string & scopedstrNew, const ::scoped_string & scopedstr, character_count iStart = 0)
123 {
124 return utf8_replace_with(scopedstrNew, scopedstrOld, scopedstr, iStart);
125 }
126
127 static string random_replace(::particle * pparticle, const string_array_base & straNew, const string_array_base & straOld, const ::scoped_string & scopedstr);
128
129 static character_count find_first(const string_array_base & straSearch, ::collection::index & iFound, const ::scoped_string & scopedstr, ::collection::index iStart = 0);
130
131 static character_count case_insensitive_find(const ::scoped_string & scopedstrFind, const ::scoped_string & scopedstr, character_count iStart = 0);
132
133 static character_count utf8_find(const ::scoped_string & scopedstrFind, const ::scoped_string & scopedstr, character_count iStart = 0);
134
135 static character_count find_file_extension(const ::scoped_string & scopedstrExtension, const ::scoped_string & scopedstr, character_count iStart = 0, character_count iLast = -1);
136
137 static character_count find_ww(const ::scoped_string & scopedstrFind, const ::scoped_string & scopedstr, character_count iStart = 0);
138 static character_count find_wwci(const ::scoped_string & scopedstrFind, const ::scoped_string & scopedstr, character_count iStart = 0);
139 static character_count find_aww(const ::scoped_string & scopedstrFind, const ::scoped_string & scopedstr, character_count iStart = 0);
140 static character_count find_awwci(const ::scoped_string & scopedstrFind, const ::scoped_string & scopedstr, character_count iStart = 0);
141 static string has_character(const ::scoped_string & scopedstrIfHasChar, const ::scoped_string & scopedstrBefore = nullptr, const ::scoped_string & scopedstrAfter = nullptr, const ::scoped_string & scopedstrDoesnt = nullptr);
142 static bool has_upper(const ::scoped_string & scopedstr);
143 static bool has_lower(const ::scoped_string & scopedstr);
144 static bool has_digit(const ::scoped_string & scopedstr);
145 static void calc_v1(const ::scoped_string & scopedstr, bool & bHasUpper, bool & bHasLower, bool & bHasDigit);
146 static bool has_one_v1(const ::scoped_string & scopedstr, bool & bHasUpper, bool & bHasLower, bool & bHasDigit);
147 static bool has_all_v1(const ::scoped_string & scopedstr, bool & bHasUpper, bool & bHasLower, bool & bHasDigit);
148 static bool has_all_v1(const ::scoped_string & scopedstr);
149 static string if_null(const ::scoped_string & scopedstr, const ::scoped_string & scopedstrIfNull = nullptr);
150
151
152 //inline const_char_pointer __utf8_inc(const_char_pointer psz) { return psz + 1 + trailingBytesForUTF8(*psz); }
153
154 //const_char_pointer utf8_next_add_length(character_count * paddlength, const_char_pointer psz);
155 //const_char_pointer utf8_inc_copy_slide_back(character_count * pslideback, ::ansi_character * pchDst, const_char_pointer pchSrc);
156 //const_char_pointer utf8_inc_count(const_char_pointer psz, character_count * piCount);
157
158 static string block(::ansi_character ch, ::i32 iSize);
159 static void fill(string & str, ::ansi_character ch);
160
161
162
163
164 //static inline bool begins_ci_skip(const_char_pointer &psz, const ::scoped_string & scopedstrPrefix);
165 //static inline struct ::end_of_line_and_next_line end_of_line_and_next_line(const ::scoped_string & scopedstr);
166
167// bool replace_prefix(::string & str, const ::scoped_string & scopedstrPrefixReplacement, const ::scoped_string & scopedstrPrefix);
168// inline bool begins_replace(::string & str, const ::scoped_string & scopedstrPrefixReplacement, const ::scoped_string & scopedstrPrefix)
169// {
170//
171// return replace_prefix(str, scopedstrPrefixReplacement, scopedstrPrefix);
172//
173// }
174//
175//
176// bool case_insensitive_replace_prefix(::string & str, const ::scoped_string & scopedstrPrefixReplacement, const ::scoped_string & scopedstrPrefix);
177// inline bool case_insensitive_begins_replace(::string & str, const ::scoped_string & scopedstrPrefixReplacement, const ::scoped_string & scopedstrPrefix)
178// {
179//
180// return case_insensitive_replace_prefix(str, scopedstrPrefixReplacement, scopedstrPrefix);
181//
182// }
183
184
185 static bool trim_any_quotes(string & str);
186 static bool paired_trim(string & str, ::ansi_character ch);
187 static bool trim(string & str);
188 static bool _008Trim(string & str);
189
190
191
192
193 static string & zero_pad(string & str, character_count iPad);
194 static string zero_padded(const ::scoped_string & scopedstr, character_count iPad);
195 static ::i32 get_escaped_char(const_char_pointer psz, character_count pos, character_count & retPos);
196 static bool get_curly_content(const_char_pointer psz, string & str);
197 static bool is_simple_natural(const_char_pointer psz, character_count iCount = -1);
198 static bool is_natural(const ::scoped_string & scopedstr);
199 static bool is_integer(const ::scoped_string & scopedstr);
200
201 static string ansi_lower(const ::scoped_string & scopedstr);
202 static string ansi_upper(const ::scoped_string & scopedstr);
203
204
205 static string get_word(const ::scoped_string & scopedstr, const ::scoped_string & scopedstrSeparator, bool bWithSeparator = false, bool bEndIsSeparator = true);
206
207 static string token(string & str, const ::scoped_string & scopedstrSeparatorText, bool bWithSeparator = false);
208
209 // void token(string & strToken, ::string & strSource, const ::scoped_string & scopedstrSeparatorText, bool bWithSeparator = false);
210
211 static string line(string & str, bool bWithNewLine = false);
212
213 static string pad(const ::scoped_string & scopedstr, ::collection::count iLen, const ::scoped_string & scopedstrPattern, enum_pad epad);
214
215 static inline character_count length(const_char_pointer pansichar) { return ansi_length(pansichar); }
216 static inline character_count length(const ::wd16_character * pwd16char) { return wd16_length(pwd16char); }
217 static inline character_count length(const ::wd32_character * pwd32char) { return wd32_length(pwd32char); }
218
219
220 template < typename TYPE >
221 static inline TYPE from_string(const_char_pointer psz);
222
223
224 static bool simple_escaped(const ::scoped_string & scopedstr, character_count pos);
225
226
227
228
229
230
231 static bool utf8_check_is_valid(const ::scoped_string & scopedstring);
232
233 static string q_valid(const ::scoped_string & scopedstr);
234
235
236 static inline ::ansi_character * dup(const_char_pointer psz)
237 {
238
239 try
240 {
241
242 return ansi_dup(psz);
243
244 }
245 catch (...)
246 {
247
248 }
249
250 return nullptr;
251
252 }
253
254
255
256 static string signed_f64(::f64 d);
257
258 static string signed_int(::i32 i);
259
260 static bool is_true(const ::scoped_string & scopedstr);
261
262
263 static inline character_count utf8_dec_len(const_char_pointer pszBeg, const_char_pointer psz);
264
265 static inline character_count utf8_inc_len(const_char_pointer psz);
266
267 static inline bool namespaced(const_char_pointer psz, const_char_pointer pszNamespace, const_char_pointer pszSeparator = "::");
268
269
270
271 static void fix_eol(string & str);
272
273
274 static bool to(::i64 & i, const ::scoped_string & scopedstrParam);
275 static bool to(::i32 & i, const ::scoped_string & scopedstrParam);
276 static bool to(::u64 & u, const ::scoped_string & scopedstrParam);
277 static bool to(::u32 & u, const ::scoped_string & scopedstrParam);
278
279
280 static bool to(::i32 & i, ::i32 iBase, const ::scoped_string & scopedstrParam);
281 static bool to(::i64 & i, ::i32 iBase, const ::scoped_string & scopedstrParam);
282 static bool to(::u64 & u, ::i32 iBase, const ::scoped_string & scopedstrParam);
283 static bool to(::u32 & u, ::i32 iBase, const ::scoped_string & scopedstrParam);
284
285
286 static iptr to_iptr(const ::scoped_string & scopedstr);
287 static ::i32 to_int(const ::scoped_string & scopedstr);
288 static ::u32 to_u32(const ::scoped_string & scopedstr);
289
290
291 static ::i64 to_i64(const ::scoped_string & scopedstr);
292 static ::u64 to_u64(const ::scoped_string & scopedstr);
293
294
295
296 static inline ::i32 to_with_fallback(const ::scoped_string & scopedstr, ::i32 iDefault);
297 static inline ::i64 to_with_fallback(const ::scoped_string & scopedstr, ::i64 iDefault);
298 static inline ::i32 to_with_fallback(const ::scoped_string & scopedstr, ::i32 iDefault, ::i32 iBase);
299 static inline ::i64 to_with_fallback(const ::scoped_string & scopedstr, ::i64 iDefault, ::i32 iBase);
300
301
302
303 // case insensitive, ignore white space - only in searched string
304 static bool begins_ci_iws(const ::scoped_string & scopedstr, const ::scoped_string & scopedstrPrefix);
305 static bool begins_ci_iws(const wstring & wstr, const wstring & wstrPrefix);
306
307 //bool while_begins_with_chars_eat(string & str, const ::scoped_string & scopedstrChars);
308 //bool case_insensitive_while_begins_with_chars_eat(string & str, const ::scoped_string & scopedstrChars);
309
310
311 // static inline const_char_pointer windows_bbqbunc(const ansi_string &);
312 // static inline const_char_pointer windows_bbqb(const ansi_string &);
313 // static inline const_char_pointer windows_bb(const ansi_string &);
314
315
316 // static inline const ::wide_character * windows_bbqbunc(const wide_string &);
317 // static inline const ::wide_character * windows_bbqb(const wide_string &);
318 // static inline const ::wide_character * windows_bb(const wide_string &);
319
320
321 static inline character_count unichar_count(const_char_pointer pstr);
322 static inline character_count unichar_count(const ::wd16_character * pstr);
323 static inline character_count unichar_count(const ::wd32_character * pstr);
324
325
326 static void get_lines(::string & str, bool bFinal, const ::function < void(const ::scoped_string &, bool bCarriage) > & functionNewLine);
327
328
329 static void get_lines(::string_array_base & stra, ::string & str, const ::scoped_string & scopedstrPrefix, bool bFinal, ::particle * pparticleSynchronization = nullptr, ::file::file * pfileLines = nullptr);
330
331
332 static character_count x_find_index(const ::scoped_string& scopedstr, const ::scoped_string& scopedstrSearchedTerm);
333 static bool x_contains(const ::scoped_string& scopedstr, const ::scoped_string& scopedstrSearchedTerm);
334
335 static bool x_contains(const ::scoped_string& scopedstr, const ::string_array_base & straSearchedTerm);
336
337
338}; // class str
339
340
341CLASS_DECL_ACME string normalize_wildcard_criteria(const ::scoped_string & scopedstrPattern);
342
343
344CLASS_DECL_ACME string _001Concatenate(const ::scoped_string & scopedstr1, const ::scoped_string & scopedstrMid, const ::scoped_string & scopedstr2);
345
346
347CLASS_DECL_ACME string string_from_strdup(const_char_pointer psz);
348
349//
350//
351//template<typename ITERATOR_TYPE>
352//auto string_range < ITERATOR_TYPE>::consume_quoted_value()
353//{
354//
355// return ::str::consume_quoted_value(*this);
356//
357//}
358
359
360inline character_count str::utf8_dec_len(const_char_pointer pszBeg, const_char_pointer psz)
361{
362
363 const_char_pointer pszDec = unicode_prior(psz, pszBeg);
364
365 if (psz == nullptr)
366 {
367
368 return -1;
369
370 }
371
372 return psz - pszDec;
373
374}
375
376
377inline character_count str::utf8_inc_len(const_char_pointer psz)
378{
379
380 return get_utf8_char_length(psz);
381
382}
383
384
385
Definition file.h:33
Definition particle.h:95
Definition _str.h:21
Definition _str.h:60
static bool utf8_check_is_valid(const ::scoped_string &scopedstring)
Definition _str.cpp:3601
static string q_valid(const ::scoped_string &scopedstr)
Definition _str.cpp:3637
static bool trimmed_is_empty(const ::scoped_string &scopedstr)
include "_____str_ch.h"
Definition _str_impl.cpp:20
Definition aaa_want_to_remove_str_wstring.h:94