6#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
7#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
9#if !defined(JSON_IS_AMALGAMATION)
10#include "nim_wrapper_util/json/config.h"
14#ifdef NO_LOCALE_SUPPORT
15#define JSONCPP_NO_LOCALE_SUPPORT
18#ifndef JSONCPP_NO_LOCALE_SUPPORT
30static inline char getDecimalPoint() {
31#ifdef JSONCPP_NO_LOCALE_SUPPORT
34 struct lconv* lc = localeconv();
35 return lc ? *(lc->decimal_point) :
'\0';
40static inline String codePointToUTF8(
unsigned int cp) {
47 result[0] =
static_cast<char>(cp);
48 }
else if (cp <= 0x7FF) {
50 result[1] =
static_cast<char>(0x80 | (0x3f & cp));
51 result[0] =
static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
52 }
else if (cp <= 0xFFFF) {
54 result[2] =
static_cast<char>(0x80 | (0x3f & cp));
55 result[1] =
static_cast<char>(0x80 | (0x3f & (cp >> 6)));
56 result[0] =
static_cast<char>(0xE0 | (0xf & (cp >> 12)));
57 }
else if (cp <= 0x10FFFF) {
59 result[3] =
static_cast<char>(0x80 | (0x3f & cp));
60 result[2] =
static_cast<char>(0x80 | (0x3f & (cp >> 6)));
61 result[1] =
static_cast<char>(0x80 | (0x3f & (cp >> 12)));
62 result[0] =
static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
71 uintToStringBufferSize = 3 *
sizeof(LargestUInt) + 1
75using UIntToStringBuffer =
char[uintToStringBufferSize];
82static inline void uintToString(LargestUInt value,
char*& current) {
85 *--current =
static_cast<char>(value % 10U +
static_cast<unsigned>(
'0'));
95template <
typename Iter>
96Iter fixNumericLocale(Iter begin, Iter end) {
97 for (; begin != end; ++begin) {
105template <
typename Iter>
106void fixNumericLocaleInput(Iter begin, Iter end) {
107 char decimalPoint = getDecimalPoint();
108 if (decimalPoint ==
'\0' || decimalPoint ==
'.') {
111 for (; begin != end; ++begin) {
113 *begin = decimalPoint;
122template <
typename Iter>
123Iter fixZerosInTheEnd(Iter begin, Iter end) {
124 for (; begin != end; --end) {
125 if (*(end - 1) !=
'0') {
129 if (begin != (end - 1) && *(end - 2) ==
'.') {
JSON (JavaScript Object Notation).
Definition: allocator.h:14