15 #ifndef RAPIDJSON_ITOA_
16 #define RAPIDJSON_ITOA_
18 #include "../rapidjson.h"
25 static const char cDigitsLut[200] = {
26 '0',
'0',
'0',
'1',
'0',
'2',
'0',
'3',
'0',
'4',
'0',
'5',
'0',
'6',
'0',
'7',
'0',
27 '8',
'0',
'9',
'1',
'0',
'1',
'1',
'1',
'2',
'1',
'3',
'1',
'4',
'1',
'5',
'1',
'6',
28 '1',
'7',
'1',
'8',
'1',
'9',
'2',
'0',
'2',
'1',
'2',
'2',
'2',
'3',
'2',
'4',
'2',
29 '5',
'2',
'6',
'2',
'7',
'2',
'8',
'2',
'9',
'3',
'0',
'3',
'1',
'3',
'2',
'3',
'3',
30 '3',
'4',
'3',
'5',
'3',
'6',
'3',
'7',
'3',
'8',
'3',
'9',
'4',
'0',
'4',
'1',
'4',
31 '2',
'4',
'3',
'4',
'4',
'4',
'5',
'4',
'6',
'4',
'7',
'4',
'8',
'4',
'9',
'5',
'0',
32 '5',
'1',
'5',
'2',
'5',
'3',
'5',
'4',
'5',
'5',
'5',
'6',
'5',
'7',
'5',
'8',
'5',
33 '9',
'6',
'0',
'6',
'1',
'6',
'2',
'6',
'3',
'6',
'4',
'6',
'5',
'6',
'6',
'6',
'7',
34 '6',
'8',
'6',
'9',
'7',
'0',
'7',
'1',
'7',
'2',
'7',
'3',
'7',
'4',
'7',
'5',
'7',
35 '6',
'7',
'7',
'7',
'8',
'7',
'9',
'8',
'0',
'8',
'1',
'8',
'2',
'8',
'3',
'8',
'4',
36 '8',
'5',
'8',
'6',
'8',
'7',
'8',
'8',
'8',
'9',
'9',
'0',
'9',
'1',
'9',
'2',
'9',
37 '3',
'9',
'4',
'9',
'5',
'9',
'6',
'9',
'7',
'9',
'8',
'9',
'9'};
53 *buffer++ = cDigitsLut[d1];
55 *buffer++ = cDigitsLut[d1 + 1];
57 *buffer++ = cDigitsLut[d2];
58 *buffer++ = cDigitsLut[d2 + 1];
60 else if(
value < 100000000)
73 *buffer++ = cDigitsLut[d1];
75 *buffer++ = cDigitsLut[d1 + 1];
77 *buffer++ = cDigitsLut[d2];
78 *buffer++ = cDigitsLut[d2 + 1];
80 *buffer++ = cDigitsLut[d3];
81 *buffer++ = cDigitsLut[d3 + 1];
82 *buffer++ = cDigitsLut[d4];
83 *buffer++ = cDigitsLut[d4 + 1];
94 const unsigned i =
a << 1;
95 *buffer++ = cDigitsLut[i];
96 *buffer++ = cDigitsLut[i + 1];
99 *buffer++ =
static_cast<char>(
'0' +
static_cast<char>(
a));
110 *buffer++ = cDigitsLut[d1];
111 *buffer++ = cDigitsLut[d1 + 1];
112 *buffer++ = cDigitsLut[d2];
113 *buffer++ = cDigitsLut[d2 + 1];
114 *buffer++ = cDigitsLut[d3];
115 *buffer++ = cDigitsLut[d3 + 1];
116 *buffer++ = cDigitsLut[d4];
117 *buffer++ = cDigitsLut[d4 + 1];
141 const uint64_t kTen10 = kTen8 * 100;
142 const uint64_t kTen11 = kTen8 * 1000;
143 const uint64_t kTen12 = kTen8 * 10000;
144 const uint64_t kTen13 = kTen8 * 100000;
145 const uint64_t kTen14 = kTen8 * 1000000;
146 const uint64_t kTen15 = kTen8 * 10000000;
147 const uint64_t kTen16 = kTen8 * kTen8;
158 *buffer++ = cDigitsLut[d1];
160 *buffer++ = cDigitsLut[d1 + 1];
162 *buffer++ = cDigitsLut[d2];
163 *buffer++ = cDigitsLut[d2 + 1];
177 if(
value >= 10000000)
178 *buffer++ = cDigitsLut[d1];
180 *buffer++ = cDigitsLut[d1 + 1];
182 *buffer++ = cDigitsLut[d2];
183 *buffer++ = cDigitsLut[d2 + 1];
185 *buffer++ = cDigitsLut[d3];
186 *buffer++ = cDigitsLut[d3 + 1];
187 *buffer++ = cDigitsLut[d4];
188 *buffer++ = cDigitsLut[d4 + 1];
191 else if(
value < kTen16)
199 const uint32_t d1 = (b0 / 100) << 1;
200 const uint32_t d2 = (b0 % 100) << 1;
202 const uint32_t d3 = (c0 / 100) << 1;
203 const uint32_t d4 = (c0 % 100) << 1;
208 const uint32_t d5 = (b1 / 100) << 1;
209 const uint32_t d6 = (b1 % 100) << 1;
211 const uint32_t d7 = (c1 / 100) << 1;
212 const uint32_t d8 = (c1 % 100) << 1;
215 *buffer++ = cDigitsLut[d1];
217 *buffer++ = cDigitsLut[d1 + 1];
219 *buffer++ = cDigitsLut[d2];
221 *buffer++ = cDigitsLut[d2 + 1];
223 *buffer++ = cDigitsLut[d3];
225 *buffer++ = cDigitsLut[d3 + 1];
227 *buffer++ = cDigitsLut[d4];
229 *buffer++ = cDigitsLut[d4 + 1];
230 *buffer++ = cDigitsLut[d5];
231 *buffer++ = cDigitsLut[d5 + 1];
232 *buffer++ = cDigitsLut[d6];
233 *buffer++ = cDigitsLut[d6 + 1];
234 *buffer++ = cDigitsLut[d7];
235 *buffer++ = cDigitsLut[d7 + 1];
236 *buffer++ = cDigitsLut[d8];
237 *buffer++ = cDigitsLut[d8 + 1];
245 *buffer++ =
static_cast<char>(
'0' +
static_cast<char>(
a));
249 *buffer++ = cDigitsLut[i];
250 *buffer++ = cDigitsLut[i + 1];
254 *buffer++ =
static_cast<char>(
'0' +
static_cast<char>(
a / 100));
257 *buffer++ = cDigitsLut[i];
258 *buffer++ = cDigitsLut[i + 1];
264 *buffer++ = cDigitsLut[i];
265 *buffer++ = cDigitsLut[i + 1];
266 *buffer++ = cDigitsLut[j];
267 *buffer++ = cDigitsLut[j + 1];
276 const uint32_t d1 = (b0 / 100) << 1;
277 const uint32_t d2 = (b0 % 100) << 1;
279 const uint32_t d3 = (c0 / 100) << 1;
280 const uint32_t d4 = (c0 % 100) << 1;
285 const uint32_t d5 = (b1 / 100) << 1;
286 const uint32_t d6 = (b1 % 100) << 1;
288 const uint32_t d7 = (c1 / 100) << 1;
289 const uint32_t d8 = (c1 % 100) << 1;
291 *buffer++ = cDigitsLut[d1];
292 *buffer++ = cDigitsLut[d1 + 1];
293 *buffer++ = cDigitsLut[d2];
294 *buffer++ = cDigitsLut[d2 + 1];
295 *buffer++ = cDigitsLut[d3];
296 *buffer++ = cDigitsLut[d3 + 1];
297 *buffer++ = cDigitsLut[d4];
298 *buffer++ = cDigitsLut[d4 + 1];
299 *buffer++ = cDigitsLut[d5];
300 *buffer++ = cDigitsLut[d5 + 1];
301 *buffer++ = cDigitsLut[d6];
302 *buffer++ = cDigitsLut[d6 + 1];
303 *buffer++ = cDigitsLut[d7];
304 *buffer++ = cDigitsLut[d7 + 1];
305 *buffer++ = cDigitsLut[d8];
306 *buffer++ = cDigitsLut[d8 + 1];
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:451
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
Definition: allocators.h:459
char * i64toa(int64_t value, char *buffer)
Definition: itoa.h:312
char * i32toa(int32_t value, char *buffer)
Definition: itoa.h:122
char * u32toa(uint32_t value, char *buffer)
Definition: itoa.h:41
const char * GetDigitsLut()
Definition: itoa.h:23
char * u64toa(uint64_t value, char *buffer)
Definition: itoa.h:135
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1697
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1517
signed __int64 int64_t
Definition: stdint.h:135
unsigned int uint32_t
Definition: stdint.h:126
signed int int32_t
Definition: stdint.h:123
unsigned __int64 uint64_t
Definition: stdint.h:136