YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
chrmap.h
浏览该文件的文档.
1 /*
2  Copyright (C) by Franksoft 2009 - 2012.
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 CHRLIB_INC_CHRMAP_H_
29 #define CHRLIB_INC_CHRMAP_H_ 1
30 
31 #include "encoding.h"
32 
34 
35 using CharSet::Encoding;
36 
37 
43 
44 
49 inline ucs2_t
50 FetchBiCharBE(const char* c_ptr)
51 {
52  yconstraint(c_ptr);
53 
54  return (*c_ptr << CHAR_BIT) | c_ptr[1];
55 }
56 
61 inline ucs2_t
62 FetchBiCharLE(const char* c_ptr)
63 {
64  yconstraint(c_ptr);
65 
66  return (c_ptr[1] << CHAR_BIT) | *c_ptr;
67 }
68 
69 
74 enum class ConversionResult
75 {
76  OK = 0,
77  BadState,
78  BadSource,
79  Invalid,
80  Unhandled
81 };
82 
83 
89 {
93  std::uint_fast8_t Count;
94  union
95  {
97  byte Sequence[4];
98  } Value;
99 
100  yconstfn
101  ConversionState(size_t n= 0)
102  : Count(n), Value()
103  {}
104 };
105 
106 yconstfn std::uint_fast8_t&
108 {
109  return st.Count;
110 }
113 {
114  return st.Value.Wide;
115 }
116 yconstfn byte*
118 {
119  return st.Value.Sequence;
120 }
121 
122 
127 template<typename _type>
128 yconstfn _type&
129 GetCountOf(_type& st)
130 {
131  return st;
132 }
133 
134 
141 YF_API size_t
143 
150 YF_API size_t
152 
159 YF_API size_t
161 
163 
164 #endif
165