6 #ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED 7 #define LIB_JSONCPP_JSON_TOOL_H_INCLUDED 9 #if !defined(JSON_IS_AMALGAMATION) 10 #include <json/config.h> 14 #ifdef NO_LOCALE_SUPPORT 15 #define JSONCPP_NO_LOCALE_SUPPORT 18 #ifndef JSONCPP_NO_LOCALE_SUPPORT 29 static inline char getDecimalPoint() {
30 #ifdef JSONCPP_NO_LOCALE_SUPPORT 33 struct lconv* lc = localeconv();
34 return lc ? *(lc->decimal_point) :
'\0';
46 result[0] =
static_cast<char>(cp);
47 }
else if (cp <= 0x7FF) {
49 result[1] =
static_cast<char>(0x80 | (0x3f & cp));
50 result[0] =
static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
51 }
else if (cp <= 0xFFFF) {
53 result[2] =
static_cast<char>(0x80 | (0x3f & cp));
54 result[1] =
static_cast<char>(0x80 | (0x3f & (cp >> 6)));
55 result[0] =
static_cast<char>(0xE0 | (0xf & (cp >> 12)));
56 }
else if (cp <= 0x10FFFF) {
58 result[3] =
static_cast<char>(0x80 | (0x3f & cp));
59 result[2] =
static_cast<char>(0x80 | (0x3f & (cp >> 6)));
60 result[1] =
static_cast<char>(0x80 | (0x3f & (cp >> 12)));
61 result[0] =
static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
81 static inline void uintToString(LargestUInt value,
char*& current) {
84 *--current =
static_cast<char>(value % 10U +
static_cast<unsigned>(
'0'));
95 for (; begin != end; ++begin) {
103 template <
typename Iter>
void fixNumericLocaleInput(Iter begin, Iter end) {
104 char decimalPoint = getDecimalPoint();
105 if (decimalPoint ==
'\0' || decimalPoint ==
'.') {
108 for (; begin != end; ++begin) {
110 *begin = decimalPoint;
119 template <
typename Iter>
121 for (; begin != end; --end) {
122 if (*(end - 1) !=
'0') {
126 if (begin != (end - 1) && begin != (end - 2) && *(end - 2) ==
'.') {
138 #endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED Iter fixZerosInTheEnd(Iter begin, Iter end, unsigned int precision)
Return iterator that would be the new end of the range [begin,end), if we were to delete zeros in the...
Definition: json_tool.h:120
static String codePointToUTF8(unsigned int cp)
Converts a unicode code-point to UTF-8.
Definition: json_tool.h:39
static void uintToString(LargestUInt value, char *¤t)
Converts an unsigned integer to string.
Definition: json_tool.h:81
JSON (JavaScript Object Notation).
Definition: allocator.h:15
Constant that specify the size of the buffer that must be passed to uintToString. ...
Definition: json_tool.h:70
Iter fixNumericLocale(Iter begin, Iter end)
Change ',' to '.
Definition: json_tool.h:94