Major rework of 64 integer support: 64 bits integer are only returned when explicitly request via Json::Value::asInt64(), unlike previous implementation where Json::Value::asInt() returned a 64 bits integer.
This eases porting portable code and does not break compatibility with the previous release.
Json::Value::asLargestInt() has also be added to ease writing portable code independent of 64 bits integer support. It is typically used to implement writers.
diff --git a/include/json/value.h b/include/json/value.h
index 8d0d4c1..14464e4 100644
--- a/include/json/value.h
+++ b/include/json/value.h
@@ -126,13 +126,36 @@
typedef ValueConstIterator const_iterator;
typedef Json::UInt UInt;
typedef Json::Int Int;
+# if defined(JSON_HAS_INT64)
+ typedef Json::UInt64 UInt64;
+ typedef Json::Int64 Int64;
+#endif // defined(JSON_HAS_INT64)
+ typedef Json::LargestInt LargestInt;
+ typedef Json::LargestUInt LargestUInt;
typedef Json::ArrayIndex ArrayIndex;
static const Value null;
- static const Int minInt;
+ /// Minimum signed integer value that can be stored in a Json::Value.
+ static const LargestInt minLargestInt;
+ /// Maximum signed integer value that can be stored in a Json::Value.
+ static const LargestInt maxLargestInt;
+ /// Maximum unsigned integer value that can be stored in a Json::Value.
+ static const LargestUInt maxLargestUInt;
+
+ /// Minimum signed int value that can be stored in a Json::Value.
+ static const Int minInt;
+ /// Maximum signed int value that can be stored in a Json::Value.
static const Int maxInt;
+ /// Maximum unsigned int value that can be stored in a Json::Value.
static const UInt maxUInt;
+ /// Minimum signed 64 bits int value that can be stored in a Json::Value.
+ static const Int64 minInt64;
+ /// Maximum signed 64 bits int value that can be stored in a Json::Value.
+ static const Int64 maxInt64;
+ /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
+ static const UInt64 maxUInt64;
+
private:
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
# ifndef JSON_VALUE_USE_INTERNAL_MAP
@@ -187,12 +210,12 @@
\endcode
*/
Value( ValueType type = nullValue );
-#if !defined(JSON_NO_INT64)
- Value( int value );
- Value( ArrayIndex value );
-#endif // if !defined(JSON_NO_INT64)
Value( Int value );
Value( UInt value );
+#if defined(JSON_HAS_INT64)
+ Value( Int64 value );
+ Value( UInt64 value );
+#endif // if defined(JSON_HAS_INT64)
Value( double value );
Value( const char *value );
Value( const char *beginValue, const char *endValue );
@@ -240,6 +263,10 @@
# endif
Int asInt() const;
UInt asUInt() const;
+ Int64 asInt64() const;
+ UInt64 asUInt64() const;
+ LargestInt asLargestInt() const;
+ LargestUInt asLargestUInt() const;
float asFloat() const;
double asDouble() const;
bool asBool() const;
@@ -448,8 +475,8 @@
union ValueHolder
{
- Int int_;
- UInt uint_;
+ LargestInt int_;
+ LargestUInt uint_;
double real_;
bool bool_;
char *string_;