From 2ca3d84092f9f004efc47c38a67ab34ceb008306 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 27 Dec 2019 01:24:57 +0300 Subject: libjson: patch to write 64-bit integers --- libs/libjson/src/JSONNode.h | 3 +++ libs/libjson/src/NumberToString.h | 6 +++--- libs/libjson/src/stdafx.cxx | 4 +--- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'libs/libjson/src') diff --git a/libs/libjson/src/JSONNode.h b/libs/libjson/src/JSONNode.h index 21889ca903..dc69e965ab 100644 --- a/libs/libjson/src/JSONNode.h +++ b/libs/libjson/src/JSONNode.h @@ -48,6 +48,7 @@ foo(short); foo(unsigned short);\ foo(int); foo(unsigned int);\ foo(long); foo(unsigned long);\ + foo(long long); foo(unsigned long long);\ foo(float); foo(double);\ foo(bool);\ foo(const json_string &);\ @@ -57,6 +58,7 @@ foo(short) const; foo(unsigned short) const;\ foo(int) const; foo(unsigned int) const;\ foo(long) const; foo(unsigned long) const;\ + foo(long long) const; foo(unsigned long long) const;\ foo(float) const; foo(double) const;\ foo(bool) const;\ foo(const json_string &) const;\ @@ -67,6 +69,7 @@ foo(short) foo(unsigned short)\ foo(int) foo(unsigned int)\ foo(long) foo(unsigned long)\ + foo(long long) foo(unsigned long long)\ foo(float) foo(double) #endif #define IMPLEMENT_FOR_ALL_TYPES(foo)\ diff --git a/libs/libjson/src/NumberToString.h b/libs/libjson/src/NumberToString.h index a706372f92..4ecd8779c2 100644 --- a/libs/libjson/src/NumberToString.h +++ b/libs/libjson/src/NumberToString.h @@ -24,11 +24,11 @@ class NumberToString { public: template static json_string _itoa(T val, unsigned int size){ - long value = (long)val; + int64_t value = (int64_t)val; const unsigned int digits = getlen(size); json_auto result(digits); result.ptr[digits - 1] = JSON_TEXT('\0'); //null terminator - json_char * runner = &result.ptr[digits - 2]; + json_char *runner = &result.ptr[digits - 2]; bool negative; //first thing, check if it's negative, if so, make it positive @@ -58,7 +58,7 @@ public: #ifndef JSON_LIBRARY template static json_string _uitoa(T val, unsigned int size){ - unsigned long value = val; + uint64_t value = (uint64_t)val; const unsigned int digits = getlen(size) - 1; //minus one because no '-' char json_auto result(digits); result.ptr[digits - 1] = JSON_TEXT('\0'); //null terminator diff --git a/libs/libjson/src/stdafx.cxx b/libs/libjson/src/stdafx.cxx index 324814bd86..d3822a7acb 100644 --- a/libs/libjson/src/stdafx.cxx +++ b/libs/libjson/src/stdafx.cxx @@ -28,9 +28,7 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT_PARAM ¶m) LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT64_PARAM ¶m) { - char tmp[100]; - _i64toa_s(param.iValue, tmp, _countof(tmp), 10); - json.push_back(JSONNode(param.szName, tmp)); + json.push_back(JSONNode(param.szName, param.iValue)); return json; } -- cgit v1.2.3