Compare commits

...

2 Commits

Author SHA1 Message Date
Baptiste Lepilleur
678d65e7ad Release 0.6.0-rc2 2011-05-02 21:46:58 +00:00
Baptiste Lepilleur
88292c9516 Release 0.6.0-rc2 2011-05-02 21:31:33 +00:00
15 changed files with 121 additions and 112 deletions

View File

@ -13,8 +13,8 @@
Notes: you need to setup the environment by running vcvars32.bat Notes: you need to setup the environment by running vcvars32.bat
(e.g. MSVC 2008 command prompt in start menu) before running scons. (e.g. MSVC 2008 command prompt in start menu) before running scons.
- Added support for amalgated source and header generation (a la sqlite). - Added support for amalgamated source and header generation (a la sqlite).
Refer to README.txt section "Generating amalgated source and header" Refer to README.txt section "Generating amalgamated source and header"
for detail. for detail.
* Value * Value
@ -90,6 +90,9 @@
- Fixed Value::operator <= implementation (had the semantic of operator >=). - Fixed Value::operator <= implementation (had the semantic of operator >=).
Found when addigin unit tests for comparison operators. Found when addigin unit tests for comparison operators.
- Value::compare() is now const and has an actual implementation with
unit tests.
* License * License
- See file LICENSE for details. Basically JsonCpp is now licensed under - See file LICENSE for details. Basically JsonCpp is now licensed under

View File

@ -90,30 +90,30 @@ Notes that the documentation is also available for download as a tarball.
The documentation of the latest release is available online at: The documentation of the latest release is available online at:
http://jsoncpp.sourceforge.net/ http://jsoncpp.sourceforge.net/
* Generating amalgated source and header * Generating amalgamated source and header
====================================== ========================================
JsonCpp is provided with a script to generate a single header and a single JsonCpp is provided with a script to generate a single header and a single
source file to ease inclusion in an existing project. source file to ease inclusion in an existing project.
The amalgated source can be generated at any time by running the following The amalgamated source can be generated at any time by running the following
command from the top-directory (requires python 2.6): command from the top-directory (requires python 2.6):
python amalgate.py python amalgamate.py
It is possible to specify header name. See -h options for detail. By default, It is possible to specify header name. See -h options for detail. By default,
the following files are generated: the following files are generated:
- dist/jsoncpp.cpp: source file that need to be added to your project - dist/jsoncpp.cpp: source file that need to be added to your project
- dist/json/json.h: header file corresponding to use in your project. It is - dist/json/json.h: header file corresponding to use in your project. It is
equivalent to including json/json.h in non-amalgated source. This header equivalent to including json/json.h in non-amalgamated source. This header
only depends on standard headers. only depends on standard headers.
- dist/json/json-forwards.h: header the provides forward declaration - dist/json/json-forwards.h: header the provides forward declaration
of all JsonCpp types. This typically what should be included in headers to of all JsonCpp types. This typically what should be included in headers to
speed-up compilation. speed-up compilation.
The amalgated sources are generated by concatenating JsonCpp source in the The amalgamated sources are generated by concatenating JsonCpp source in the
correct order and defining macro JSON_IS_AMALGATED to prevent inclusion of correct order and defining macro JSON_IS_AMALGAMATION to prevent inclusion
other headers. of other headers.
* Using json-cpp in your project: * Using json-cpp in your project:
=============================== ===============================

View File

@ -9,7 +9,7 @@ import os
import os.path import os.path
import sys import sys
class AmalagatedFile: class AmalgamationFile:
def __init__( self, top_dir ): def __init__( self, top_dir ):
self.top_dir = top_dir self.top_dir = top_dir
self.blocks = [] self.blocks = []
@ -47,9 +47,9 @@ class AmalagatedFile:
f.write( self.get_value() ) f.write( self.get_value() )
f.close() f.close()
def amalgate_source( source_top_dir=None, def amalgamate_source( source_top_dir=None,
target_source_path=None, target_source_path=None,
header_include_path=None ): header_include_path=None ):
"""Produces amalgated source. """Produces amalgated source.
Parameters: Parameters:
source_top_dir: top-directory source_top_dir: top-directory
@ -57,7 +57,7 @@ def amalgate_source( source_top_dir=None,
header_include_path: generated header path relative to target_source_path. header_include_path: generated header path relative to target_source_path.
""" """
print 'Amalgating header...' print 'Amalgating header...'
header = AmalagatedFile( source_top_dir ) header = AmalgamationFile( source_top_dir )
header.add_text( '/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).' ) header.add_text( '/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).' )
header.add_text( '/// It is intented to be used with #include <%s>' % header_include_path ) header.add_text( '/// It is intented to be used with #include <%s>' % header_include_path )
header.add_file( 'LICENSE', wrap_in_comment=True ) header.add_file( 'LICENSE', wrap_in_comment=True )
@ -81,7 +81,7 @@ def amalgate_source( source_top_dir=None,
base, ext = os.path.splitext( header_include_path ) base, ext = os.path.splitext( header_include_path )
forward_header_include_path = base + '-forwards' + ext forward_header_include_path = base + '-forwards' + ext
print 'Amalgating forward header...' print 'Amalgating forward header...'
header = AmalagatedFile( source_top_dir ) header = AmalgamationFile( source_top_dir )
header.add_text( '/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).' ) header.add_text( '/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).' )
header.add_text( '/// It is intented to be used with #include <%s>' % forward_header_include_path ) header.add_text( '/// It is intented to be used with #include <%s>' % forward_header_include_path )
header.add_text( '/// This header provides forward declaration for all JsonCpp types.' ) header.add_text( '/// This header provides forward declaration for all JsonCpp types.' )
@ -101,7 +101,7 @@ def amalgate_source( source_top_dir=None,
header.write_to( target_forward_header_path ) header.write_to( target_forward_header_path )
print 'Amalgating source...' print 'Amalgating source...'
source = AmalagatedFile( source_top_dir ) source = AmalgamationFile( source_top_dir )
source.add_text( '/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).' ) source.add_text( '/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).' )
source.add_text( '/// It is intented to be used with #include <%s>' % header_include_path ) source.add_text( '/// It is intented to be used with #include <%s>' % header_include_path )
source.add_file( 'LICENSE', wrap_in_comment=True ) source.add_file( 'LICENSE', wrap_in_comment=True )
@ -134,9 +134,9 @@ Generate a single amalgated source and header file from the sources.
parser.enable_interspersed_args() parser.enable_interspersed_args()
options, args = parser.parse_args() options, args = parser.parse_args()
msg = amalgate_source( source_top_dir=options.top_dir, msg = amalgamate_source( source_top_dir=options.top_dir,
target_source_path=options.target_source_path, target_source_path=options.target_source_path,
header_include_path=options.header_include_path ) header_include_path=options.header_include_path )
if msg: if msg:
sys.stderr.write( msg + '\n' ) sys.stderr.write( msg + '\n' )
sys.exit( 1 ) sys.exit( 1 )

View File

@ -31,7 +31,7 @@
/// If defined, indicates that the source file is amalgated /// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion. /// to prevent private header inclusion.
/// Remarks: it is automatically defined in the generated amalgated header. /// Remarks: it is automatically defined in the generated amalgated header.
// #define JSON_IS_AMALGATED // #define JSON_IS_AMALGAMATION
# ifdef JSON_IN_CPPTL # ifdef JSON_IN_CPPTL

View File

@ -6,9 +6,9 @@
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED #ifndef CPPTL_JSON_FEATURES_H_INCLUDED
# define CPPTL_JSON_FEATURES_H_INCLUDED # define CPPTL_JSON_FEATURES_H_INCLUDED
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include "forwards.h" # include "forwards.h"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json { namespace Json {

View File

@ -6,9 +6,9 @@
#ifndef JSON_FORWARDS_H_INCLUDED #ifndef JSON_FORWARDS_H_INCLUDED
# define JSON_FORWARDS_H_INCLUDED # define JSON_FORWARDS_H_INCLUDED
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include "config.h" # include "config.h"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json { namespace Json {

View File

@ -6,10 +6,10 @@
#ifndef CPPTL_JSON_READER_H_INCLUDED #ifndef CPPTL_JSON_READER_H_INCLUDED
# define CPPTL_JSON_READER_H_INCLUDED # define CPPTL_JSON_READER_H_INCLUDED
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include "features.h" # include "features.h"
# include "value.h" # include "value.h"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
# include <deque> # include <deque>
# include <stack> # include <stack>
# include <string> # include <string>
@ -197,11 +197,11 @@ namespace Json {
Result: Result:
\verbatim \verbatim
{ {
"dir": { "dir": {
"file": { "file": {
// The input stream JSON would be nested here. // The input stream JSON would be nested here.
} }
} }
} }
\endverbatim \endverbatim
\throw std::exception on parse error. \throw std::exception on parse error.

View File

@ -6,9 +6,9 @@
#ifndef CPPTL_JSON_H_INCLUDED #ifndef CPPTL_JSON_H_INCLUDED
# define CPPTL_JSON_H_INCLUDED # define CPPTL_JSON_H_INCLUDED
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include "forwards.h" # include "forwards.h"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
# include <string> # include <string>
# include <vector> # include <vector>
@ -132,30 +132,30 @@ namespace Json {
typedef Json::UInt64 UInt64; typedef Json::UInt64 UInt64;
typedef Json::Int64 Int64; typedef Json::Int64 Int64;
#endif // defined(JSON_HAS_INT64) #endif // defined(JSON_HAS_INT64)
typedef Json::LargestInt LargestInt; typedef Json::LargestInt LargestInt;
typedef Json::LargestUInt LargestUInt; typedef Json::LargestUInt LargestUInt;
typedef Json::ArrayIndex ArrayIndex; typedef Json::ArrayIndex ArrayIndex;
static const Value null; static const Value null;
/// Minimum signed integer value that can be stored in a Json::Value. /// Minimum signed integer value that can be stored in a Json::Value.
static const LargestInt minLargestInt; static const LargestInt minLargestInt;
/// Maximum signed integer value that can be stored in a Json::Value. /// Maximum signed integer value that can be stored in a Json::Value.
static const LargestInt maxLargestInt; static const LargestInt maxLargestInt;
/// Maximum unsigned integer value that can be stored in a Json::Value. /// Maximum unsigned integer value that can be stored in a Json::Value.
static const LargestUInt maxLargestUInt; static const LargestUInt maxLargestUInt;
/// Minimum signed int value that can be stored in a Json::Value. /// Minimum signed int value that can be stored in a Json::Value.
static const Int minInt; static const Int minInt;
/// Maximum signed int value that can be stored in a Json::Value. /// Maximum signed int value that can be stored in a Json::Value.
static const Int maxInt; static const Int maxInt;
/// Maximum unsigned int value that can be stored in a Json::Value. /// Maximum unsigned int value that can be stored in a Json::Value.
static const UInt maxUInt; static const UInt maxUInt;
/// Minimum signed 64 bits int value that can be stored in a Json::Value. /// Minimum signed 64 bits int value that can be stored in a Json::Value.
static const Int64 minInt64; static const Int64 minInt64;
/// Maximum signed 64 bits int value that can be stored in a Json::Value. /// Maximum signed 64 bits int value that can be stored in a Json::Value.
static const Int64 maxInt64; static const Int64 maxInt64;
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value. /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
static const UInt64 maxUInt64; static const UInt64 maxUInt64;
private: private:
@ -202,14 +202,14 @@ namespace Json {
To create an empty array, pass arrayValue. To create an empty array, pass arrayValue.
To create an empty object, pass objectValue. To create an empty object, pass objectValue.
Another Value can then be set to this one by assignment. Another Value can then be set to this one by assignment.
This is useful since clear() and resize() will not alter types. This is useful since clear() and resize() will not alter types.
Examples: Examples:
\code \code
Json::Value null_value; // null Json::Value null_value; // null
Json::Value arr_value(Json::arrayValue); // [] Json::Value arr_value(Json::arrayValue); // []
Json::Value obj_value(Json::objectValue); // {} Json::Value obj_value(Json::objectValue); // {}
\endcode \endcode
*/ */
Value( ValueType type = nullValue ); Value( ValueType type = nullValue );
Value( Int value ); Value( Int value );
@ -256,7 +256,7 @@ namespace Json {
bool operator ==( const Value &other ) const; bool operator ==( const Value &other ) const;
bool operator !=( const Value &other ) const; bool operator !=( const Value &other ) const;
int compare( const Value &other ); int compare( const Value &other ) const;
const char *asCString() const; const char *asCString() const;
std::string asString() const; std::string asString() const;
@ -315,24 +315,24 @@ namespace Json {
/// this from the operator[] which takes a string.) /// this from the operator[] which takes a string.)
Value &operator[]( ArrayIndex index ); Value &operator[]( ArrayIndex index );
/// Access an array element (zero based index ). /// Access an array element (zero based index ).
/// If the array contains less than index element, then null value are inserted /// If the array contains less than index element, then null value are inserted
/// in the array so that its size is index+1. /// in the array so that its size is index+1.
/// (You may need to say 'value[0u]' to get your compiler to distinguish /// (You may need to say 'value[0u]' to get your compiler to distinguish
/// this from the operator[] which takes a string.) /// this from the operator[] which takes a string.)
Value &operator[]( int index ); Value &operator[]( int index );
/// Access an array element (zero based index ) /// Access an array element (zero based index )
/// (You may need to say 'value[0u]' to get your compiler to distinguish /// (You may need to say 'value[0u]' to get your compiler to distinguish
/// this from the operator[] which takes a string.) /// this from the operator[] which takes a string.)
const Value &operator[]( ArrayIndex index ) const; const Value &operator[]( ArrayIndex index ) const;
/// Access an array element (zero based index ) /// Access an array element (zero based index )
/// (You may need to say 'value[0u]' to get your compiler to distinguish /// (You may need to say 'value[0u]' to get your compiler to distinguish
/// this from the operator[] which takes a string.) /// this from the operator[] which takes a string.)
const Value &operator[]( int index ) const; const Value &operator[]( int index ) const;
/// If the array contains at least index+1 elements, returns the element value, /// If the array contains at least index+1 elements, returns the element value,
/// otherwise returns defaultValue. /// otherwise returns defaultValue.
Value get( ArrayIndex index, Value get( ArrayIndex index,
const Value &defaultValue ) const; const Value &defaultValue ) const;

View File

@ -6,9 +6,9 @@
#ifndef JSON_WRITER_H_INCLUDED #ifndef JSON_WRITER_H_INCLUDED
# define JSON_WRITER_H_INCLUDED # define JSON_WRITER_H_INCLUDED
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include "value.h" # include "value.h"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
# include <vector> # include <vector>
# include <string> # include <string>
# include <iostream> # include <iostream>

View File

@ -23,7 +23,7 @@ import tempfile
import os import os
import time import time
from devtools import antglob, fixeol, tarball from devtools import antglob, fixeol, tarball
import amalgate import amalgamate
SVN_ROOT = 'https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/' SVN_ROOT = 'https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/'
SVN_TAG_ROOT = SVN_ROOT + 'tags/jsoncpp' SVN_TAG_ROOT = SVN_ROOT + 'tags/jsoncpp'
@ -323,13 +323,13 @@ Warning: --force should only be used when developping/testing the release script
print 'Generating source tarball to', source_tarball_path print 'Generating source tarball to', source_tarball_path
tarball.make_tarball( source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir ) tarball.make_tarball( source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir )
amalgated_tarball_path = 'dist/%s-amalgated.tar.gz' % source_dir amalgamation_tarball_path = 'dist/%s-amalgamation.tar.gz' % source_dir
print 'Generating amalgated source tarball to', amalgated_tarball_path print 'Generating amalgamation source tarball to', amalgamation_tarball_path
amalgated_dir = 'dist/amalgated' amalgamation_dir = 'dist/amalgamation'
amalgate.amalgate_source( export_dir, '%s/jsoncpp.cpp' % amalgated_dir, 'json/json.h' ) amalgamate.amalgamate_source( export_dir, '%s/jsoncpp.cpp' % amalgamation_dir, 'json/json.h' )
amalgated_source_dir = 'jsoncpp-src-amalgated' + release_version amalgamation_source_dir = 'jsoncpp-src-amalgamation' + release_version
tarball.make_tarball( amalgated_tarball_path, [amalgated_dir], tarball.make_tarball( amalgamation_tarball_path, [amalgamation_dir],
amalgated_dir, prefix_dir=amalgated_source_dir ) amalgamation_dir, prefix_dir=amalgamation_source_dir )
# Decompress source tarball, download and install scons-local # Decompress source tarball, download and install scons-local
distcheck_dir = 'dist/distcheck' distcheck_dir = 'dist/distcheck'

View File

@ -3,11 +3,11 @@
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include <json/reader.h> # include <json/reader.h>
# include <json/value.h> # include <json/value.h>
# include "json_tool.h" # include "json_tool.h"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
#include <utility> #include <utility>
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
@ -488,7 +488,7 @@ Reader::readObject( Token &/*tokenStart*/ )
if ( !readToken( comma ) if ( !readToken( comma )
|| ( comma.type_ != tokenObjectEnd && || ( comma.type_ != tokenObjectEnd &&
comma.type_ != tokenArraySeparator && comma.type_ != tokenArraySeparator &&
comma.type_ != tokenComment ) ) comma.type_ != tokenComment ) )
{ {
return addErrorAndRecover( "Missing ',' or '}' in object declaration", return addErrorAndRecover( "Missing ',' or '}' in object declaration",
comma, comma,

View File

@ -3,13 +3,13 @@
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include <json/value.h> # include <json/value.h>
# include <json/writer.h> # include <json/writer.h>
# ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR # ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
# include "json_batchallocator.h" # include "json_batchallocator.h"
# endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR # endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
#include <iostream> #include <iostream>
#include <utility> #include <utility>
#include <stdexcept> #include <stdexcept>
@ -83,14 +83,14 @@ releaseStringValue( char *value )
// ////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# ifdef JSON_VALUE_USE_INTERNAL_MAP # ifdef JSON_VALUE_USE_INTERNAL_MAP
# include "json_internalarray.inl" # include "json_internalarray.inl"
# include "json_internalmap.inl" # include "json_internalmap.inl"
# endif // JSON_VALUE_USE_INTERNAL_MAP # endif // JSON_VALUE_USE_INTERNAL_MAP
# include "json_valueiterator.inl" # include "json_valueiterator.inl"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json { namespace Json {
@ -524,35 +524,16 @@ Value::type() const
int int
Value::compare( const Value &other ) Value::compare( const Value &other ) const
{ {
/* if ( *this < other )
int typeDelta = other.type_ - type_; return -1;
switch ( type_ ) if ( *this > other )
{ return 1;
case nullValue: return 0;
return other.type_ == type_;
case intValue:
if ( other.type_.isNumeric()
case uintValue:
case realValue:
case booleanValue:
break;
case stringValue,
break;
case arrayValue:
delete value_.array_;
break;
case objectValue:
delete value_.map_;
default:
JSON_ASSERT_UNREACHABLE;
}
*/
return 0; // unreachable
} }
bool bool
Value::operator <( const Value &other ) const Value::operator <( const Value &other ) const
{ {
@ -594,7 +575,7 @@ Value::operator <( const Value &other ) const
default: default:
JSON_ASSERT_UNREACHABLE; JSON_ASSERT_UNREACHABLE;
} }
return 0; // unreachable return false; // unreachable
} }
bool bool
@ -656,7 +637,7 @@ Value::operator ==( const Value &other ) const
default: default:
JSON_ASSERT_UNREACHABLE; JSON_ASSERT_UNREACHABLE;
} }
return 0; // unreachable return false; // unreachable
} }
bool bool
@ -827,9 +808,9 @@ LargestInt
Value::asLargestInt() const Value::asLargestInt() const
{ {
#if defined(JSON_NO_INT64) #if defined(JSON_NO_INT64)
return asInt(); return asInt();
#else #else
return asInt64(); return asInt64();
#endif #endif
} }
@ -838,9 +819,9 @@ LargestUInt
Value::asLargestUInt() const Value::asLargestUInt() const
{ {
#if defined(JSON_NO_INT64) #if defined(JSON_NO_INT64)
return asUInt(); return asUInt();
#else #else
return asUInt64(); return asUInt64();
#endif #endif
} }

View File

@ -3,10 +3,10 @@
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#if !defined(JSON_IS_AMALGATED) #if !defined(JSON_IS_AMALGAMATION)
# include <json/writer.h> # include <json/writer.h>
# include "json_tool.h" # include "json_tool.h"
#endif // if !defined(JSON_IS_AMALGATED) #endif // if !defined(JSON_IS_AMALGAMATION)
#include <utility> #include <utility>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
@ -656,7 +656,7 @@ StyledStreamWriter::writeArrayValue( const Value &value )
writeWithIndent( childValues_[index] ); writeWithIndent( childValues_[index] );
else else
{ {
writeIndent(); writeIndent();
writeValue( childValue ); writeValue( childValue );
} }
if ( ++index == size ) if ( ++index == size )

View File

@ -256,6 +256,12 @@ ValueTest::checkIs( const Json::Value &value, const IsCheck &check )
} }
JSONTEST_FIXTURE( ValueTest, compareNull )
{
JSONTEST_ASSERT_PRED( checkIsEqual( Json::Value(), Json::Value() ) );
}
JSONTEST_FIXTURE( ValueTest, compareInt ) JSONTEST_FIXTURE( ValueTest, compareInt )
{ {
JSONTEST_ASSERT_PRED( checkIsLess( 0, 10 ) ); JSONTEST_ASSERT_PRED( checkIsLess( 0, 10 ) );
@ -347,6 +353,19 @@ JSONTEST_FIXTURE( ValueTest, compareObject )
} }
JSONTEST_FIXTURE( ValueTest, compareType )
{
// object of different type are ordered according to their type
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(), Json::Value(1) ) );
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(1), Json::Value(1u) ) );
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(1u), Json::Value(1.0) ) );
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(1.0), Json::Value("a") ) );
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value("a"), Json::Value(true) ) );
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(true), Json::Value(Json::arrayValue) ) );
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(Json::arrayValue), Json::Value(Json::objectValue) ) );
}
void void
ValueTest::checkIsLess( const Json::Value &x, const Json::Value &y ) ValueTest::checkIsLess( const Json::Value &x, const Json::Value &y )
{ {
@ -360,6 +379,8 @@ ValueTest::checkIsLess( const Json::Value &x, const Json::Value &y )
JSONTEST_ASSERT( !(y <= x) ); JSONTEST_ASSERT( !(y <= x) );
JSONTEST_ASSERT( !(x > y) ); JSONTEST_ASSERT( !(x > y) );
JSONTEST_ASSERT( !(y < x) ); JSONTEST_ASSERT( !(y < x) );
JSONTEST_ASSERT( x.compare( y ) < 0 );
JSONTEST_ASSERT( y.compare( x ) >= 0 );
} }
@ -376,6 +397,8 @@ ValueTest::checkIsEqual( const Json::Value &x, const Json::Value &y )
JSONTEST_ASSERT( !(y < x) ); JSONTEST_ASSERT( !(y < x) );
JSONTEST_ASSERT( !(x > y) ); JSONTEST_ASSERT( !(x > y) );
JSONTEST_ASSERT( !(y > x) ); JSONTEST_ASSERT( !(y > x) );
JSONTEST_ASSERT( x.compare( y ) == 0 );
JSONTEST_ASSERT( y.compare( x ) == 0 );
} }
@ -394,6 +417,7 @@ int main( int argc, const char *argv[] )
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isNull ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isNull );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, accessArray ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, accessArray );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, asFloat ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, asFloat );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareNull );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareInt ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareInt );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareUInt ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareUInt );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareDouble ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareDouble );
@ -401,5 +425,6 @@ int main( int argc, const char *argv[] )
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareBoolean ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareBoolean );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareArray ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareArray );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareObject ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareObject );
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareType );
return runner.runCommandLine( argc, argv ); return runner.runCommandLine( argc, argv );
} }

View File

@ -1 +1 @@
0.6.0-dev 0.6.0-rc2