acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_.h
1#pragma once
2
3
4// OS ANCIENT strcpy
5// OS ANCIENT WIDE wcscpy
6
7// ancient
8// scaffold implementation: sometimes OS doesn't implement a OS ancient function or
9// whole certain wd16/32 version, the scaffold implementation
10// supplies a "local"/alternative implementation (even if the
11// OS already implements it)
12// scaffold-1 __ansicpy
13// scaffold-2 __wd16cpy
14// scaffold-3 __wd32cpy
15
16
17// coupling
18// ready-to-use : inlined version of either OS version (default) or scaffold version
19// (when there is no OS version).
20// ready-to-use-1 ansi_cpy
21// ready-to-use-2 wd16_cpy
22// ready-to-use-3 wd32_cpy
23
24
25//inline character_count strlen_s_dup(const ::scoped_string & scopedstr, character_count nsize);
26
27
28template < prototype_character CHARACTER >
29inline const CHARACTER * _unicode_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
30{
31
32 ::i32 len1;
33
34 ::i32 len2;
35
36 while (*psz)
37 {
38
39 auto index = unicode_index_length(psz, len1);
40
41 auto pszCharactersScan = pszCharacters;
42
43 do
44 {
45
46 if (index == unicode_index_length(pszCharactersScan, len2))
47 {
48
49 return psz;
50
51 }
52
53 pszCharactersScan += len2;
54
55 } while (*pszCharactersScan);
56
57 psz += len1;
58
59 }
60
61 return psz;
62
63}
64
65
66template < prototype_character CHARACTER >
67const CHARACTER * unicode_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
68{
69
70 if (::is_empty(psz))
71 {
72
73 return psz;
74
75 }
76
77 if (::is_empty(pszCharacters))
78 {
79
80 return psz;
81
82 }
83
84 return _unicode_scan(psz, pszCharacters);
85
86}
87
88
89template < prototype_character CHARACTER >
90const CHARACTER * _string_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
91{
92
93 //::i32 len1;
94
95 while (*psz)
96 {
97
98 auto ch = *psz;
99
100 auto pszCharactersScan = pszCharacters;
101
102 do
103 {
104
105 if (ch == *pszCharactersScan)
106 {
107
108 return psz;
109
110 }
111
112 pszCharactersScan++;
113
114 } while (*pszCharactersScan);
115
116 psz++;
117
118 }
119
120 return psz;
121
122}
123
124
125template < prototype_character CHARACTER >
126const CHARACTER * string_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
127{
128
129 if (::is_empty(psz))
130 {
131
132 return psz;
133
134 }
135
136 if (::is_empty(pszCharacters))
137 {
138
139 return psz;
140
141 }
142
143 return _string_scan(psz, pszCharacters);
144
145}
146
147
148//template < prototype_character CHARACTER >
149//inline const CHARACTER * _unicode_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
150//{
151//
152// ::i32 len1;
153//
154// ::i32 len2;
155//
156// while (*psz)
157// {
158//
159// auto index = unicode_index_length(psz, len1);
160//
161// auto pszCharactersScan = pszCharacters;
162//
163// do
164// {
165//
166// if (index == unicode_index_length(pszCharactersScan, len2))
167// {
168//
169// return psz;
170//
171// }
172//
173// pszCharactersScan += len2;
174//
175// } while (*pszCharactersScan);
176//
177// psz += len1;
178//
179// }
180//
181// return psz;
182//
183//}
184//
185//
186//template < prototype_character CHARACTER >
187//const CHARACTER * unicode_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
188//{
189//
190// if (::is_empty(psz))
191// {
192//
193// return psz;
194//
195// }
196//
197// if (::is_empty(pszCharacters))
198// {
199//
200// return psz;
201//
202// }
203//
204// return _unicode_scan(psz, pszCharacters);
205//
206//}
207
208
209//template < prototype_character CHARACTER >
210//const CHARACTER * _string_rear_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
211//{
212//
213// a
214//
215// ::i32 len1;
216//
217// while (*psz)
218// {
219//
220// auto ch = *psz;
221//
222// auto pszCharactersScan = pszCharacters;
223//
224// do
225// {
226//
227// if (ch == *pszCharactersScan)
228// {
229//
230// return psz;
231//
232// }
233//
234// pszCharactersScan++;
235//
236// } while (*pszCharactersScan);
237//
238// psz++;
239//
240// }
241//
242// return psz;
243//
244//}
245//
246//
247//template < prototype_character CHARACTER >
248//const CHARACTER * string_rear_scan(const CHARACTER * psz, const CHARACTER * pszCharacters)
249//{
250//
251// if (::is_empty(psz))
252// {
253//
254// return psz;
255//
256// }
257//
258// if (::is_empty(pszCharacters))
259// {
260//
261// return psz;
262//
263// }
264//
265// return _string_rear_scan(psz, pszCharacters);
266//
267//}
268
269
270consteval auto string_order_folder_first()
271{
272
273 return [](const_char_pointer pszA, const_char_pointer pszB)
274 {
275
276 ::i32 i = 0;
277
278 while (*pszA && *pszB && ((i = *pszA - *pszB) == 0))
279 {
280
281 pszA++;
282 pszB++;
283
284 }
285
286 if (i == 0)
287 {
288
289 return false;
290
291 }
292 else if (*pszA == '\0')
293 {
294
295 return true;
296
297 }
298 else if (*pszB == '\0')
299 {
300
301
302 return false;
303
304 }
305 else if (*pszA == '/')
306 {
307
308 return true;
309
310 }
311 else if (*pszB == '/')
312 {
313
314 return false;
315
316 }
317 else if (i >= 0)
318 {
319
320 return false;
321
322 }
323
324 return true;
325
326 };
327
328}
329
330
331#include "ancient/_.h"
332#include "coupling.h"
333#include "encoding.h"
334#include "extension/_.h"
335#include "unicode.h"
336
337