acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
string_array.h
1#pragma once
2
3
4#include "array_base.h"
5//#include "comparable_eq_array.h"
6//#include "comparable_array.h"
7//
8#include "acme/prototype/collection/address_array.h"
10//#include "acme/array.h"
11
12template < typename CHARACTER >
13constexpr std::strong_ordering case_insensitive_compare_string(const CHARACTER * pszA, const CHARACTER * pszB)
14{
15
16 return case_insensitive_string_order(pszA, pszB);
17
18}
19
20//namespace str
21//{
22
23class CLASS_DECL_ACME strsize_range
24{
25public:
26
27
28 strsize_range(character_count iBegin = -1, character_count iEnd = -1) : m_iBegin(iBegin), m_iEnd(iEnd) { }
29
30
31 character_count m_iBegin;
32 character_count m_iEnd;
33
34 character_count begin() const { return m_iBegin; }
35 character_count end() const { return m_iEnd; }
36 character_count count() const { return m_iEnd - m_iBegin; }
37 character_count upper_bound() const { return m_iEnd - 1; }
38
39};
40
41using strsize_range_array = ::array < strsize_range >;
42
43
44template < typename Type, typename RawType, ::enum_type t_etypeContainer >
45class string_base_array :
46 public comparable_array_base < Type, const Type &, comparable_eq_array_base < Type, const Type &, array_base < Type, const Type &, ::typed::def < Type >, ::heap::typed_memory < Type, ::heap::e_memory_array >, t_etypeContainer > > >
47{
48public:
49
50
51 using BASE_ARRAY = comparable_array_base < Type, const Type &, comparable_eq_array_base < Type, const Type &, array_base < Type, const Type &, ::typed::def < Type >, ::heap::typed_memory < Type, ::heap::e_memory_array >, t_etypeContainer > > >;
52 using RAW_BASE_ARRAY = typename BASE_ARRAY::RAW_BASE_ARRAY;
53 using BASE_STRING = Type;
54 using BASE_RAW_STRING = RawType;
55 using BASE_RAW_STRING_ARRAY = ::string_base_array < RawType, RawType, t_etypeContainer >;
56 using CHARACTER = typename BASE_STRING::CHARACTER;
57 using RAW_RANGE = typename BASE_RAW_STRING::RANGE;
58 using BASE_TYPE = BASE_STRING;
59 using BASE_ARG_TYPE = const BASE_STRING &;
60 using SCOPED_STRING = typename BASE_STRING::SCOPED_STRING;
61
62 using THIS_RAW_RANGE = typename BASE_ARRAY::THIS_RAW_RANGE;
63 using CONST_RAW_RANGE = typename BASE_ARRAY::CONST_RAW_RANGE;
64 using this_iterator = typename BASE_ARRAY::this_iterator;
65
66 using BASE_ARRAY::BASE_ARRAY;
67 //using BASE_ARRAY::operator =;
68
69
70 string_base_array(const RAW_BASE_ARRAY& a) : BASE_ARRAY(a) {}
71 string_base_array(CHARACTER * const * ppsz, ::collection::count c);
72 ~string_base_array();
73
74 template < prototype_container CONTAINER >
75 string_base_array & operator = (const CONTAINER & container)
76 {
77 this->assign_a_container(container);
78 return *this;
79 }
80
81 ::collection::count get_size() const;
82 ::collection::count get_count() const;
83 ::collection::index get_lower_bound(::collection::index i = 0) const;
84 ::collection::index get_upper_bound(::collection::index i = -1) const;
85 ::collection::index get_middle_index(::collection::index i = 0) const;
86
87
88 void erase_duplicates();
89
90 void case_insensitive_erase_duplicates();
91
92
93 ::collection::index _007FindLine(const SCOPED_STRING & strKey, ::collection::index iStart = 0) const;
94 void _007SetLine(const SCOPED_STRING & strKey, const SCOPED_STRING & strValue, ::collection::index iStart = 0);
95 ::collection::index _007GetLine(RawType & rawtype, const SCOPED_STRING & strKey, ::collection::index iStart = 0) const;
96 RawType _007GetLine(const SCOPED_STRING & strKey, ::collection::index iStart = 0) const;
97
98
99 ::collection::index _007FindSection(const SCOPED_STRING & strSection) const;
100 ::collection::index _007FindLine(const SCOPED_STRING & strSection, const SCOPED_STRING & strKey) const;
101 ::collection::index _007OpenSection(const SCOPED_STRING & strSection);
102 void _007SetLine(const SCOPED_STRING & strSection, const SCOPED_STRING & strKey, const SCOPED_STRING & strValue);
103 ::collection::index _007GetLine(RawType & rawtype, const SCOPED_STRING & strSection, const SCOPED_STRING & strKey) const;
104 RawType _007GetLine(const SCOPED_STRING & strSection, const SCOPED_STRING & strKey) const;
105
106
107 void order();
108 void case_insensitive_order();
109 void collate_order();
110 void case_insensitive_collate_sort();
111
112
113 Type safe_at(::collection::index nIndex, Type tDefault = "") const;
114 Type safe_at(::collection::index nIndex, Type tDefault = "");
115
116 Type get_at(::collection::index nIndex) const;
117 void set_at(::collection::index nIndex, const Type & newElement);
118
119 Type & element_at(::collection::index nIndex);
120 const Type & element_at(::collection::index nIndex) const;
121
122 //Type & add_new();
123 //Type * add_new(::collection::count c);
124
125 Type & first(::collection::index i = 0);
126 Type first(::collection::index i = 0) const;
127
128 Type & last(::collection::index i = -1);
129 Type last(::collection::index i = -1) const;
130
131 const Type * get_data() const;
132 Type * get_data();
133
134 using BASE_ARRAY::add;
135
136 Type & set_at_grow(::collection::index nIndex, const Type & newElement);
137
138
139 Type & add_get(const Type & newElement);
140
141
142 void copy(const string_base_array & src);
143
144 template < prototype_array ARRAY >
145 void copy(const ARRAY & src);
146
147
148 using BASE_ARRAY::copy;
149
150
151 ::collection::index add(::strsize_range_array & stra, const SCOPED_STRING & str)
152 {
153
154 ::collection::index i = -1;
155
156 for (auto & size_range : stra)
157 {
158
159 i = add(RawType(str.begin() + size_range.m_iBegin, str.begin() + size_range.m_iEnd));
160
161 }
162
163 return i;
164
165 }
166
167 string_base_array & c_stra(string_base_array & stra) const;
168 string_base_array c_stra() const;
169
170 Type & insert_at(::collection::index nIndex, const Type & strElement);
171 void insert_at(::collection::index nIndex, const Type & strElement, ::collection::count nCount);
172 template < prototype_container CONTAINER >
173 void insert_at(::collection::index nStartIndex, const CONTAINER & container);
174
175
176 string_base_array slice(::collection::index iStart, ::collection::count iCount = -1) const;
177
178 //string_base_array & operator =(const string_base_array & stra);
179
180
181 Type & insert_empty(::collection::index nIndex);
182
183 void insert_empty(::collection::index nIndex, ::collection::count c);
184
185
186 ::collection::count truncate_on_find_character(CHARACTER ch);
187
188
189 //class ::memory GetFormatV004();
190 ::collection::count erase_prefixed(const ::scoped_string & scopedstrPrefix);
191 ::collection::count erase_empty();
192 ::collection::count erase_empty_end();
193 ::collection::count erase_empty_begin();
194 ::collection::count erase_empty_trimmed_end();
195 ::collection::count erase_empty_trimmed_begin();
196 ::collection::index add_normal(const Type & str);
197
198 void trim_right(const SCOPED_STRING & strChars);
199 void trim_left(const SCOPED_STRING & strChars);
200 void trim(const SCOPED_STRING & strChars);
201 void trim_right();
202 void trim_left();
203 void trim();
204
205 ::collection::index add_unique(const Type & str);
206 ::collection::index case_insensitive_add_unique(const Type & str);
207
208 ::collection::count append_unique(const string_base_array & stra);
209 ::collection::count case_insensitive_append_unique(const string_base_array & stra);
210
211 void make_lower();
212 void make_upper();
213
214 auto & append_formatf(const CHARACTER * psz, ...)
215 {
216
217 va_list arguments;
218
219 va_start(arguments, psz);
220
221 auto & str = this->add_new().formatf_arguments(psz, arguments);
222
223 va_end(arguments);
224
225 return str;
226
227 }
228
229
230 template<typename... Args>
231 auto & append_format(std::format_string<Args...> fmt, Args&&... args)
232 {
233
234 return this->add_new().format(fmt, std::forward<Args>(args)...);
235
236 }
237
238
239 auto & add_trace(enum_trace_level etracelevel, const SCOPED_STRING & scopedstr)
240 {
241
242 return append_formatf("%c: %s\n", trace_level_letter(etracelevel), ::string(scopedstr).c_str());
243
244 }
245
246 //void debug_output(::collection::index iStart = 0, ::collection::count c = -1);
247
248 operator ::collection::count() const
249 {
250 return get_count();
251 }
252
253
254 ::collection::index get_random_index() const;
255
256 Type & random_element();
257 const Type & random_element() const;
258
259 Type pop_random_element();
260
261 Type pop(::collection::index i = -1);
262 void slice(string_base_array & stra, ::collection::index i, ::collection::count ca = -1);
263 void erase(::collection::index i, ::collection::count count);
264 void splice(const string_base_array & stra, ::collection::index i, ::collection::count ca = -1);
265 void splice(const string_base_array & stra, ::collection::index i, string_base_array & straRemoved, ::collection::count ca = -1);
266
267
268 // if Type is found, transfer it to specified position
269 bool case_insensitive_move(const SCOPED_STRING & str, ::collection::index iIndex);
270
271
272 // transfer preferred in order
273 bool preferred(const SCOPED_STRING & str);
274
275 ::collection::count preferred(string_base_array & stra);
276
277
278 ::collection::count case_insensitive_count(const SCOPED_STRING & strFind, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
279 ::collection::count count(const SCOPED_STRING & strFind, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
280
281
282 ::collection::index case_insensitive_find_first(const SCOPED_STRING & strFind, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
283 ::collection::index find_first(const SCOPED_STRING & strFind, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
284
285
286 ::collection::index case_insensitive_find_last(const SCOPED_STRING & strFind, ::collection::index iFind = -1, ::collection::index iLast = 0) const;
287 ::collection::index find_last(const SCOPED_STRING & strFind, ::collection::index iFind = -1, ::collection::index iLast = 0) const;
288
289
290 ::collection::index case_insensitive_reverse_find(const SCOPED_STRING & strFind, ::collection::index iFind = -1, ::collection::index iLast = 0) const;
291 ::collection::index rear_find(const SCOPED_STRING & strFind, ::collection::index iFind = -1, ::collection::index iLast = 0) const;
292
293
294 ::collection::index _066Find(const SCOPED_STRING & str) const;
295
296 ::collection::index _case_insensitive_find_first_prefixed(const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
297 ::collection::index _find_first_prefixed(const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
298
299 ::collection::index _find_first_with_starting_word(const SCOPED_STRING & strStartingWord, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
300
301 ::collection::index case_insensitive_find_first_prefixed(const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
302 ::collection::index find_first_prefixed(const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
303
304 ::collection::index _case_insensitive_find_first_suffixed(const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
305 ::collection::index _find_first_suffixed(const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
306
307 ::collection::index case_insensitive_find_first_suffixed(const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
308 ::collection::index find_first_suffixed(const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
309
310 ::collection::index case_insensitive_find_first_begins(const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return case_insensitive_find_first_prefixed(strStarting, iFind, iLast); }
311 ::collection::index find_first_begins(const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return find_first_prefixed(strStarting, iFind, iLast); }
312
313 ::collection::index find_first_with_starting_word(const SCOPED_STRING & strStartingWord, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
314
315 ::collection::index case_insensitive_find_first_ends(const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return case_insensitive_find_first_suffixed(strEnding, iFind, iLast); }
316 ::collection::index find_first_ends(const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return find_first_suffixed(strEnding, iFind, iLast); }
317
318 ::collection::index _case_insensitive_find_first_contains(const SCOPED_STRING & strSubstring, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const;
319 ::collection::index _find_first_contains(const SCOPED_STRING & strSubstring, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const;
320
321 ::collection::index case_insensitive_find_first_contains(const SCOPED_STRING & strSubstring, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const;
322 ::collection::index find_first_contains(const SCOPED_STRING & strSubstring, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const;
323
324 ::collection::index case_insensitive_find_first_begins_eat(Type & strFoundAndEaten, const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
325 ::collection::index find_first_begins_eat(Type & strFoundAndEaten, const SCOPED_STRING & strStarting, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
326
327 ::collection::index find_first_with_starting_word_eat(Type & strFoundAndEaten, const SCOPED_STRING & strStartingWord, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
328
329 ::collection::index case_insensitive_find_first_ends_eat(Type & strFoundAndEaten, const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
330 ::collection::index find_first_ends_eat(Type & strFoundAndEaten, const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
331
332 ::collection::index case_insensitive_find_first_contains_eat(Type & strFoundAndEaten, const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
333 ::collection::index find_first_contains_eat(Type & strFoundAndEaten, const SCOPED_STRING & strEnding, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
334
335
336 ::collection::index case_insensitive_prefix_find_first(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
337 ::collection::index prefix_find_first(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
338
339 inline bool case_insensitive_prefixes(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(case_insensitive_prefix_find_first(strTopic, iFind, iLast)); }
340 inline bool prefixes(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(prefix_find_first(strTopic, iFind, iLast)); }
341
342 ::collection::index case_insensitive_suffix_find_first(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
343 ::collection::index suffix_find_first(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const;
344
345 inline bool case_insensitive_suffixes(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(case_insensitive_suffix_find_first(strTopic, iFind, iLast)); }
346 inline bool suffixes(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(suffix_find_first(strTopic, iFind, iLast)); }
347
348 ::collection::index case_insensitive_substring_find_first(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const;
349 ::collection::index substring_find_first(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const;
350
351 inline bool case_insensitive_is_part_of(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(case_insensitive_substring_find_first(strTopic, iFind, iLast)); }
352 inline bool is_part_of(const SCOPED_STRING & strTopic, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(substring_find_first(strTopic, iFind, iLast)); }
353
354
355
356 bool _067CaseInsensitiveContains(const SCOPED_STRING & strFind, ::collection::index iFind = 0, ::collection::index iLast = -1, ::collection::count countMin = 1, ::collection::count countMax = -1) const;
357 bool _067Contains(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1, ::collection::count countMin = 1, ::collection::count countMax = -1) const;
358
359
360 bool _067CaseInsensitiveContainsSubstring(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1, ::collection::count countMin = 1, ::collection::count countMax = -1) const;
361 bool _067ContainsSubstring(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1, ::collection::count countMin = 1, ::collection::count countMax = -1) const;
362
363
364 bool case_insensitive_contains(const SCOPED_STRING & strFind, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(case_insensitive_find_first(strFind, iFind, iLast)); }
365 bool contains(const SCOPED_STRING & strFind, ::collection::index iFind = 0, ::collection::index iLast = -1) const { return found(case_insensitive_find_first(strFind, iFind, iLast)); }
366
367
368 bool case_insensitive_theres(const SCOPED_STRING & strSubstring, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const { return found(case_insensitive_substring_find_first(strSubstring, iFind, iLast, ppszBeg, ppszEnd)); }
369 bool theres(const SCOPED_STRING & strSubstring, ::collection::index iFind = 0, ::collection::index iLast = -1, const CHARACTER ** ppszBeg = nullptr, const CHARACTER ** ppszEnd = nullptr) const { return found(case_insensitive_substring_find_first(strSubstring, iFind, iLast, ppszBeg, ppszEnd)); }
370
371
372 template < prototype_array INDEX_ARRAY >
373 ::collection::count case_insensitive_begins(INDEX_ARRAY & ia, const SCOPED_STRING & strPrefix, ::collection::index first = 0, ::collection::index iLast = -1);
374
375 template < prototype_array INDEX_ARRAY >
376 ::collection::count begins(INDEX_ARRAY & ia, const SCOPED_STRING & strPrefix, ::collection::index first = 0, ::collection::index iLast = -1);
377
378
379 template < prototype_array STRING_ARRAY >
380 ::collection::count case_insensitive_ends(STRING_ARRAY & stra, const SCOPED_STRING & strSuffix, ::collection::index first = 0, ::collection::index iLast = -1);
381
382 template < prototype_array STRING_ARRAY >
383 ::collection::count ends(STRING_ARRAY & stra, const SCOPED_STRING & strSuffix, ::collection::index first = 0, ::collection::index iLast = -1);
384
385
386 template < prototype_array STRING_ARRAY >
387 ::collection::count case_insensitive_search(STRING_ARRAY & stra, const SCOPED_STRING & strSubstring, ::collection::index first = 0, ::collection::index iLast = -1);
388
389 template < prototype_array STRING_ARRAY >
390 ::collection::count search(STRING_ARRAY & stra, const SCOPED_STRING & strSubstring, ::collection::index first = 0, ::collection::index iLast = -1);
391
392
393 //::collection::count case_insensitive_begins(string_base_array & straPrefixed,const SCOPED_STRING &strPrefix,::collection::index first = 0,::collection::index iLast = -1);
394 //::collection::count begins(string_base_array& straPrefixed, const SCOPED_STRING &strPrefix, ::collection::index first = 0, ::collection::index iLast = -1);
395
396
397 //::collection::count case_insensitive_ends(string_base_array& straSuffixed, const SCOPED_STRING &strPrefix, ::collection::index first = 0, ::collection::index iLast = -1);
398 //::collection::count ends(string_base_array& straSuffixed, const SCOPED_STRING &strPrefix, ::collection::index first = 0, ::collection::index iLast = -1);
399
400
401 //::collection::count case_insensitive_search(string_base_array& straResult, const SCOPED_STRING &strSubstring, ::collection::index first = 0, ::collection::index iLast = -1);
402 //::collection::count search(string_base_array& straResult, const SCOPED_STRING &strSubstring, ::collection::index first = 0, ::collection::index iLast = -1);
403
404
405 ::collection::count case_insensitive_filter_begins(const SCOPED_STRING & strPrefix, ::collection::index first = 0, ::collection::index iLast = -1);
406 ::collection::count filter_begins(const SCOPED_STRING & strPrefix, ::collection::index first = 0, ::collection::index iLast = -1);
407
408
409 template < typename Pred >
410 ::collection::count filter(Pred pred, ::collection::index first = 0, ::collection::index iLast = -1);
411
412 template < typename Pred >
413 ::collection::count filter_out(Pred pred, ::collection::index first = 0, ::collection::index iLast = -1);
414
415 template < typename Pred, typename ArrayOut >
416 ::collection::count filter_out(Pred pred, ArrayOut & a, ::collection::index first = 0, ::collection::index iLast = -1);
417
418 using BASE_ARRAY::erase_first;
419 ::collection::count case_insensitive_erase_first(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1);
420
421 ::collection::count erase_first(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1);
422
423
424 ::collection::count case_insensitive_erase_last(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1);
425
426 using BASE_ARRAY::erase_last;
427 ::collection::count erase_last(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1);
428
429 ::collection::count _067CaseInsensitiveRemove(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1, ::collection::count countMin = 0, ::collection::count countMax = -1);
430
431 ::collection::count _067Remove(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1, ::collection::count countMin = 0, ::collection::count countMax = -1);
432
433 ::collection::count case_insensitive_erase(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1);
434
435 ::collection::count erase(const SCOPED_STRING & str, ::collection::index iFind = 0, ::collection::index iLast = -1);
436
437
438 template < prototype_container CONTAINER >
439 ::collection::count case_insensitive_erase(const CONTAINER & container);
440
441 template < prototype_container CONTAINER >
442 ::collection::count erase(const CONTAINER & container);
443
444 string_base_array & explode(const SCOPED_STRING & strSeparator, const SCOPED_STRING & str, bool bAddEmpty = true);
445
446 string_base_array & _001Explode(const SCOPED_STRING & str);
447
448 // csstidy: Same as explode, but not within a Type
449 //string_base_array & csstidy_explode_ws(::i8 sep,const SCOPED_STRING &str);
450
451
452 //template < typename PRED >
453 //void predicate_implode(Type & rwstr,PRED pred, const SCOPED_STRING &strSeparator = nullptr,::collection::index iStart = 0,::collection::count iCount = -1) const;
454
455
456 template < typename PRED >
457 Type predicate_implode(PRED pred, const SCOPED_STRING & strSeparator = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
458
459
460 //void implode(Type & rwstr,const SCOPED_STRING &strSeparator = nullptr,::collection::index iStart = 0,::collection::count iCount = -1) const;
461
462 Type implode(const SCOPED_STRING & strSeparator = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
463
464 Type postfix_implode(const SCOPED_STRING& strSuffix = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
465
467
468 Type reverse_implode(const SCOPED_STRING & strSeparator = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
469
470
471 //void _008Implode(Type & rwstr, const SCOPED_STRING &strSeparator = nullptr, const SCOPED_STRING &strLastSeparator = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
472
473 Type _008Implode(const SCOPED_STRING & strSeparator = nullptr, const SCOPED_STRING & strLastSeparator = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
474
475
476 //void _008IfImplode(Type & rwstr, const SCOPED_STRING &strIfHasElementPrefix = nullptr, const SCOPED_STRING &strSeparator = nullptr, const SCOPED_STRING &strLastSeparator = nullptr, bool bUseLast = true, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
477
478 Type _008IfImplode(const SCOPED_STRING & strIfHasElementPrefix = nullptr, const SCOPED_STRING & strSeparator = nullptr, const SCOPED_STRING & strLastSeparator = nullptr, bool bUseLast = true, ::collection::index iStart = 0, ::collection::count iCount = -1) const;
479
480
481 void surround(const SCOPED_STRING & strPrefix = nullptr, const SCOPED_STRING & strSuffix = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1);
482 Type surround_and_implode(const SCOPED_STRING & strSeparator = nullptr, const SCOPED_STRING & strPrefix = nullptr, const SCOPED_STRING & strSuffix = nullptr, ::collection::index iStart = 0, ::collection::count iCount = -1);
483
484
485 //comparable_array < atom > get_comparable_ida() const;
486
487 //::collection::count explode_command_line(const SCOPED_STRING &str, address_array < char_pointer > * argv = nullptr);
488
489
490
491 // void XFV001Expand();
492
493 //string_base_array & operator =(const ::payload & payload);
494 // string_base_array & operator =(const string_base_array & stra);
495 //string_base_array & operator =(const i64_array_base & ia);
496 // string_base_array & operator =(const string_base_array & stra);
497 //string_base_array & operator -=(const string_base_array & stra);
498 //string_base_array & operator +=(const string_base_array & stra);
499
500 using BASE_ARRAY::operator +=;
501 //using BASE_ARRAY::operator -=;
502
503
504 //string_base_array operator -(const string_base_array & stra) const;
505 //string_base_array operator +(const string_base_array & stra) const;
506 // string_base_array operator -(const string_base_array & stra) const;
507 // string_base_array operator +(const string_base_array & stra) const;
508
509
510 bool operator == (const BASE_RAW_STRING_ARRAY & a) const;
511 bool operator != (const BASE_RAW_STRING_ARRAY & a) const;
512
513
514 void replace_with(const SCOPED_STRING & strNew, const SCOPED_STRING & strOld);
515
516
517 //void write(stream & ostream) const;
518 //void read(stream & istream);
519
520
521 void get_format_string(Type & str, const SCOPED_STRING & strSeparator) const;
522
523 void add_tokens(const SCOPED_STRING & str, const SCOPED_STRING & strSeparator, bool bAddEmpty = true);
524
525 void add_smallest_tokens(const SCOPED_STRING & str, const BASE_RAW_STRING_ARRAY & straSeparator, bool bAddEmpty = true, bool bWithSeparator = false);
526
527 void add_words(const SCOPED_STRING & str);
528
529
535 template < bool bAddEmpty >
536 typename Type::const_iterator _____add_lines_rn(const SCOPED_STRING & scopedstr, bool bWithEOL);
537 //template < CHARACTER chSeparator, bool bAddEmpty >
538 //typename Type::const_iterator _____add_lines(const SCOPED_STRING & scopedstr);
543 template < bool bAddEmpty >
544 void __add_lines_suffix(typename Type::const_iterator start, typename Type::const_iterator end)
545 {
546
547 if (start < end)
548 {
549
550 this->add_item({ start, end });
551
552 }
553 else if (bAddEmpty)
554 {
555
556 this->add_item({});
557
558 }
559
560 }
561 template < bool bAddEmpty >
562 void __add_lines_rn(const SCOPED_STRING & scopedstr) { __add_lines_suffix<bAddEmpty>(__add_lines_rn<bAddEmpty>(scopedstr), scopedstr.end()); }
563 template < CHARACTER chSeparator, bool bAddEmpty >
564 void __add_lines(const SCOPED_STRING & scopedstr) { __add_lines_suffix<bAddEmpty>(__add_lines<chSeparator, bAddEmpty>(scopedstr), scopedstr.end()); }
565 template < bool bAddEmpty >
566 void _add_lines(const SCOPED_STRING & scopedstr, bool bWithEOL = false);
567 void add_lines(const SCOPED_STRING & scopedstr, bool bAddEmpty = true, bool bWithEOL = false)
568 {
569 if (bAddEmpty)_add_lines<true>(scopedstr, bWithEOL); else _add_lines<false>(scopedstr, bWithEOL);
570 }
571
578 template < CHARACTER chSeparator, bool bAddEmpty >
579 typename Type::const_iterator _____add_lines(const SCOPED_STRING & scopedstr, bool bWithEOL = false)
580 {
581
582 auto range = scopedstr();
583
584 while (true)
585 {
586
587 auto p = range.find(chSeparator);
588
589 if (::is_null(p))
590 {
591
592 return range.begin();
593
594 }
595
596 __add_lines_suffix<bAddEmpty>(range.begin(), bWithEOL ? p + 1 : p);
597
598 range.begin(p + 1);
599
600 }
601
602 }
603
604
605
606 void _001AddTokens(const SCOPED_STRING & str);
607
608
609
610 bool is_empty(::collection::count countMinimum = 1) const;
611 bool has_elements(::collection::count countMinimum = 1) const;
612
613 Type encode_v16();
614
615
616 void decode_v16(const SCOPED_STRING & str);
617
618 ::collection::count count_except(const SCOPED_STRING & str);
619 ::collection::count count_except(const string_base_array & stra);
620
621 ::collection::count case_insensitive_count_except(const SCOPED_STRING & str);
622 ::collection::count case_insensitive_count_except(const string_base_array & stra);
623
624 Type & get_network_payload(Type & str, bool bNewLine = true) const;
625
626
627
628 // c_get
629 ::array_base < const_char_pointer >c_ansi_get(bool bMemoryAlloc = false) const;
630 //::array < const ::wide_character * > c_wide_get(bool bMemoryAlloc = false) const;
631 void c_add(char_pointer * ppsz, ::collection::count iCount, bool bMemoryAlloc = false);
632 void c_add(char_pointer * ppsz, bool bMemoryAlloc = false);
633 void c_add(wchar_t ** ppsz, ::collection::count iCount, bool bMemoryAlloc = false);
634 void c_add(wchar_t ** ppsz, bool bMemoryAlloc = false);
635
636 void feed_line(const ::scoped_string& scopedstr, bool bCarriage)
637 {
638 if (this->m_erange & e_range_array_carriage_return)
639 {
640 if (this->has_elements())
641 {
642 this->last() = scopedstr;
643 }
644 else
645 {
646 this->add(scopedstr);
647 }
648 if (!bCarriage)
649 {
650 this->m_erange = this->m_erange & ~e_range_array_carriage_return;
651 }
652 }
653 else
654 {
655 this->add(scopedstr);
656 if (bCarriage)
657 {
658 this->m_erange = this->m_erange | e_range_array_carriage_return;
659 }
660
661 }
662 }
663
664 string_base_array & intersect(const string_base_array & a)
665 {
666
667 for (::collection::index i = 0; i < get_size(); )
668 {
669
670 if (!a.contains(element_at(i)))
671 {
672
673 this->erase_at(i);
674
675 }
676 else
677 {
678
679 i++;
680
681 }
682
683 }
684
685 return *this;
686
687 }
688
689 string_base_array & case_insensitive_intersect(const string_base_array & a)
690 {
691
692 for (::collection::index i = 0; i < get_size(); )
693 {
694
695 if (!a.case_insensitive_contains(element_at(i)))
696 {
697
698 this->erase_at(i);
699
700 }
701 else
702 {
703
704 i++;
705
706 }
707
708 }
709
710 return *this;
711
712 }
713
714 string_base_array & operator &=(const string_base_array & a)
715 {
716
717 return intersect(a);
718
719 }
720
721
722 ::std::strong_ordering case_insensitive_order(const THIS_RAW_RANGE & rawrange) const
723 {
724
725 return BASE_ARRAY::order(rawrange, ::comparison::case_insensitive < Type >());
726
727 }
728
729
730};
731
732
733//typedef CLASS_DECL_ACME string_base_array < string > string_array_base;
734
735
736
737class CLASS_DECL_ACME string_array_array_base :
738 public ::array_base < string_array_base >
739{
740public:
741
742
743 void add_csv(const ::scoped_string & scopedstr);
744
745
746};
747
748
749CLASS_DECL_ACME bool next_csv(string & str, const string_array_base & stra);
750CLASS_DECL_ACME void add_csv(string_array_base & stra, const ::scoped_string & scopedstr);
751
752CLASS_DECL_ACME string_array_base string_array_from_strdup_count(const_char_pointer *pszaUrl, long lCount);
753
754
755
756
757
Definition comparable_array.h:9
Definition range.h:223
Definition string_array.h:739
Definition string_array.h:47
void c_add(wchar_t **ppsz, bool bMemoryAlloc=false)
expect strings allocated with malloc (sic, not acme::get()->m_pheapmanagement->memory(::heap::e_memor...
Definition _impl_string_array.h:4321
void c_add(char_pointer *ppsz, bool bMemoryAlloc=false)
expect strings allocated with malloc (sic, not acme::get()->m_pheapmanagement->memory(::heap::e_memor...
Definition _impl_string_array.h:4226
Type::const_iterator _____add_lines(const SCOPED_STRING &scopedstr, bool bWithEOL=false)
Add Lines in a string that contains only one type of separator @chSeparator.
Definition string_array.h:579
void c_add(char_pointer *ppsz, ::collection::count iCount, bool bMemoryAlloc=false)
expect strings allocated with malloc (sic, not acme::get()->m_pheapmanagement->memory(::heap::e_memor...
Definition _impl_string_array.h:4174
void __add_lines_suffix(typename Type::const_iterator start, typename Type::const_iterator end)
Add Last Line when adding lines in a string.
Definition string_array.h:544
Type reverse_implode(const SCOPED_STRING &strSeparator=nullptr, ::collection::index iStart=0, ::collection::count iCount=-1) const
void reverse_implode(Type & rwstr,const SCOPED_STRING &strSeparator = nullptr,collection::index iStar...
Definition _impl_string_array.h:2651
Type::const_iterator _____add_lines_rn(const SCOPED_STRING &scopedstr, bool bWithEOL)
Add Lines in a string that contains at least one '\r' character and one ' ' character.
Definition _impl_string_array.h:983
void c_add(wchar_t **ppsz, ::collection::count iCount, bool bMemoryAlloc=false)
expect strings allocated with malloc (sic, not acme::get()->m_pheapmanagement->memory(::heap::e_memor...
Definition _impl_string_array.h:4273