YSTest: StaticMapping.hpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

StaticMapping.hpp
浏览该文件的文档.
1 /*
2 © 2009-2017 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
28 #ifndef INC_CHRLib_StaticMapping_hpp_
29 #define INC_CHRLib_StaticMapping_hpp_ 1
30
31 #include "YModules.h"
32 #include YFM_CHRLib_CharacterMapping // for std::is_constructible,
33 // ystdex::is_undereferenceable, ystdex::remove_reference_t,
34 // ystdex::pseudo_output, yconstraint;
35 #include <ystdex/cast.hpp> // for ystdex::not_widen_cast;
36
37 namespace CHRLib
38 {
39
41
42
46 template<typename _tIn>
47 inline bool
48 CheckIterator(_tIn& i) ynothrow
49 {
50 static_assert(std::is_constructible<const byte, decltype(*i)>(),
51 "Invalid mapping source type found.");
52 using ystdex::is_undereferenceable;
53
54 return !is_undereferenceable(i);
55 }
56
62 template<typename _tIn>
63 inline bool
64 FillByte(_tIn& i, byte& b) ynoexcept(noexcept(byte(*i)) && noexcept(++i))
65 {
66 if(CheckIterator(i))
67 {
68 const auto r = byte(*i);
69
70 yunseq(++i, b = r);
71 return true;
72 }
73 return {};
74 }
75 template<typename _tIn, typename _tState>
76 inline bool
77 FillByte(_tIn& i, _tState& st) ynoexcept(noexcept(byte(*i)) && noexcept(++i)
78 && noexcept(GetSequenceOf(st)[GetIndexOf(st)++] = byte()))
79 {
80 if(CheckIterator(i))
81 {
82 static_assert(!std::is_volatile<ystdex::remove_reference_t<_tState>>(),
83 "Volatile state is not supported.");
84 const auto r = byte(*i);
85
86 yunseq(++i, GetSequenceOf(st)[GetIndexOf(st)++] = r);
87 return true;
88 }
89 return {};
90 }
91 template<typename _tIn>
92 inline bool
93 FillByte(GuardPair<_tIn>& pr, byte& b) ynoexcept(noexcept(pr.first.get()
94 != pr.second) && noexcept(FillByte(pr.first.get(), b)))
95 {
96 return pr.first.get() != pr.second ? FillByte(pr.first.get(), b) : false;
97 }
98 template<typename _tIn, typename _tState>
99 inline bool
100 FillByte(GuardPair<_tIn>& pr, _tState& st) ynoexcept(noexcept(pr.first.get()
101 != pr.second) && noexcept(FillByte(pr.first.get(), st)))
102 {
103 return pr.first.get() != pr.second ? FillByte(pr.first.get(), st) : false;
104 }
106
107
108
110
111 yconstfn PDefH(bool, IsSurrogateHead, octet x) ynothrow
113 ImplRet(x >= 0xD8 && x < 0xE0)
114
115 yconstfn PDefH(bool, IsValidSurrogateHead, octet x) ynothrow
117 ImplRet(x >= 0xD8 && x < 0xDE)
118
120 yconstfn PDefH(bool, IsValidSurrogateTail, octet x) ynothrow
121 ImplRet(x >= 0xDC && x < 0xE0)
122
123
125 struct UCSMapperBase
126 {
128
129 static void
130 Assign(ystdex::pseudo_output, char32_t) ynothrow
131 {}
132 template<typename _tObj>
133 static void
134 Assign(_tObj& uc, char32_t c) ynothrow
135 {
136 ynoexcept_assert("Invalid type found", uc = _tObj(c));
137
138 uc = _tObj(c);
139 }
141
148 template<typename _tOut>
149 static void
150 EncodeChar(_tOut d, char32_t c) ynothrowv
151 {
152 using ystdex::is_undereferenceable;
153 ynoexcept_assert("Invalid type found.", !is_undereferenceable(d));
154
155 yconstraint(!is_undereferenceable(d));
156 *d = ystdex::not_widen_cast<ystdex::remove_reference_t<decltype(*d)>>(
157 c);
158 }
159 };
160
161
181 template<Encoding>
182 class GUCSMapper
183 {};
184
189 template<>
190 struct GUCSMapper<CharSet::UTF_8> : UCSMapperBase
191 {
192 using UCSMapperBase::Assign;
194 using UCSMapperBase::EncodeChar;
195
196 private:
197 template<typename _tObj, typename _tSeq>
198 static void
199 Assign1(_tObj& uc, const _tSeq& seq) ynothrow
200 {
201 ynoexcept_assert("Invalid type found", Assign(uc, char32_t()));
202
203 Assign(uc, (char32_t(seq[0] & 0x1CU) >> 2U << 8U)
204 | (char32_t(seq[0] & 0x03U) << 6) | (char32_t(seq[1]) & 0x3FU));
205 }
206
207 template<typename _tObj, typename _tSeq>
208 static void
209 Assign2(_tObj& uc, const _tSeq& seq) ynothrow
210 {
211 ynoexcept_assert("Invalid type found", Assign(uc, char32_t()));
212
213 Assign(uc, (((char32_t(seq[0]) & 0x0FU) << 4U
214 | char32_t(seq[1] & 0x3CU) >> 2U) << 8U)
215 | (char32_t(seq[1] & 0x3U) << 6U) | char32_t(seq[2] & 0x3FU));
216 }
217
218 static yconstfn bool
219 CheckInvalid(octet x, octet y = 0x80) ynothrow
220 {
221 return IsInvalid(x) || ((x & 0xC0) != y);
222 }
223
224 public:
229 static yconstfn bool
230 IsInvalid(octet x) ynothrow
231 {
232 return x == 0xC0 || x == 0xC1 || x > 0xF4;
233 }
234
239 template<typename _tObj, typename _tIn, typename _tState>
240 static ConversionResult
241 Decode(_tObj&& uc, _tIn&& i, _tState&& st)
242 ynoexcept(noexcept(GetSequenceOf(st)) && noexcept(GetIndexOf(st))
243 && noexcept(!FillByte(i, st)))
244 {
245 const auto seq(GetSequenceOf(st));
246
247 switch(GetIndexOf(st))
248 {
249 case 0:
250 if(YB_UNLIKELY(!FillByte(i, st)))
251 return ConversionResult::BadSource;
252 if((seq[0] & 0x80) == 0)
253 {
254 Assign(uc, seq[0]);
255 break;
256 }
257 if(YB_UNLIKELY(CheckInvalid(seq[0], 0xC0)))
258 return ConversionResult::Invalid;
259 YB_ATTR_fallthrough;
260 case 1:
261 if(YB_UNLIKELY(!FillByte(i, st)))
262 return ConversionResult::BadSource;
263 if(YB_UNLIKELY(CheckInvalid(seq[1])))
264 return ConversionResult::Invalid;
265 if(((seq[0] ^ 0xC0) & 0xE0) == 0)
266 {
267 Assign1(uc, seq);
268 break;
269 }
270 YB_ATTR_fallthrough;
271 case 2:
272 if(YB_UNLIKELY(!FillByte(i, st)))
273 return ConversionResult::BadSource;
274 if(YB_UNLIKELY(CheckInvalid(seq[2])))
275 return ConversionResult::Invalid;
276 if(((seq[0] ^ 0xE0) & 0xF0) == 0)
277 {
278 Assign2(uc, seq);
279 break;
280 }
281 YB_ATTR_fallthrough;
282 case 3:
283 if(YB_UNLIKELY(!FillByte(i, st)))
284 return ConversionResult::BadSource;
285 if(YB_UNLIKELY(CheckInvalid(seq[3])))
286 return ConversionResult::Invalid;
287 if(YB_LIKELY(((seq[0] ^ 0xF0) & 0xF8) == 0))
288 {
289 Assign2(uc, seq);
290 break;
291 }
292 return ConversionResult::Unhandled;
293 default:
294 return ConversionResult::BadState;
295 }
296 return ConversionResult::OK;
297 }
304 template<typename _tObj, typename _tIn>
305 static ConversionResult
306 Decode(_tObj&& uc, _tIn&& i, ConversionState& st)
307 ynoexcept_spec(!FillByte(i, st))
308 {
309 byte b(0);
310
311 if(YB_UNLIKELY(!FillByte(i, b)))
312 return ConversionResult::BadSource;
313 if((b & 0x80U) == 0)
314 {
315 if(st.Index == 0)
316 {
317 uc = b;
318 return ConversionResult::OK;
319 }
320 return ConversionResult::Invalid;
321 }
322
323 using state_t = std::uint_fast8_t;
324 static yconstexpr const state_t t_data_1[]{
325 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
326 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
327 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3,
328 11, 6, 6, 6, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
329 };
330 static yconstexpr const state_t t_data_2[]{1, 2, 4, 4};
331 auto& code(st.Value.UCS4);
332 #define CHRLib_Impl_UTF8_Decode_Fill \
333 if(YB_UNLIKELY(!FillByte(i, b))) \
334 return ConversionResult::BadSource; \
335 code = (code << 6U) | (b & 0x3FU)
336 #define CHRLib_Impl_UTF8_Decode_Tail \
337 CHRLib_Impl_UTF8_Decode_Fill; \
338 trans(0x70U)
339 #define CHRLib_Impl_UTF8_Decode_FillTransTail(_mask) \
340 CHRLib_Impl_UTF8_Decode_Fill; \
341 trans(_mask); \
342 CHRLib_Impl_UTF8_Decode_Tail;
343 bool res(true);
344 auto trans([&](unsigned mask){
345 res &= (b & 0xC0U) == 0x80U
346 && (t_data_2[byte(b >> 4U) & 0x3U] & byte(mask)) != 0;
347 });
348 auto& type(st.Index);
349
350 if(type == 0)
351 {
352 if((b & 0xC0U) != 0)
353 {
354 type = state_t(t_data_1[b & 0x3FU]);
355 code = (0xFFU >> type) & byte(b);
356 }
357 else
358 return ConversionResult::Invalid;
359 }
360 switch(type)
361 {
362 case 6:
363 CHRLib_Impl_UTF8_Decode_Fill;
364 YB_ATTR_fallthrough;
365 case 3:
366 CHRLib_Impl_UTF8_Decode_Fill;
367 YB_ATTR_fallthrough;
368 case 2:
369 CHRLib_Impl_UTF8_Decode_Fill;
370 break;
371 case 4:
372 CHRLib_Impl_UTF8_Decode_FillTransTail(3U);
373 break;
374 case 10:
375 CHRLib_Impl_UTF8_Decode_FillTransTail(4U);
376 break;
377 case 5:
378 CHRLib_Impl_UTF8_Decode_FillTransTail(1U);
379 CHRLib_Impl_UTF8_Decode_Tail;
380 break;
381 case 11:
382 CHRLib_Impl_UTF8_Decode_FillTransTail(6U);
383 CHRLib_Impl_UTF8_Decode_Tail;
384 break;
385 case 8:
386 return ConversionResult::Invalid;
387 default:
388 return ConversionResult::BadState;
389 }
390 Assign(uc, code);
391 return res ? ConversionResult::OK : ConversionResult::Invalid;
392 #undef CHRLib_Impl_UTF8_Decode_FillTransTail
393 #undef CHRLib_Impl_UTF8_Decode_Tail
394 #undef CHRLib_Impl_UTF8_Decode_Fill
395 }
396 template<typename _tObj, typename _tIn>
397 static ConversionResult
398 Decode(_tObj&& uc, _tIn&& i, ConversionState&& st)
399 ynoexcept_spec(Decode(uc, yforward(i), st))
400 {
401 return Decode(uc, yforward(i), st);
402 }
404
406 template<typename _tOut>
407 static size_t
408 Encode(_tOut d, char32_t c) ynothrow
409 {
410 using ystdex::is_undereferenceable;
411 size_t l(0);
412
413 yconstraint(!is_undereferenceable(d));
414 if(c < 0x80U)
415 {
416 EncodeChar(d, c);
417 return 1;
418 }
419 if(c < 0x800U)
420 l = 2;
421 else
422 {
423 EncodeChar(d, byte(0xE0U | c >> 12U));
424 ++d;
425 l = 3;
426 }
427 EncodeChar(d, byte(0x80U | (c >> 6U & 0x3FU)));
428 ++d;
429 EncodeChar(d, byte(0x80U | (c & 0x3FU)));
430 return l;
431 }
432 };
433
435 template<>
436 struct GUCSMapper<CharSet::UTF_16BE> : UCSMapperBase
437 {
438 using UCSMapperBase::Assign;
439
444 template<typename _tObj, typename _tIn, typename _tState>
445 static ConversionResult
446 Decode(_tObj&& uc, _tIn&& i, _tState&& st)
447 ynoexcept(noexcept(GetSequenceOf(st))
448 && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st)))
449 {
450 const auto seq(GetSequenceOf(st));
451
452 switch(GetIndexOf(st))
453 {
454 case 0:
455 if(YB_UNLIKELY(!FillByte(i, st)))
456 return ConversionResult::BadSource;
457 YB_ATTR_fallthrough;
458 case 1:
459 if(YB_UNLIKELY(!FillByte(i, st)))
460 return ConversionResult::BadSource;
461 if(YB_UNLIKELY(CHRLib::IsSurrogateHead(seq[0])))
462 {
463 if(YB_UNLIKELY(!CHRLib::IsValidSurrogateHead(seq[0])))
464 return ConversionResult::Invalid;
465 YB_ATTR_fallthrough;
466 }
467 else
468 {
469 Assign(uc, char32_t(seq[0]) << 8U | char32_t(seq[1]));
470 break;
471 }
472 case 2:
473 if(YB_UNLIKELY(!FillByte(i, st)))
474 return ConversionResult::BadSource;
475 YB_ATTR_fallthrough;
476 case 3:
477 if(YB_UNLIKELY(!FillByte(i, st)))
478 return ConversionResult::BadSource;
479 if(YB_UNLIKELY(!CHRLib::IsValidSurrogateTail(seq[2])))
480 return ConversionResult::Invalid;
481 Assign(uc, char32_t(seq[0] & 0x03U) << 18U | char32_t(seq[1]) << 10U
482 | char32_t(seq[2] & 0x03U) << 8U | char32_t(seq[3]));
483 break;
484 default:
485 return ConversionResult::BadState;
486 }
487 return ConversionResult::OK;
488 }
489 };
490
492 template<>
493 struct GUCSMapper<CharSet::UTF_16LE> : UCSMapperBase
494 {
495 using UCSMapperBase::Assign;
496
501 template<typename _tObj, typename _tIn, typename _tState>
502 static ConversionResult
503 Decode(_tObj&& uc, _tIn&& i, _tState&& st)
504 ynoexcept(noexcept(GetSequenceOf(st))
505 && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st)))
506 {
507 const auto seq(GetSequenceOf(st));
508
509 switch(GetIndexOf(st))
510 {
511 case 0:
512 if(YB_UNLIKELY(!FillByte(i, st)))
513 return ConversionResult::BadSource;
514 YB_ATTR_fallthrough;
515 case 1:
516 if(YB_UNLIKELY(!FillByte(i, st)))
517 return ConversionResult::BadSource;
518 if(YB_UNLIKELY(CHRLib::IsSurrogateHead(seq[1])))
519 {
520 if(YB_UNLIKELY(!CHRLib::IsValidSurrogateHead(seq[1])))
521 return ConversionResult::Invalid;
522 YB_ATTR_fallthrough;
523 }
524 else
525 {
526 Assign(uc, char32_t(seq[0]) | char32_t(seq[1]) << 8U);
527 break;
528 }
529 case 2:
530 if(YB_UNLIKELY(!FillByte(i, st)))
531 return ConversionResult::BadSource;
532 YB_ATTR_fallthrough;
533 case 3:
534 if(YB_UNLIKELY(!FillByte(i, st)))
535 return ConversionResult::BadSource;
536 if(YB_UNLIKELY(!CHRLib::IsValidSurrogateTail(seq[3])))
537 return ConversionResult::Invalid;
538 Assign(uc, char32_t(seq[0] << 10U) | char32_t(seq[1] & 0x03U) << 18U
539 | char32_t(seq[2]) | char32_t(seq[3] & 0x03U) << 8U);
540 break;
541 default:
542 return ConversionResult::BadState;
543 }
544 return ConversionResult::OK;
545 }
546 };
547
549 template<>
550 struct GUCSMapper<CharSet::UTF_32BE> : UCSMapperBase
551 {
552 using UCSMapperBase::Assign;
553
558 template<typename _tObj, typename _tIn, typename _tState>
559 static ConversionResult
560 Decode(_tObj&& uc, _tIn&& i, _tState&& st)
561 ynoexcept(noexcept(GetSequenceOf(st))
562 && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st)))
563 {
564 const auto seq(GetSequenceOf(st));
565
566 switch(GetIndexOf(st))
567 {
568 case 0:
569 if(YB_UNLIKELY(!FillByte(i, st)))
570 return ConversionResult::BadSource;
571 YB_ATTR_fallthrough;
572 case 1:
573 if(YB_UNLIKELY(!FillByte(i, st)))
574 return ConversionResult::BadSource;
575 YB_ATTR_fallthrough;
576 case 2:
577 if(YB_UNLIKELY(!FillByte(i, st)))
578 return ConversionResult::BadSource;
579 YB_ATTR_fallthrough;
580 case 3:
581 if(YB_UNLIKELY(!FillByte(i, st)))
582 return ConversionResult::BadSource;
583 Assign(uc, char32_t(seq[0]) << 24U | char32_t(seq[1]) << 16U
584 | char32_t(seq[2]) << 8U | char32_t(seq[3]));
585 break;
586 default:
587 return ConversionResult::BadState;
588 }
589 return ConversionResult::OK;
590 }
591 };
592
594 template<>
595 struct GUCSMapper<CharSet::UTF_32LE> : UCSMapperBase
596 {
597 using UCSMapperBase::Assign;
598
603 template<typename _tObj, typename _tIn, typename _tState>
604 static ConversionResult
605 Decode(_tObj&& uc, _tIn&& i, _tState&& st)
606 ynoexcept(noexcept(GetSequenceOf(st))
607 && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st)))
608 {
609 const auto seq(GetSequenceOf(st));
610
611 switch(GetIndexOf(st))
612 {
613 case 0:
614 if(YB_UNLIKELY(!FillByte(i, st)))
615 return ConversionResult::BadSource;
616 YB_ATTR_fallthrough;
617 case 1:
618 if(YB_UNLIKELY(!FillByte(i, st)))
619 return ConversionResult::BadSource;
620 YB_ATTR_fallthrough;
621 case 2:
622 if(YB_UNLIKELY(!FillByte(i, st)))
623 return ConversionResult::BadSource;
624 YB_ATTR_fallthrough;
625 case 3:
626 if(YB_UNLIKELY(!FillByte(i, st)))
627 return ConversionResult::BadSource;
628 Assign(uc, char32_t(seq[2]) | char32_t(seq[3]) << 8U
629 | char32_t(seq[0]) << 16U | char32_t(seq[1]) << 24U);
630 break;
631 default:
632 return ConversionResult::BadState;
633 }
634 return ConversionResult::OK;
635 }
636 };
638
639
640 } // namespace CHRLib;
641
642 #endif
643
CHRLib_Impl_UTF8_Decode_Fill
#define CHRLib_Impl_UTF8_Decode_Fill
Definition: StaticMapping.hpp:332
CHRLib::CharSet::UTF_16LE
yconstexpr const Encoding UTF_16LE(csUTF16LE)
CHRLib::GUCSMapper< CharSet::UTF_32LE >::Decode
static ConversionResult Decode(_tObj &&uc, _tIn &&i, _tState &&st) ynoexcept(noexcept(GetSequenceOf(st))&&noexcept(GetIndexOf(st))&&noexcept(!FillByte(i, st)))
解码： UTF-32LE 。
Definition: StaticMapping.hpp:605
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
CHRLib::IsValidSurrogateTail
yconstfn octet x ynothrow IsValidSurrogateTail
Definition: StaticMapping.hpp:120
CHRLib::PDefH
PDefH(char16_t, FetchBiCharBE, const char *c_ptr) ImplRet(yconstraint(c_ptr)
取 c_ptr 指向的大端序双字节字符。
CHRLib::GUCSMapper< CharSet::UTF_8 >::Assign1
static void Assign1(_tObj &uc, const _tSeq &seq) ynothrow
Definition: StaticMapping.hpp:199
cast.hpp
C++ 转换模板。
CHRLib::GUCSMapper< CharSet::UTF_16BE >::Decode
static ConversionResult Decode(_tObj &&uc, _tIn &&i, _tState &&st) ynoexcept(noexcept(GetSequenceOf(st))&&noexcept(GetIndexOf(st))&&noexcept(!FillByte(i, st)))
解码： UTF-16BE 。
Definition: StaticMapping.hpp:446
CHRLib::GetSequenceOf
yconstfn ConversionState &st GetSequenceOf
Definition: CharacterMapping.h:138
CHRLib::GUCSMapper< CharSet::UTF_8 >::IsInvalid
static yconstfn bool IsInvalid(octet x) ynothrow
检查 UTF-8 文本序列中非法字节。
Definition: StaticMapping.hpp:230
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::x
const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow TermNode &term const TermNode &term ValueNode &node const ValueNode &node const _type & x
Definition: SContext.h:94
CHRLib::IsValidSurrogateHead
yconstfn IsValidSurrogateHead
Definition: StaticMapping.hpp:116
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
CHRLib::GUCSMapper
静态编码操作模板及 Unicode 编码特化。
Definition: StaticMapping.hpp:182
CHRLib::GUCSMapper< CharSet::UTF_8 >::Decode
static ConversionResult Decode(_tObj &&uc, _tIn &&i, _tState &&st) ynoexcept(noexcept(GetSequenceOf(st))&&noexcept(GetIndexOf(st))&&noexcept(!FillByte(i, st)))
解码： UTF-8 。
Definition: StaticMapping.hpp:241
ynoexcept_assert
#define ynoexcept_assert(_msg,...)
表达式 noexcept 静态断言。
Definition: ydef.h:747
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:794
YB_UNLIKELY
#define YB_UNLIKELY(_expr)
分支预测提示。
Definition: ydef.h:464
CHRLib_Impl_UTF8_Decode_Tail
#define CHRLib_Impl_UTF8_Decode_Tail
Definition: StaticMapping.hpp:336
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:45
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1022
CHRLib::FillByte
bool FillByte(_tIn &i, byte &b) ynoexcept(noexcept(byte(*i))&&noexcept(++i))
以输入迭代器指向内容填充有效输入迭代器指定的字节。
Definition: StaticMapping.hpp:64
CHRLib::CharSet::UTF_16BE
yconstexpr const Encoding UTF_16BE(csUTF16BE)
CHRLib::CharSet::UTF_32LE
yconstexpr const Encoding UTF_32LE(csUTF32LE)
CHRLib::CharSet::UTF_32BE
yconstexpr const Encoding UTF_32BE(csUTF32BE)
ystdex::not_widen_cast
_tDst not_widen_cast(_tSrc v)
可能缩小数值范围或数值范围最大和最小值保持不变的转换。
Definition: cast.hpp:179
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:766
CHRLib::ImplRet
const char *c_ptr ImplRet(yconstraint(c_ptr), char16_t((c_ptr[1]<< CHAR_BIT)|*c_ptr)) enum class ConversionResult
编码转换结果。
Definition: CharacterMapping.h:84
YSLib::i
return i
Definition: YCoreUtilities.h:176
CHRLib::CharSet::UTF_8
yconstexpr const Encoding UTF_8(csUTF8)
platform_ex::Windows::Invalid
Definition: MinGW32.h:471
YModules.h
CHRLib::GUCSMapper< CharSet::UTF_16LE >::Decode
static ConversionResult Decode(_tObj &&uc, _tIn &&i, _tState &&st) ynoexcept(noexcept(GetSequenceOf(st))&&noexcept(GetIndexOf(st))&&noexcept(!FillByte(i, st)))
解码： UTF-16LE 。
Definition: StaticMapping.hpp:503
CHRLib::ConversionState
编码转换状态。
Definition: CharacterMapping.h:106
CHRLib::GUCSMapper< CharSet::UTF_8 >::state_t
std::uint_fast8_t state_t
Definition: StaticMapping.hpp:323
CHRLib::GUCSMapper< CharSet::UTF_8 >::Encode
static size_t Encode(_tOut d, char32_t c) ynothrow
Definition: StaticMapping.hpp:408
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:786
CHRLib::GuardPair
std::pair< ystdex::lref< _tIn >, const _tIn > GuardPair
Definition: CharacterMapping.h:185
ystdex::pseudo_output
伪输出对象。
Definition: ref.hpp:307
CHRLib
Definition: CharacterDefinition.h:38
ystdex::byte
unsigned char byte
字节类型。
Definition: ydef.h:834
CHRLib::c
c
Definition: CharacterProcessing.h:81
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:995
CHRLib::GUCSMapper< CharSet::UTF_32BE >::Decode
static ConversionResult Decode(_tObj &&uc, _tIn &&i, _tState &&st) ynoexcept(noexcept(GetSequenceOf(st))&&noexcept(GetIndexOf(st))&&noexcept(!FillByte(i, st)))
解码： UTF-32BE 。
Definition: StaticMapping.hpp:560
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:139
CHRLib::GUCSMapper< CharSet::UTF_8 >::CheckInvalid
static yconstfn bool CheckInvalid(octet x, octet y=0x80) ynothrow
Definition: StaticMapping.hpp:219
YSLib::Drawing::char32_t
tr TextRegion &tr char32_t
Definition: TextLayout.h:92
CHRLib::CheckIterator
bool CheckIterator(_tIn &i) ynothrow
检查解码迭代器。
Definition: StaticMapping.hpp:48
YB_LIKELY
#define YB_LIKELY(_expr)
Definition: ydef.h:463
YB_ATTR_fallthrough
#define YB_ATTR_fallthrough
用于 switch 语句的 fallthrough 属性。
Definition: ydef.h:383
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:88
CHRLib_Impl_UTF8_Decode_FillTransTail
#define CHRLib_Impl_UTF8_Decode_FillTransTail(_mask)
Definition: StaticMapping.hpp:339
ystdex::octet
void octet
Definition: ydef.h:844
CHRLib::GUCSMapper< CharSet::UTF_8 >::Assign2
static void Assign2(_tObj &uc, const _tSeq &seq) ynothrow
Definition: StaticMapping.hpp:209
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:746