15 #ifndef RAPIDJSON_ITOA_
16 #define RAPIDJSON_ITOA_
18 #include "../rapidjson.h"
24 static const char cDigitsLut[200] = {
25 '0',
'0',
'0',
'1',
'0',
'2',
'0',
'3',
'0',
'4',
'0',
'5',
'0',
'6',
'0',
'7',
'0',
'8',
'0',
'9',
26 '1',
'0',
'1',
'1',
'1',
'2',
'1',
'3',
'1',
'4',
'1',
'5',
'1',
'6',
'1',
'7',
'1',
'8',
'1',
'9',
27 '2',
'0',
'2',
'1',
'2',
'2',
'2',
'3',
'2',
'4',
'2',
'5',
'2',
'6',
'2',
'7',
'2',
'8',
'2',
'9',
28 '3',
'0',
'3',
'1',
'3',
'2',
'3',
'3',
'3',
'4',
'3',
'5',
'3',
'6',
'3',
'7',
'3',
'8',
'3',
'9',
29 '4',
'0',
'4',
'1',
'4',
'2',
'4',
'3',
'4',
'4',
'4',
'5',
'4',
'6',
'4',
'7',
'4',
'8',
'4',
'9',
30 '5',
'0',
'5',
'1',
'5',
'2',
'5',
'3',
'5',
'4',
'5',
'5',
'5',
'6',
'5',
'7',
'5',
'8',
'5',
'9',
31 '6',
'0',
'6',
'1',
'6',
'2',
'6',
'3',
'6',
'4',
'6',
'5',
'6',
'6',
'6',
'7',
'6',
'8',
'6',
'9',
32 '7',
'0',
'7',
'1',
'7',
'2',
'7',
'3',
'7',
'4',
'7',
'5',
'7',
'6',
'7',
'7',
'7',
'8',
'7',
'9',
33 '8',
'0',
'8',
'1',
'8',
'2',
'8',
'3',
'8',
'4',
'8',
'5',
'8',
'6',
'8',
'7',
'8',
'8',
'8',
'9',
34 '9',
'0',
'9',
'1',
'9',
'2',
'9',
'3',
'9',
'4',
'9',
'5',
'9',
'6',
'9',
'7',
'9',
'8',
'9',
'9'
43 const uint32_t d1 = (value / 100) << 1;
44 const uint32_t d2 = (value % 100) << 1;
47 *buffer++ = cDigitsLut[d1];
49 *buffer++ = cDigitsLut[d1 + 1];
51 *buffer++ = cDigitsLut[d2];
52 *buffer++ = cDigitsLut[d2 + 1];
54 else if (value < 100000000) {
65 if (value >= 10000000)
66 *buffer++ = cDigitsLut[d1];
68 *buffer++ = cDigitsLut[d1 + 1];
70 *buffer++ = cDigitsLut[d2];
71 *buffer++ = cDigitsLut[d2 + 1];
73 *buffer++ = cDigitsLut[d3];
74 *buffer++ = cDigitsLut[d3 + 1];
75 *buffer++ = cDigitsLut[d4];
76 *buffer++ = cDigitsLut[d4 + 1];
81 const uint32_t a = value / 100000000;
85 const unsigned i = a << 1;
86 *buffer++ = cDigitsLut[i];
87 *buffer++ = cDigitsLut[i + 1];
90 *buffer++ =
static_cast<char>(
'0' +
static_cast<char>(a));
101 *buffer++ = cDigitsLut[d1];
102 *buffer++ = cDigitsLut[d1 + 1];
103 *buffer++ = cDigitsLut[d2];
104 *buffer++ = cDigitsLut[d2 + 1];
105 *buffer++ = cDigitsLut[d3];
106 *buffer++ = cDigitsLut[d3 + 1];
107 *buffer++ = cDigitsLut[d4];
108 *buffer++ = cDigitsLut[d4 + 1];
127 const uint64_t kTen10 = kTen8 * 100;
128 const uint64_t kTen11 = kTen8 * 1000;
129 const uint64_t kTen12 = kTen8 * 10000;
130 const uint64_t kTen13 = kTen8 * 100000;
131 const uint64_t kTen14 = kTen8 * 1000000;
132 const uint64_t kTen15 = kTen8 * 10000000;
133 const uint64_t kTen16 = kTen8 * kTen8;
142 *buffer++ = cDigitsLut[d1];
144 *buffer++ = cDigitsLut[d1 + 1];
146 *buffer++ = cDigitsLut[d2];
147 *buffer++ = cDigitsLut[d2 + 1];
160 if (value >= 10000000)
161 *buffer++ = cDigitsLut[d1];
162 if (value >= 1000000)
163 *buffer++ = cDigitsLut[d1 + 1];
165 *buffer++ = cDigitsLut[d2];
166 *buffer++ = cDigitsLut[d2 + 1];
168 *buffer++ = cDigitsLut[d3];
169 *buffer++ = cDigitsLut[d3 + 1];
170 *buffer++ = cDigitsLut[d4];
171 *buffer++ = cDigitsLut[d4 + 1];
174 else if (value < kTen16) {
181 const uint32_t d1 = (b0 / 100) << 1;
182 const uint32_t d2 = (b0 % 100) << 1;
184 const uint32_t d3 = (c0 / 100) << 1;
185 const uint32_t d4 = (c0 % 100) << 1;
190 const uint32_t d5 = (b1 / 100) << 1;
191 const uint32_t d6 = (b1 % 100) << 1;
193 const uint32_t d7 = (c1 / 100) << 1;
194 const uint32_t d8 = (c1 % 100) << 1;
197 *buffer++ = cDigitsLut[d1];
199 *buffer++ = cDigitsLut[d1 + 1];
201 *buffer++ = cDigitsLut[d2];
203 *buffer++ = cDigitsLut[d2 + 1];
205 *buffer++ = cDigitsLut[d3];
207 *buffer++ = cDigitsLut[d3 + 1];
209 *buffer++ = cDigitsLut[d4];
211 *buffer++ = cDigitsLut[d4 + 1];
213 *buffer++ = cDigitsLut[d5];
214 *buffer++ = cDigitsLut[d5 + 1];
215 *buffer++ = cDigitsLut[d6];
216 *buffer++ = cDigitsLut[d6 + 1];
217 *buffer++ = cDigitsLut[d7];
218 *buffer++ = cDigitsLut[d7 + 1];
219 *buffer++ = cDigitsLut[d8];
220 *buffer++ = cDigitsLut[d8 + 1];
227 *buffer++ =
static_cast<char>(
'0' +
static_cast<char>(a));
230 *buffer++ = cDigitsLut[i];
231 *buffer++ = cDigitsLut[i + 1];
234 *buffer++ =
static_cast<char>(
'0' +
static_cast<char>(a / 100));
237 *buffer++ = cDigitsLut[i];
238 *buffer++ = cDigitsLut[i + 1];
243 *buffer++ = cDigitsLut[i];
244 *buffer++ = cDigitsLut[i + 1];
245 *buffer++ = cDigitsLut[j];
246 *buffer++ = cDigitsLut[j + 1];
255 const uint32_t d1 = (b0 / 100) << 1;
256 const uint32_t d2 = (b0 % 100) << 1;
258 const uint32_t d3 = (c0 / 100) << 1;
259 const uint32_t d4 = (c0 % 100) << 1;
264 const uint32_t d5 = (b1 / 100) << 1;
265 const uint32_t d6 = (b1 % 100) << 1;
267 const uint32_t d7 = (c1 / 100) << 1;
268 const uint32_t d8 = (c1 % 100) << 1;
270 *buffer++ = cDigitsLut[d1];
271 *buffer++ = cDigitsLut[d1 + 1];
272 *buffer++ = cDigitsLut[d2];
273 *buffer++ = cDigitsLut[d2 + 1];
274 *buffer++ = cDigitsLut[d3];
275 *buffer++ = cDigitsLut[d3 + 1];
276 *buffer++ = cDigitsLut[d4];
277 *buffer++ = cDigitsLut[d4 + 1];
278 *buffer++ = cDigitsLut[d5];
279 *buffer++ = cDigitsLut[d5 + 1];
280 *buffer++ = cDigitsLut[d6];
281 *buffer++ = cDigitsLut[d6 + 1];
282 *buffer++ = cDigitsLut[d7];
283 *buffer++ = cDigitsLut[d7 + 1];
284 *buffer++ = cDigitsLut[d8];
285 *buffer++ = cDigitsLut[d8 + 1];
304 #endif // RAPIDJSON_ITOA_
char * u64toa(uint64_t value, char *buffer)
Definition: itoa.h:123
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
const char * GetDigitsLut()
Definition: itoa.h:23
signed __int64 int64_t
Definition: stdint.h:89
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
unsigned int uint32_t
Definition: stdint.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90
char * u32toa(uint32_t value, char *buffer)
Definition: itoa.h:39
Definition: document.h:390
signed int int32_t
Definition: stdint.h:77
const FieldDescriptor value
Definition: descriptor.h:1522
char * i64toa(int64_t value, char *buffer)
Definition: itoa.h:291
char * i32toa(int32_t value, char *buffer)
Definition: itoa.h:113