mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-14 23:07:55 +02:00
- added Int/UInt typedef in Json namespace. Modified Value::Int and Value::UInt to be typedef on those. Modified code to use Json::Int instead of Value::Int.
- added Value constructor taking begin/end pointer to initialize the Value with a non-zero terminated string.
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
namespace Json {
|
||||
|
||||
const Value Value::null;
|
||||
const Value::Int Value::minInt = Value::Int( ~(Value::UInt(-1)/2) );
|
||||
const Value::Int Value::maxInt = Value::Int( Value::UInt(-1)/2 );
|
||||
const Value::UInt Value::maxUInt = Value::UInt(-1);
|
||||
const Int Value::minInt = Int( ~(UInt(-1)/2) );
|
||||
const Int Value::maxInt = Int( UInt(-1)/2 );
|
||||
const UInt Value::maxUInt = UInt(-1);
|
||||
|
||||
// A "safe" implementation of strdup. Allow null pointer to be passed.
|
||||
// Also avoid warning on msvc80.
|
||||
@@ -351,6 +351,21 @@ Value::Value( const char *value )
|
||||
value_.string_ = valueAllocator()->duplicateStringValue( value );
|
||||
}
|
||||
|
||||
|
||||
Value::Value( const char *beginValue,
|
||||
const char *endValue )
|
||||
: type_( stringValue )
|
||||
, allocated_( true )
|
||||
, comments_( 0 )
|
||||
# ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||
, itemIsUsed_( 0 )
|
||||
#endif
|
||||
{
|
||||
value_.string_ = valueAllocator()->duplicateStringValue( beginValue,
|
||||
UInt(endValue - beginValue) );
|
||||
}
|
||||
|
||||
|
||||
Value::Value( const std::string &value )
|
||||
: type_( stringValue )
|
||||
, allocated_( true )
|
||||
|
@@ -176,7 +176,7 @@ ValueIteratorBase::key() const
|
||||
}
|
||||
|
||||
|
||||
Value::UInt
|
||||
UInt
|
||||
ValueIteratorBase::index() const
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
|
@@ -39,14 +39,14 @@ static void uintToString( unsigned int value,
|
||||
while ( value != 0 );
|
||||
}
|
||||
|
||||
std::string valueToString( Value::Int value )
|
||||
std::string valueToString( Int value )
|
||||
{
|
||||
char buffer[32];
|
||||
char *current = buffer + sizeof(buffer);
|
||||
bool isNegative = value < 0;
|
||||
if ( isNegative )
|
||||
value = -value;
|
||||
uintToString( Value::UInt(value), current );
|
||||
uintToString( UInt(value), current );
|
||||
if ( isNegative )
|
||||
*--current = '-';
|
||||
assert( current >= buffer );
|
||||
@@ -54,7 +54,7 @@ std::string valueToString( Value::Int value )
|
||||
}
|
||||
|
||||
|
||||
std::string valueToString( Value::UInt value )
|
||||
std::string valueToString( UInt value )
|
||||
{
|
||||
char buffer[32];
|
||||
char *current = buffer + sizeof(buffer);
|
||||
|
Reference in New Issue
Block a user