From: Baptiste L. <bl...@us...> - 2005-10-31 17:30:28
|
Update of /cvsroot/jsoncpp/jsoncpp/include/json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7828/include/json Modified Files: json_config.h json_value.h json_writer.h Log Message: * added optional support for CppTL library enumerator and ConstString. Index: json_value.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_value.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** json_value.h 29 Sep 2005 21:11:49 -0000 1.5 --- json_value.h 31 Oct 2005 17:30:09 -0000 1.6 *************** *** 7,10 **** --- 7,14 ---- # include <vector> + # ifdef JSON_USE_CPPTL + # include <cpptl/forwards.h> + # endif + namespace Json { *************** *** 33,36 **** --- 37,44 ---- }; + # ifdef JSON_USE_CPPTL + typedef CppTL::AnyEnumerator<const char *> EnumMemberNames; + typedef CppTL::AnyEnumerator<const Value &> EnumValues; + # endif /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value. *************** *** 79,82 **** --- 87,93 ---- Value( const char *value ); Value( const std::string &value ); + # ifdef JSON_USE_CPPTL + Value( const CppTL::ConstString &value ); + # endif Value( bool value ); Value( const Value &other ); *************** *** 100,103 **** --- 111,117 ---- const char *asCString() const; std::string asString() const; + # ifdef JSON_USE_CPPTL + CppTL::ConstString asConstString() const; + # endif Int asInt() const; UInt asUInt() const; *************** *** 115,118 **** --- 129,134 ---- bool isObject() const; + bool isConvertibleTo( ValueType other ) const; + /// Number of values in array or object UInt size() const; *************** *** 138,141 **** --- 154,160 ---- /// Returns true if index < size(). bool isValidIndex( UInt index ) const; + /// Append value to array at the end. + /// Equivalent to jsonvalue[jsonvalue.size()] = value; + Value &append( const Value &value ); // Access an object value by name, create a null member if it does not exist. *************** *** 147,150 **** --- 166,175 ---- // Access an object value by name, returns null if there is no member with that name. const Value &operator[]( const std::string &key ) const; + # ifdef JSON_USE_CPPTL + // Access an object value by name, create a null member if it does not exist. + Value &operator[]( const CppTL::ConstString &key ); + // Access an object value by name, returns null if there is no member with that name. + const Value &operator[]( const CppTL::ConstString &key ) const; + # endif /// Returns the member named key if it exist, defaultValue otherwise. Value get( const char *key, *************** *** 153,164 **** --- 178,203 ---- Value get( const std::string &key, const Value &defaultValue ) const; + # ifdef JSON_USE_CPPTL + /// Returns the member named key if it exist, defaultValue otherwise. + Value get( const CppTL::ConstString &key, + const Value &defaultValue ) const; + # endif /// Returns true if the object has a member named key. bool isMember( const char *key ) const; /// Returns true if the object has a member named key. bool isMember( const std::string &key ) const; + # ifdef JSON_USE_CPPTL + /// Returns true if the object has a member named key. + bool isMember( const CppTL::ConstString &key ) const; + # endif // Returns a list of the member names. Members getMemberNames() const; + # ifdef JSON_USE_CPPTL + EnumMemberNames enumMemberNames() const; + EnumValues enumValues() const; + # endif + void setComment( const char *comment, CommentPlacement placement ); *************** *** 168,171 **** --- 207,212 ---- std::string getComment( CommentPlacement placement ) const; + std::string toStyledString() const; + private: struct CommentInfo *************** *** 204,207 **** --- 245,257 ---- typedef std::map<CZString, Value> ObjectValues; + struct MemberNamesTransform + { + typedef const char *result_type; + const char *operator()( const CZString &name ) const + { + return name.c_str(); + } + }; + union ValueHolder { Index: json_config.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_config.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** json_config.h 29 Sep 2005 21:11:49 -0000 1.2 --- json_config.h 31 Oct 2005 17:30:09 -0000 1.3 *************** *** 5,10 **** --- 5,17 ---- //# define JSON_IN_CPPTL 1 + /// If defined, indicates that json may leverage CppTL library + # define JSON_USE_CPPTL 1 + + # ifdef JSON_IN_CPPTL # include <cpptl/config.h> + # ifndef JSON_USE_CPPTL + # define JSON_USE_CPPTL 1 + # endif # endif *************** *** 19,26 **** # endif - # ifdef JSON_IN_CPPTL - /// If defined, indicates that json may leverage CppTL library - # define JSON_USE_CPPTL 1 - # endif - #endif // JSON_CONFIG_H_INCLUDED --- 26,28 ---- Index: json_writer.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_writer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** json_writer.h 30 Jul 2005 17:40:58 -0000 1.4 --- json_writer.h 31 Oct 2005 17:30:09 -0000 1.5 *************** *** 3,7 **** # include "json_value.h" ! # include "json_reader.h" # include <deque> # include <string> --- 3,7 ---- # include "json_value.h" ! //# include "json_reader.h" # include <deque> # include <string> *************** *** 81,85 **** }; - std::string JSON_API valueToString( Value::Int value ); std::string JSON_API valueToString( Value::UInt value ); --- 81,84 ---- *************** *** 88,92 **** std::string JSON_API valueToQuotedString( const char *value ); - } // namespace Json --- 87,90 ---- |