YSTest: cstring.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

cstring.h
浏览该文件的文档.
1 /*
2 © 2009-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
30 #ifndef YB_INC_ystdex_cstring_h_
31 #define YB_INC_ystdex_cstring_h_ 1
32
33 #include "type_pun.hpp" // for is_in_types, enable_if_t, not_, or_,
34 // is_trivially_replaceable, cond_t, replace_cast, enable_if_replaceable_t;
35 #include <cstring> // for std::strlen, std::strcpy, std::strncpy;
36 #include <string> // for std::char_traits;
37 #include "cassert.h" // for yconstraint;
38 #include "cctype.h" // for ystdex::tolower;
39 #include <cwchar> // for std::wcscpy, std::wcsncpy;
40 #include <algorithm> // for std::min, std::lexicographical_compare;
41
42 namespace ystdex
43 {
44
49 inline YB_PURE size_t
50 strlen_n(const char* s)
51 {
52 return s ? std::strlen(s) : 0;
53 }
54
61 inline char*
62 strcpy_n(char* d, const char* s)
63 {
64 return d && s ? std::strcpy(d, s) : nullptr;
65 }
66
73 YB_API char*
74 strcpycat(char*, const char*, const char*);
75
83 YB_API char*
84 strcatdup(const char*, const char*, void*(*)(size_t) = std::malloc);
85
86
94 template<typename _tChar>
95 struct is_char_specialized_in_std
96 : is_in_types<_tChar, char, wchar_t, char16_t, char32_t>
97 {};
98
99
101
102
106 template<typename _tChar, typename _type = void>
107 using enable_if_irreplaceable_char_t = enable_if_t<not_<or_<
108 is_trivially_replaceable<_tChar, char>,
109 is_trivially_replaceable<_tChar, wchar_t>>>::value, _type>;
110
111
117 using uchar_t = cond_t<is_trivially_replaceable<wchar_t, char16_t>, char16_t,
118 cond_t<is_trivially_replaceable<wchar_t, char32_t>, char32_t, void>>;
120
121
123
124 template<typename _tChar>
126 yconstfn YB_STATELESS bool
127 is_null(_tChar c) ynothrow
128 {
129 return std::char_traits<_tChar>::eq(c, _tChar());
130 }
131
132
146
148
150
152 template<typename _tChar>
153 YB_NONNULL(1, 2) YB_PURE int
154 ntctscmp(const _tChar* s1, const _tChar* s2) ynothrowv
155 {
156 yconstraint(s1),
157 yconstraint(s2);
158
159 while(*s1 == *s2 && !ystdex::is_null(*s1))
160 yunseq(++s1, ++s2);
161 return int(*s1 - *s2);
162 }
164
165 inline YB_NONNULL(1, 2) YB_PURE int
166 ntctscmp(const char* s1, const char* s2) ynothrowv
167 {
168 yconstraint(s1),
169 yconstraint(s2);
170 return std::strcmp(s1, s2);
171 }
172 inline YB_NONNULL(1, 2) YB_PURE int
173 ntctscmp(const wchar_t* s1, const wchar_t* s2) ynothrowv
174 {
175 yconstraint(s1),
176 yconstraint(s2);
177 return std::wcscmp(s1, s2);
178 }
179 inline YB_NONNULL(1, 2) YB_PURE int
180 ntctscmp(const uchar_t* s1, const uchar_t* s2) ynothrowv
181 {
182 return ntctscmp(replace_cast<const wchar_t*>(s1),
183 replace_cast<const wchar_t*>(s2));
184 }
186
187 template<typename _tChar>
189 YB_NONNULL(1, 2) YB_PURE int
190 ntctscmp(const _tChar* s1, const _tChar* s2, size_t n) ynothrowv
191 {
192 return yconstraint(s1), yconstraint(s2),
193 std::char_traits<_tChar>::compare(s1, s2, n);
194 }
196 template<typename _tChar>
197 YB_NONNULL(1, 2) YB_PURE int
198 ntctscmp(const _tChar* s1, const _tChar* s2, size_t n1, size_t n2) ynothrowv
199 {
200 return yconstraint(s1), yconstraint(s2),
201 std::lexicographical_compare(s1, s1 + n1, s2, s2 + n2);
202 }
203
205
211 template<typename _tChar>
212 YB_NONNULL(1, 2) YB_PURE int
213 ntctsicmp(const _tChar* s1, const _tChar* s2) ynothrowv
214 {
215 yconstraint(s1),
216 yconstraint(s2);
217
218 while(ystdex::tolower(*s1) == ystdex::tolower(*s2) && !ystdex::is_null(s2))
219 yunseq(++s1, ++s2);
220 return int(ystdex::tolower(*s1) - ystdex::tolower(*s2));
221 }
227 template<typename _tChar>
228 YB_NONNULL(1, 2) YB_PURE int
229 ntctsicmp(const _tChar* s1, const _tChar* s2, size_t n) ynothrowv
230 {
231 yconstraint(s1),
232 yconstraint(s2);
233
234 using int_type = typename std::char_traits<_tChar>::int_type;
235 int_type d(0);
236
237 while(n-- != 0 && (d = int_type(ystdex::tolower(*s1))
238 - int_type(ystdex::tolower(*s2))) == int_type(0)
239 && !ystdex::is_null(*s2))
240 yunseq(++s1, ++s2);
241 return int(d);
242 }
243
245
246
248 template<typename _tChar>
249 YB_NONNULL(1, 2) yimpl(enable_if_irreplaceable_char_t<_tChar, _tChar*>)
250 ntctscpy(_tChar* s1, const _tChar* s2) ynothrowv
251 {
252 yconstraint(s1),
253 yconstraint(s2);
254
255 const auto res(s1);
256
257 while(!ystdex::is_null(*s1++ = *s2++))
258 ;
259 return res;
260 }
261 inline YB_NONNULL(1, 2) char*
262 ntctscpy(char* s1, const char* s2) ynothrowv
263 {
264 yconstraint(s1),
265 yconstraint(s2);
266 return std::strcpy(s1, s2);
267 }
268 inline YB_NONNULL(1, 2) wchar_t*
269 ntctscpy(wchar_t* s1, const wchar_t* s2) ynothrowv
270 {
271 yconstraint(s1),
272 yconstraint(s2);
273 return std::wcscpy(s1, s2);
274 }
275 inline YB_NONNULL(1, 2) wchar_t*
276 ntctscpy(uchar_t* s1, const uchar_t* s2) ynothrowv
277 {
278 return ntctscpy(replace_cast<wchar_t*>(s1),
279 replace_cast<const wchar_t*>(s2));
280 }
281 template<typename _tChar,
282 yimpl(typename = enable_if_replaceable_t<_tChar, char>)>
283 inline YB_NONNULL(1, 2) _tChar*
284 ntctscpy(_tChar* s1, const _tChar* s2) ynothrowv
285 {
286 return ystdex::replace_cast<_tChar*>(ystdex::ntctscpy(ystdex::replace_cast<
287 char*>(s1), ystdex::replace_cast<const char*>(s2)));
288 }
289 template<typename _tChar>
290 inline YB_NONNULL(1, 2) yimpl(enable_if_replaceable_t)<_tChar, wchar_t, _tChar*>
291 ntctscpy(_tChar* s1, const _tChar* s2) ynothrowv
292 {
293 return ystdex::replace_cast<_tChar*>(ystdex::ntctscpy(ystdex::replace_cast<
294 wchar_t*>(s1), ystdex::replace_cast<const wchar_t*>(s2)));
295 }
297 template<typename _tChar>
299 YB_NONNULL(1, 2) _tChar*
300 ntctscpy(_tChar* s1, const _tChar* s2, size_t n) ynothrowv
301 {
302 yconstraint(s1),
303 yconstraint(s2);
304 return yunseq(std::char_traits<_tChar>::copy(s1, s2, n), s1[n] = _tChar());
305 }
306
313 template<typename _tChar>
314 YB_NONNULL(1, 2) yimpl(enable_if_irreplaceable_char_t<_tChar, _tChar*>)
315 ntctsncpy(_tChar* s1, const _tChar* s2, size_t n) ynothrowv
316 {
317 yconstraint(s1),
318 yconstraint(s2);
319
320 const auto res(s1);
321
322 while(n != 0)
323 {
324 --n;
325 if(ystdex::is_null(*s1++ = *s2++))
326 break;
327 }
328 while(n-- != 0)
329 *s1++ = _tChar();
330 return res;
331 }
332 inline YB_NONNULL(1, 2) char*
333 ntctsncpy(char* s1, const char* s2, size_t n) ynothrowv
334 {
335 yconstraint(s1),
336 yconstraint(s2);
337 return std::strncpy(s1, s2, n);
338 }
339 inline YB_NONNULL(1, 2) wchar_t*
340 ntctsncpy(wchar_t* s1, const wchar_t* s2, size_t n) ynothrowv
341 {
342 yconstraint(s1),
343 yconstraint(s2);
344 return std::wcsncpy(s1, s2, n);
345 }
346 inline YB_NONNULL(1, 2) wchar_t*
347 ntctsncpy(uchar_t* s1, const uchar_t* s2, size_t n) ynothrowv
348 {
349 return ntctsncpy(replace_cast<wchar_t*>(s1),
350 replace_cast<const wchar_t*>(s2), n);
351 }
352 template<typename _tChar,
353 yimpl(typename = enable_if_replaceable_t<_tChar, char>)>
354 inline YB_NONNULL(1, 2) _tChar*
355 ntctsncpy(_tChar* s1, const _tChar* s2, size_t n) ynothrowv
356 {
357 return ystdex::replace_cast<_tChar*>(ystdex::ntctsncpy(ystdex::replace_cast<
358 char*>(s1), ystdex::replace_cast<const char*>(s2), n));
359 }
360 template<typename _tChar>
361 inline YB_NONNULL(1, 2) yimpl(enable_if_replaceable_t)<_tChar, wchar_t, _tChar*>
362 ntctsncpy(_tChar* s1, const _tChar* s2, size_t n) ynothrowv
363 {
364 return ystdex::replace_cast<_tChar*>(ystdex::ntctsncpy(ystdex::replace_cast<
365 wchar_t*>(s1), ystdex::replace_cast<const wchar_t*>(s2), n));
366 }
368
369
374 template<typename _tChar>
375 YB_NONNULL(1, 2) _tChar*
376 ntctsmove(_tChar* s1, const _tChar* s2, size_t n) ynothrowv
377 {
378 yconstraint(s1),
379 yconstraint(s2);
380 return yunseq(std::char_traits<_tChar>::move(s1, s2, n), s1[n] = _tChar());
381 }
383
385
386
391 template<typename _tChar>
392 YB_NONNULL(1) YB_PURE _tChar*
393 ntctschr(_tChar* s, remove_const_t<_tChar> c) ynothrowv
394 {
395 yconstraint(s);
396 for(auto p(s); !ystdex::is_null(*p); ++p)
397 if(*p == c)
398 return p;
399 return {};
400 }
401 inline YB_NONNULL(1) YB_PURE char*
402 ntctschr(char* s, char c) ynothrowv
403 {
404 yconstraint(s);
405 return std::strchr(s, c);
406 }
407 inline YB_NONNULL(1) YB_PURE const char*
408 ntctschr(const char* s, char c) ynothrowv
409 {
410 yconstraint(s);
411 return std::strchr(s, c);
412 }
413 inline YB_NONNULL(1) YB_PURE wchar_t*
414 ntctschr(wchar_t* s, wchar_t c) ynothrowv
415 {
416 yconstraint(s);
417 return std::wcschr(s, c);
418 }
419 inline YB_NONNULL(1) YB_PURE const wchar_t*
420 ntctschr(const wchar_t* s, wchar_t c) ynothrowv
421 {
422 yconstraint(s);
423 return std::wcschr(s, c);
424 }
425 inline YB_NONNULL(1) YB_PURE uchar_t*
426 ntctschr(uchar_t* s, uchar_t c) ynothrowv
427 {
428 return replace_cast<uchar_t*>(
429 ntctschr(replace_cast<wchar_t*>(s), wchar_t(c)));
430 }
431 inline YB_NONNULL(1) YB_PURE const uchar_t*
432 ntctschr(const uchar_t* s, uchar_t c) ynothrowv
433 {
434 return replace_cast<const uchar_t*>(
435 ntctschr(replace_cast<const wchar_t*>(s), wchar_t(c)));
436 }
438
443 template<typename _tChar>
444 inline YB_NONNULL(1) YB_PURE size_t
445 ntctsfind(const _tChar* s, size_t n, _tChar c) ynothrowv
446 {
447 return yconstraint(s), std::char_traits<_tChar>::find(s, n, c);
448 }
449
454 template<typename _tChar>
455 inline YB_NONNULL(1) YB_PURE size_t
456 ntctslen(const _tChar* s) ynothrowv
457 {
458 return yconstraint(s), std::char_traits<_tChar>::length(s);
459 }
461 template<typename _tChar>
462 inline YB_NONNULL(1) YB_PURE size_t
463 ntctslen(const _tChar* s, size_t n) ynothrowv
464 {
465 return ystdex::ntctsfind(s, n, _tChar());
466 }
468
469
470
472
473
477 template<typename _tChar>
478 yconstfn YB_NONNULL(1) YB_PURE size_t
479 const_ntctslen(const _tChar* s) ynothrowv
480 {
481 return ystdex::is_null(*s) ? 0 : ystdex::const_ntctslen(s + 1) + 1;
482 }
483
485 template<typename _tChar>
486 yconstfn YB_NONNULL(1) YB_PURE size_t
487 const_ntctscnt(const _tChar* s, _tChar c) ynothrowv
488 {
489 return ystdex::is_null(*s) ? 0 : ystdex::const_ntctscnt(s + 1, c)
490 + std::char_traits<_tChar>::eq(*s, c);
491 }
492
497 template<typename _tChar>
498 yconstfn YB_NONNULL(1, 2) YB_PURE typename std::char_traits<_tChar>::int_type
499 const_ntctscmp(const _tChar* s1, const _tChar* s2) ynothrowv
500 {
501 return !std::char_traits<_tChar>::eq(*s1, *s2) || ystdex::is_null(*s1)
502 || ystdex::is_null(*s2) ? *s1 - *s2
503 : ystdex::const_ntctscmp(s1 + 1, s2 + 1);
504 }
509 template<typename _tChar>
510 yconstfn YB_NONNULL(1, 2) YB_PURE typename std::char_traits<_tChar>::int_type
511 const_ntctscmp(const _tChar* s1, const _tChar* s2, size_t n) ynothrowv
512 {
513 return n == 0 ? _tChar() : (!std::char_traits<_tChar>::eq(*s1, *s2)
514 || ystdex::is_null(*s1) || ystdex::is_null(*s2) ? *s1 - *s2
515 : ystdex::const_ntctscmp(s1 + 1, s2 + 1, n - 1));
516 }
517
522 template<typename _tChar>
523 yconstfn YB_NONNULL(1) YB_PURE size_t
524 const_ntctsfind(const _tChar* s, _tChar c) ynothrowv
525 {
526 return ystdex::is_null(*s) || std::char_traits<_tChar>::eq(*s, c)
527 ? 0 : ystdex::const_ntctsfind(s + 1, c) + 1;
528 }
533 template<typename _tChar>
534 yconstfn YB_NONNULL(1) YB_PURE size_t
535 const_ntctsfind(const _tChar* s, _tChar c, size_t n) ynothrowv
536 {
537 return n == 0 || ystdex::is_null(*s) ? 0 : (std::char_traits<_tChar>
538 ::eq(*s, c) ? ystdex::const_ntctsfind(s + 1, c, n - 1) + (n != 1)
539 : ystdex::const_ntctsfind(s + 1, c, n) + 1);
540 }
545 template<typename _tChar>
546 yconstfn YB_NONNULL(1) YB_PURE size_t
547 const_ntctsfind(const _tChar* s1, const _tChar* s2) ynothrowv
548 {
549 return ystdex::is_null(*s1) ? 0 : (ystdex::const_ntctscmp(s1, s2,
550 ystdex::const_ntctslen(s2)) == _tChar()? 0
551 : ystdex::const_ntctsfind(s1 + 1, s2) + 1);
552 }
554
555
556
558
559 template<typename _tChar, typename _tSize,
560 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
561 yconstfn_relaxed _tSize
562 str_find(const _tChar* p, _tSize sz, _tChar c, _tSize pos) ynothrowv
563 {
564 yconstraint(p || sz == 0);
565 if(pos < sz)
566 if(const _tChar* ret = _tTraits::find(p + pos, sz - pos, c))
567 return _tSize(ret - p);
568 return _vNPos;
569 }
570 template<typename _tChar, typename _tSize,
571 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
572 yconstfn_relaxed _tSize
573 str_find(const _tChar* p, _tSize sz, const _tChar* s, _tSize pos, _tSize n)
574 ynothrowv
575 {
576 yconstraint((p || sz == 0) && (s || n == 0));
577 if(n == 0)
578 return pos <= sz ? pos : _vNPos;
579 if(n <= sz)
580 for(; pos <= sz - n; ++pos)
581 if(_tTraits::eq(p[pos], s[0])
582 && _tTraits::compare(p + pos + 1, s + 1, n - 1) == 0)
583 return pos;
584 return _vNPos;
585 }
586
587 template<typename _tChar, typename _tSize,
588 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
589 yconstfn_relaxed _tSize
590 str_rfind(const _tChar* p, _tSize sz, _tChar c, _tSize pos) ynothrowv
591 {
592 yconstraint(p || sz == 0);
593 if(0 < sz)
594 {
595 if(pos < --sz)
596 sz = pos;
597 for(++sz; sz-- > 0; )
598 if(_tTraits::eq(*(p + sz), c))
599 return sz;
600 }
601 return _vNPos;
602 }
603 template<typename _tChar, typename _tSize,
604 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
605 yconstfn_relaxed _tSize
606 str_rfind(const _tChar* p, _tSize sz, const _tChar* s, _tSize pos, _tSize n)
607 ynothrowv
608 {
609 yconstraint((p || sz == 0) && (s || n == 0));
610 if(n <= sz)
611 {
612 pos = std::min(_tSize(sz - n), pos);
613 do
614 if(_tTraits::compare(p + pos, s, n) == 0)
615 return pos;
616 while(pos-- > 0);
617 }
618 return _vNPos;
619 }
620
621 template<typename _tChar, typename _tSize,
622 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
623 yconstfn_relaxed _tSize
624 str_find_first_of(const _tChar* p, _tSize sz, const _tChar* s, _tSize pos,
625 _tSize n) ynothrowv
626 {
627 yconstraint((p || sz == 0) && (s || n == 0));
628 if(n != 0)
629 {
630 for(; pos < sz; ++pos)
631 if(_tTraits::find(s, n, p[pos]))
632 return pos;
633 }
634 return _vNPos;
635 }
636
637 template<typename _tChar, typename _tSize,
638 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
639 yconstfn_relaxed _tSize
640 str_find_last_of(const _tChar* p, _tSize sz, const _tChar* s, _tSize pos,
641 _tSize n) ynothrowv
642 {
643 yconstraint((p || sz == 0) && (s || n == 0));
644 if(sz != 0 && n != 0)
645 {
646 if(--sz > pos)
647 sz = pos;
648 do
649 if(_tTraits::find(s, n, p[sz]))
650 return sz;
651 while(sz-- != 0);
652 }
653 return _vNPos;
654 }
655
656 template<typename _tChar, typename _tSize,
657 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
658 yconstfn_relaxed _tSize
659 str_find_first_not_of(const _tChar* p, _tSize sz, _tChar c, _tSize pos)
660 ynothrowv
661 {
662 yconstraint(p || sz == 0);
663 for(; pos < sz; ++pos)
664 if(!_tTraits::eq(p[pos], c))
665 return pos;
666 return _vNPos;
667 }
668 template<typename _tChar, typename _tSize,
669 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
670 yconstfn_relaxed _tSize
671 str_find_first_not_of(const _tChar* p, _tSize sz, const _tChar* s, _tSize pos,
672 _tSize n) ynothrowv
673 {
674 yconstraint((p || sz == 0) && (s || n == 0));
675 for(; pos < sz; ++pos)
676 if(!_tTraits::find(s, n, p[pos]))
677 return pos;
678 return _vNPos;
679 }
680
681 template<typename _tChar, typename _tSize,
682 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
683 yconstfn_relaxed _tSize
684 str_find_last_not_of(const _tChar* p, _tSize sz, _tChar c, _tSize pos) ynothrowv
685 {
686 yconstraint(p || sz == 0);
687 if(sz != 0)
688 {
689 if(--sz > pos)
690 sz = pos;
691 do
692 if(!_tTraits::eq(p[sz], c))
693 return sz;
694 while(sz-- != 0);
695 }
696 return _vNPos;
697 }
698 template<typename _tChar, typename _tSize,
699 class _tTraits = std::char_traits<_tChar>, _tSize _vNPos = _tSize(-1)>
700 yconstfn_relaxed _tSize
701 str_find_last_not_of(const _tChar* p, _tSize sz, const _tChar* s, _tSize pos,
702 _tSize n) ynothrowv
703 {
704 yconstraint((p || sz == 0) && (s || n == 0));
705 if(sz != 0)
706 {
707 if(--sz > pos)
708 sz = pos;
709 do
710 if(!_tTraits::find(s, n, p[sz]))
711 return sz;
712 while(sz -- != 0);
713 }
714 return _vNPos;
715 }
717
718
719 } // namespace ystdex;
720
721 #endif
722
ystdex::const_ntctscmp
std::char_traits< _tChar >::int_type const_ntctscmp(const _tChar *s1, const _tChar *s2)
比较简单 NTCTS 。
Definition: cstring.h:499
platform::p
while p p
Definition: YCLib/FileSystem.h:225
ystdex::is_null
bool is_null(_tChar c)
使用 std::char_traits::eq 判断是否为空字符。
Definition: cstring.h:127
cctype.h
ISO C 字符分类操作扩展。
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:522
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
ystdex::enable_if_irreplaceable_char_t
enable_if_t< not_< or_< is_trivially_replaceable< _tChar, char >, is_trivially_replaceable< _tChar, wchar_t >>>::value, _type > enable_if_irreplaceable_char_t
选择不和 char 或 wchar_t 可替换字符类类型的特定重载以避免冲突。
Definition: cstring.h:109
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:82
cassert.h
ISO C 断言/调试跟踪扩展。
ystdex::str_find_last_not_of
_tSize str_find_last_not_of(const _tChar *p, _tSize sz, _tChar c, _tSize pos)
Definition: cstring.h:684
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:350
ystdex::ntctschr
_tChar * ntctschr(_tChar *s, remove_const_t< _tChar > c)
在简单 NTCTS 内查找字符。
Definition: cstring.h:393
ystdex::ntctsfind
size_t ntctsfind(const _tChar *s, size_t n, _tChar c)
在简单 NTCTS 的指定前若干字符内查找字符。
Definition: cstring.h:445
ystdex::ntctscpy
enable_if_irreplaceable_char_t< _tChar, _tChar * > ntctscpy(_tChar *s1, const _tChar *s2)
复制 NTCTS 。
Definition: cstring.h:250
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:760
ystdex::str_find_last_of
_tSize str_find_last_of(const _tChar *p, _tSize sz, const _tChar *s, _tSize pos, _tSize n)
Definition: cstring.h:640
ystdex::strcatdup
char * strcatdup(const char *, const char *, void *(*)(size_t)=std::malloc)
带空指针检查的字符串连接复制。
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:139
ystdex::uchar_t
cond_t< is_trivially_replaceable< wchar_t, char16_t >, char16_t, cond_t< is_trivially_replaceable< wchar_t, char32_t >, char32_t, void >> uchar_t
指定和 wchar_t 互相替换存储的非 char 内建字符类型。
Definition: cstring.h:118
ystdex::strcpy_n
char * strcpy_n(char *d, const char *s)
带空指针检查的字符串复制。
Definition: cstring.h:62
YSLib::Drawing::char32_t
tr TextRegion &tr char32_t
Definition: TextLayout.h:92
ystdex::cpp2014::remove_const_t
typename remove_const< _type >::type remove_const_t
ISO C++ 14 兼容类型操作别名。
Definition: type_traits.hpp:285
type_pun.hpp
共享存储和直接转换。
CHRLib::c
c
Definition: CharacterProcessing.h:81
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:256
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
ystdex::ntctscmp
int ntctscmp(const _tChar *s1, const _tChar *s2)
按字典序比较简单 NTCTS 。
Definition: cstring.h:154
YB_API
#define YB_API
YBase 应用程序编程接口：用于向库文件约定链接。
Definition: ydef.h:566
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:501
ystdex::ntctsicmp
int ntctsicmp(const _tChar *s1, const _tChar *s2)
按字典序比较简单 NTCTS （忽略大小写）。
Definition: cstring.h:213
ystdex::str_find_first_not_of
_tSize str_find_first_not_of(const _tChar *p, _tSize sz, _tChar c, _tSize pos)
Definition: cstring.h:659
yconstfn_relaxed
#define yconstfn_relaxed
指定编译时没有 C++11 限制和隐式成员 const 的常量函数。
Definition: ydef.h:666
ystdex::strcpycat
char * strcpycat(char *, const char *, const char *)
带空指针检查的字符串连接。
Definition: cstring.cpp:35
std
Definition: memory.hpp:1100
ystdex::ntctsncpy
enable_if_irreplaceable_char_t< _tChar, _tChar * > ntctsncpy(_tChar *s1, const _tChar *s2, size_t n)
复制不超过指定长度的 NTCTS 。
Definition: cstring.h:315
ystdex::str_find
_tSize str_find(const _tChar *p, _tSize sz, _tChar c, _tSize pos)
查找字符或子串。
Definition: cstring.h:562
ystdex::const_ntctscnt
size_t const_ntctscnt(const _tChar *s, _tChar c)
计算简单 NTCTS 中的指定字符数。
Definition: cstring.h:487
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
ystdex
特性测试宏。
Definition: ydef.h:796
ystdex::cond_t
conditional_t< _tCond::value, _tThen, _tElse > cond_t
条件判断。
Definition: type_traits.hpp:698
ystdex::enable_if_replaceable_t
enable_if_t< is_trivially_replaceable< _tSrc, _tDst >::value, _type > enable_if_replaceable_t
选择和特定类型可替换字符类类型的特定重载以避免冲突。
Definition: type_pun.hpp:106
ystdex::replace_cast
ystdex::enable_if_t< and_< is_object_pointer< _pDst >, is_trivially_replaceable< _tSrc, remove_pointer_t< _pDst > > >::value, _pDst > replace_cast(_tSrc *v)
保证平凡替换存储的显式转换。
Definition: type_pun.hpp:204
ystdex::const_ntctslen
size_t const_ntctslen(const _tChar *s)
计算简单 NTCTS 长度。
Definition: cstring.h:479
YSLib::IO::int
YF_API int
Definition: File.h:49
ystdex::ntctsmove
_tChar * ntctsmove(_tChar *s1, const _tChar *s2, size_t n)
转移 NTCTS 。
Definition: cstring.h:376
ystdex::str_rfind
_tSize str_rfind(const _tChar *p, _tSize sz, _tChar c, _tSize pos)
Definition: cstring.h:590
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:654
ystdex::str_find_first_of
_tSize str_find_first_of(const _tChar *p, _tSize sz, const _tChar *s, _tSize pos, _tSize n)
Definition: cstring.h:624
ystdex::is_in_types
判断第一个参数在之后参数指定的类型中出现。
Definition: type_traits.hpp:939
ystdex::min
const _type & min(const _type &a, const _type &b, _fComp comp=less< _type >())
取较小的元素。
Definition: algorithm.hpp:521
ystdex::or_
Definition: type_traits.hpp:412
YSLib::char
char
Definition: ValueNode.h:851
ystdex::is_trivially_replaceable
判断是否可平凡替换存储。
Definition: type_pun.hpp:92
ystdex::tolower
_tChar tolower(_tChar c)
转换大小写字符。
Definition: cctype.h:137
ystdex::strlen_n
size_t strlen_n(const char *s)
带空指针检查的字符串长度计算。
Definition: cstring.h:50
ystdex::is_char_specialized_in_std
判断字符类型是否被 ISO C++ 指定提供 std::char_traits 的特化。
Definition: cstring.h:95
ystdex::ntctslen
size_t ntctslen(const _tChar *s)
计算简单 NTCTS 长度。
Definition: cstring.h:456
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140
ystdex::not_
Definition: type_traits.hpp:430
ystdex::const_ntctsfind
size_t const_ntctsfind(const _tChar *s, _tChar c)
在简单 NTCTS 中顺序查找指定字符。
Definition: cstring.h:524
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321