You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(30) |
Aug
|
Sep
(3) |
Oct
(3) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
2010 |
Jan
(1) |
Feb
(41) |
Mar
(15) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(79) |
Jun
(11) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(1) |
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
(3) |
May
(13) |
Jun
|
Jul
|
Aug
(6) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Baptiste L. <bl...@us...> - 2005-07-30 11:15:21
|
Update of /cvsroot/jsoncpp/jsoncpp/include/json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3607/include/json Modified Files: json_reader.h json_forwards.h json_value.h json_writer.h Log Message: * added doxygen documentation Index: json_value.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_value.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** json_value.h 27 Jul 2005 07:38:15 -0000 1.2 --- json_value.h 30 Jul 2005 11:15:11 -0000 1.3 *************** *** 2,5 **** --- 2,6 ---- # define CPPTL_JSON_H_INCLUDED + # include "json_forwards.h" # include "json_config.h" # include <string> *************** *** 11,26 **** class Value; enum ValueType { ! nullValue = 0, ! intValue, ! uintValue, ! realValue, ! stringValue, ! booleanValue, ! arrayValue, ! objectValue }; class JSON_API Value { --- 12,56 ---- class Value; + /** \brief Type of the value held by a Value object. + */ enum ValueType { ! nullValue = 0, ///< 'null' value ! intValue, ///< signed integer value ! uintValue, ///< unsigned integer value ! realValue, ///< double value ! stringValue, ///< UTF-8 string value ! booleanValue, ///< bool value ! arrayValue, ///< array value (ordered list) ! objectValue ///< object value (collection of name/value pairs). }; + /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value. + * + * This class is a discriminated union wrapper that can represents a: + * - signed integer [range: Value::minInt - Value::maxInt] + * - unsigned integer (range: 0 - Value::maxUInt) + * - double + * - UTF-8 string + * - boolean + * - 'null' + * - an ordered list of Value + * - collection of name/value pairs (javascript object) + * + * The type of the held value is represented by a #ValueType and + * can be obtained using type(). + * + * values of an #objectValue or #arrayValue can be accessed using operator[]() methods. + * Non const methods will automatically create the a #nullValue element + * if it does not exist. + * The sequence of an #arrayValue will be automatically resize and initialized + * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue. + * + * The get() methods can be used to obtanis default value in the case the required element + * does not exist. + * + * It is possible to iterate over the list of a #objectValue values using + * the getMemberNames() method. + */ class JSON_API Value { *************** *** 123,126 **** --- 153,159 ---- Members getMemberNames() const; + void setId( ValueId id ); + ValueId id() const; + private: struct CZString *************** *** 149,153 **** typedef std::map<CZString, Value> ObjectValues; - ValueType type_; union ValueHolder { --- 182,185 ---- *************** *** 159,165 **** ObjectValues *map_; } value_; ! Value *parent_; ! Value *previous_; ! Value *next_; }; --- 191,196 ---- ObjectValues *map_; } value_; ! ValueType type_; ! ValueId id_; }; Index: json_reader.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_reader.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json_reader.h 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json_reader.h 30 Jul 2005 11:15:11 -0000 1.2 *************** *** 2,7 **** --- 2,9 ---- # define CPPTL_JSON_READER_H_INCLUDED + # include "json_forwards.h" # include "json_config.h" # include <deque> + # include <map> # include <stack> # include <string> *************** *** 9,14 **** --- 11,21 ---- namespace Json { + class CommentMemo; class Value; + /** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value. + * + * + */ class JSON_API Reader { *************** *** 19,25 **** --- 26,55 ---- Reader(); + /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document. + * \param document UTF-8 encoded string containing the document to read. + * \param root [out] Contains the root value of the document if it was + * successfully parsed. + * \return \c true if the document was successfully parsed, \c false if an error occurred. + */ bool parse( const std::string &document, Value &root ); + /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document and preserve comments. + * \param document [in] UTF-8 encoded string containing the document to read. + * \param root [out] Contains the root value of the document if it was + * successfully parsed. + * \param commentMemo [out] Contains the comment associated with the value if it was successfully + * parsed. + * \return \c true if the document was successfully parsed, \c false if an error occurred. + */ + bool parse( const std::string &document, + Value &root, + CommentMemo &commentMemo ); + + /** \brief Returns a user friendly string that list errors in the parsed document. + * \return Formatted error message with the list of errors with their location in + * the parsed document. An empty string is returned if no error occurred + * during parsing. + */ std::string getFormatedErrorMessages() const; *************** *** 104,107 **** --- 134,191 ---- Location end_; Location current_; + CommentMemo *commentMemo_; + }; + + class JSON_API CommentMemo + { + public: + enum Placement + { + atDocumentStart = 1, + beforeValue, + afterValueOnSameLine, + atDocumentEnd + }; + + class CommentInfo + { + public: + std::string comment_; + Placement placement_; + ValueId id_; + }; + + CommentMemo(); + + void beginDocumentParsing(); + void parsedCComment( Reader::Location begin, + Reader::Location end ); + void parsedCppComment( Reader::Location begin, + Reader::Location end ); + void parsedValue( Reader::Location begin, + Reader::Location end, + Value &value ); + void endDocumentParsing(); + + unsigned int getCommentCount() const; + const CommentInfo &getComment( unsigned int index ) const; + const CommentInfo *findComment( ValueId id, Placement placement ) const; + private: + static bool containsNewLine( Reader::Location begin, + Reader::Location end ); + void addComment( Reader::Location begin, + Reader::Location end, + Placement placement ); + void registerComment( Placement placement, + unsigned int index ); + + + typedef std::deque<CommentInfo> Comments; + typedef std::map<unsigned int> CommentsById; + Comments comments_; + CommentsById commentsById_; + ValueId currentId_; + Reader::Location lastValueEnd_; + int monitorNextValue_; }; Index: json_forwards.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_forwards.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** json_forwards.h 27 Jul 2005 07:36:26 -0000 1.2 --- json_forwards.h 30 Jul 2005 11:15:11 -0000 1.3 *************** *** 4,12 **** namespace Json { ! class Value; ! class Reader; class FastWriter; class Path; class PathArgument; } // namespace Json --- 4,16 ---- namespace Json { ! class CommentMemo; class FastWriter; class Path; class PathArgument; + class Reader; + class StyledWriter; + class Value; + + typedef unsigned int ValueId; } // namespace Json Index: json_writer.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_writer.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** json_writer.h 28 Jul 2005 08:21:10 -0000 1.2 --- json_writer.h 30 Jul 2005 11:15:11 -0000 1.3 *************** *** 3,6 **** --- 3,7 ---- # include "json_value.h" + # include "json_reader.h" # include <deque> # include <string> *************** *** 10,13 **** --- 11,20 ---- class Value; + /** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format without formatting (not human friendly). + * + * The JSON document is written in a single line. It is not intended for 'human' consumption, + * but may be usefull to support feature such as RPC where bandwith is limited. + * \sa Reader, Value + */ class JSON_API FastWriter { *************** *** 21,26 **** }; ! // @todo extends to allow rewriting while preserving existing comment & inserting other. ! /* Write the JSON values in a human readable way. * * The rules for line break and indent are as follow: --- 28,32 ---- }; ! /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way. * * The rules for line break and indent are as follow: *************** *** 35,38 **** --- 41,45 ---- * - otherwise, it the values do not fit on one line, or the array contains * object or non empty array, then print one value per line. + * \sa Reader, Value */ class JSON_API StyledWriter *************** *** 41,46 **** --- 48,65 ---- StyledWriter(); + /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format. + * \param root Value to serialize. + * \return String containing the JSON document that represent the root value. + */ std::string write( const Value &root ); + /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format. + * \param root Value to serialize. + * \param commentMemo Memo generated while parsing a JSON document. + * \return String containing the JSON document that represent the root value. + */ + std::string write( const Value &root, + const CommentMemo &commentMemo ); + private: void writeValue( const Value &value ); *************** *** 52,55 **** --- 71,80 ---- void indent(); void unindent(); + void writeInitialComment( const Value &root ); + void writeFinalComment( const Value &root ); + bool hasMoreComments() const; + const CommentMemo::CommentInfo &getCurrentComment() const; + void writeComment( const CommentMemo::CommentInfo &comment ); + bool hasCommentForValue( const Value &value ) const; typedef std::vector<std::string> ChildValues; *************** *** 60,63 **** --- 85,90 ---- int rightMargin_; int indentSize_; + const CommentMemo *commentMemo_; + unsigned int currentComment_; bool addChildValues_; }; |
From: Baptiste L. <bl...@us...> - 2005-07-30 11:15:20
|
Update of /cvsroot/jsoncpp/jsoncpp/src/lib_json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3607/src/lib_json Modified Files: json_reader.cpp json_value.cpp json_writer.cpp Log Message: * added doxygen documentation Index: json_value.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/json_value.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** json_value.cpp 27 Jul 2005 22:25:57 -0000 1.3 --- json_value.cpp 30 Jul 2005 11:15:11 -0000 1.4 *************** *** 92,98 **** Value::Value( ValueType type ) : type_( type ) ! , parent_( 0 ) ! , previous_( 0 ) ! , next_( 0 ) { switch ( type ) --- 92,96 ---- Value::Value( ValueType type ) : type_( type ) ! , id_( 0 ) { switch ( type ) *************** *** 125,128 **** --- 123,127 ---- Value::Value( Int value ) : type_( intValue ) + , id_( 0 ) { value_.int_ = value; *************** *** 132,135 **** --- 131,135 ---- Value::Value( UInt value ) : type_( uintValue ) + , id_( 0 ) { value_.uint_ = value; *************** *** 138,141 **** --- 138,142 ---- Value::Value( double value ) : type_( realValue ) + , id_( 0 ) { value_.real_ = value; *************** *** 144,147 **** --- 145,149 ---- Value::Value( const char *value ) : type_( stringValue ) + , id_( 0 ) { value_.string_ = value ? strdup( value ) : 0; *************** *** 150,153 **** --- 152,156 ---- Value::Value( const std::string &value ) : type_( stringValue ) + , id_( 0 ) { value_.string_ = value.empty() ? 0 : strdup( value.c_str() ); *************** *** 156,159 **** --- 159,163 ---- Value::Value( bool value ) : type_( booleanValue ) + , id_( 0 ) { value_.bool_ = value; *************** *** 163,166 **** --- 167,171 ---- Value::Value( const Value &other ) : type_( other.type_ ) + , id_( 0 ) { switch ( type_ ) *************** *** 601,616 **** it = value_.map_->insert( it, defaultValue ); Value &value = (*it).second; - /* - if ( result.second ) - { - value.parent_ = this; - if ( value_.map_.size() > 1 ) - { - Value &headValue = (*value_.map_.begin()).second; - value.next_ = &headValue; - value.previous = headValue.previous_; - headValue.previous_ = &value; - } - }*/ return value; } --- 606,609 ---- *************** *** 773,776 **** --- 766,783 ---- + void + Value::setId( ValueId id ) + { + id_ = id; + } + + + ValueId + Value::id() const + { + return id_; + } + + // class PathArgument // ////////////////////////////////////////////////////////////////// Index: json_reader.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/json_reader.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json_reader.cpp 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json_reader.cpp 30 Jul 2005 11:15:11 -0000 1.2 *************** *** 19,23 **** --- 19,27 ---- + // Class Reader + // ////////////////////////////////////////////////////////////////// + Reader::Reader() + : commentMemo_( 0 ) { } *************** *** 39,42 **** --- 43,60 ---- + bool + Reader::parse( const std::string &document, + Value &root, + CommentMemo &commentMemo ) + { + commentMemo_ = &commentMemo; + commentMemo.beginDocumentParsing(); + bool success = parse( document, root ); + commentMemo.endDocumentParsing(); + commentMemo_ = 0; + return success; + } + + bool Reader::readValue() *************** *** 606,609 **** --- 624,768 ---- + // Class Reader + // ////////////////////////////////////////////////////////////////// + CommentMemo::CommentMemo() + : currentId_( 0 ) + , lastValueEnd_( 0 ) + { + } + + + void + CommentMemo::beginDocumentParsing() + { + monitorNextValue_ = 0; + lastValueEnd_ = 0; + } + + + void + CommentMemo::parsedCComment( Reader::Location begin, + Reader::Location end ) + { + if ( lastValueEnd_ == 0 ) + addComment( begin, end, atDocumentStart ); + else if ( containsNewLine( begin, end ) || containsNewLine( lastValueEnd_, begin ) ) + addComment( begin, end, beforeValue ); + else + addComment( begin, end, afterValueOnSameLine ); + } + + + void + CommentMemo::parsedCppComment( Reader::Location begin, + Reader::Location end ) + { + if ( lastValueEnd_ == 0 ) + addComment( begin, end, atDocumentStart ); + else if ( containsNewLine( lastValueEnd_, begin ) ) + addComment( begin, end, beforeValue ); + else + addComment( begin, end, afterValueOnSameLine ); + } + + + void + CommentMemo::parsedValue( Reader::Location begin, + Reader::Location end, + Value &value ) + { + value.setId( ++currentId_ ); + for ( ; monitorNextValue_ > 0; --monitorNextValue_ ) + { + unsigned int index = (unsigned int)(comments_.size() - monitorNextValue_); + comments_[ index ].id_ = currentId_; + registerComment( comments_[index].placement_, index ); + // commentsById_[currentId_ << 4 | comments_[index].placement_] = index; + } + } + + + void + CommentMemo::endDocumentParsing() + { + unsigned int size = (unsigned int)comments_.size(); + if ( !size ) + return; + while ( --size && comments_[size].id_ == ValueId(-1) ) + { + comments_[size].id_ = currentId_; + comments_[size].placement_ = atDocumentEnd; + registerComment( atDocumentEnd, size ); + } + } + + + unsigned int + CommentMemo::getCommentCount() const + { + return (unsigned int)comments_.size(); + } + + + const CommentMemo::CommentInfo & + CommentMemo::getComment( unsigned int index ) const + { + return comments_.at(index); + } + + + bool + CommentMemo::containsNewLine( Reader::Location begin, + Reader::Location end ) + { + for ( ;begin < end; ++begin ) + if ( *begin == '\n' || *begin == '\r' ) + return true; + return false; + } + + + void + CommentMemo::addComment( Reader::Location begin, + Reader::Location end, + Placement placement ) + { + CommentInfo info; + info.comment_ = std::string( begin, end ); + info.placement_ = placement; + if ( placement == afterValueOnSameLine ) + { + info.id_ = currentId_; + registerComment( placement, comments_.size() ); + } + else + { + info.id_ = -1; + ++monitorNextValue_; + } + + comments_.push_back( info ); + } + + + void + CommentMemo::registerComment( Placement placement, + unsigned int index ) + { + commentsById_[ placement | currentId_ * 8 ] = index; + } + + + const CommentMemo::CommentInfo * + CommentMemo::findComment( ValueId id, Placement placement ) const + { + unsigned int key = placement | id * 8; + CommentsById::const_iterator it = commentsById_.find( key ); + if ( it == commentsById_.end() ) + return 0; + return &((*it).second); + } + + } // namespace Json Index: json_writer.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/json_writer.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** json_writer.cpp 28 Jul 2005 08:21:11 -0000 1.3 --- json_writer.cpp 30 Jul 2005 11:15:11 -0000 1.4 *************** *** 74,77 **** --- 74,78 ---- } + void FastWriter::writeValue( const Value &value ) *************** *** 154,157 **** --- 155,173 ---- + std::string + StyledWriter::write( const Value &root, + const CommentMemo &commentMemo ) + { + commentMemo_ = &commentMemo; + writeInitialComment( root ); + writeCommentBeforeValue( root ); + write( root ); + writeCommentAfterValueOnSameLine( root ); + writeFinalComment( root ); + commentMemo_ = 0; + return document_; + } + + void StyledWriter::writeValue( const Value &value ) *************** *** 189,202 **** writeWithIndent( "{" ); indent(); ! for ( Value::Members::iterator it = members.begin(); ! it != members.end(); ! ++it ) { const std::string &name = *it; ! if ( it != members.begin() ) ! document_ += ","; writeWithIndent( valueToQuotedString( name.c_str() ) ); document_ += " : "; ! writeValue( value[name] ); } unindent(); --- 205,224 ---- writeWithIndent( "{" ); indent(); ! Value::Members::iterator it = members.begin(); ! while ( true ) { const std::string &name = *it; ! const Value &childValue = value[name]; ! writeCommentBeforeValue( childValue ); writeWithIndent( valueToQuotedString( name.c_str() ) ); document_ += " : "; ! writeValue( childValue ); ! if ( ++it == members.end() ) ! { ! writeCommentAfterValueOnSameLine( childValue ); ! break; ! } ! document_ += ","; ! writeCommentAfterValueOnSameLine( childValue ); } unindent(); *************** *** 223,230 **** indent(); bool hasChildValue = !childValues_.empty(); ! for ( int index =0; index < size; ++index ) { ! if ( index > 0 ) ! document_ += ","; if ( hasChildValue ) writeWithIndent( childValues_[index] ); --- 245,253 ---- indent(); bool hasChildValue = !childValues_.empty(); ! int index =0; ! while ( true ) { ! const Value &childValue = value[index]; ! writeCommentBeforeValue( childValue ); if ( hasChildValue ) writeWithIndent( childValues_[index] ); *************** *** 232,237 **** { writeIndent(); ! writeValue( value[index] ); } } unindent(); --- 255,267 ---- { writeIndent(); ! writeValue( childValue ); } + if ( ++index == size ) + { + writeCommentAfterValueOnSameLine( childValue ); + break; + } + document_ += ","; + writeCommentAfterValueOnSameLine( childValue ); } unindent(); *************** *** 276,279 **** --- 306,310 ---- writeValue( value[index] ); lineLength += int( childValues_[index].length() ); + isMultiLine = isMultiLine && hasCommentForValue( value[index] ); } addChildValues_ = false; *************** *** 332,334 **** --- 363,418 ---- + void + StyledWriter::writeInitialComment( const Value &root ) + { + currentComment_ = 0; + for ( ; hasMoreComments() + && getCurrentComment().id_ == root.id() + && getCurrentComment().placement_ == CommentMemo::atDocumentStart; + ++currentComment_ ) + writeComment( getCurrentComment() ); + } + + + void + StyledWriter::writeFinalComment( const Value &root ) + { + for ( ; hasMoreComments() + && getCurrentComment().id_ == root.id() + && getCurrentComment().placement_ == CommentMemo::atDocumentEnd; + ++currentComment_ ) + { + writeComment( commentMemo_->getComment( currentComment_++ ) ); + } + } + + + bool + StyledWriter::hasMoreComments() const + { + return commentMemo_ && currentComment_ < commentMemo_->getCommentCount(); + } + + + const CommentMemo::CommentInfo & + StyledWriter::getCurrentComment() const + { + return commentMemo_->getComment( currentComment_ ); + } + + + void + StyledWriter::writeComment( const CommentMemo::CommentInfo &comment ) + { + document_ += comment.comment_; + document_ += "\n"; + } + + + bool + StyledWriter::hasCommentForValue( const Value &value ) const + { + } + + } // namespace Json |
From: Baptiste L. <bl...@us...> - 2005-07-30 11:15:19
|
Update of /cvsroot/jsoncpp/jsoncpp/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3607/doc Added Files: .cvsignore doxyfile Log Message: * added doxygen documentation --- NEW FILE: doxyfile --- # Doxyfile 1.4.3 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = "Json Cpp" PROJECT_NUMBER = 1.0 OUTPUT_DIRECTORY = docbuild CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES STRIP_FROM_PATH = E:\prg\vc\Lib\jsoncpp STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO INHERIT_DOCS = YES DISTRIBUTE_GROUP_DOC = NO SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 ALIASES = OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = YES EXTRACT_PRIVATE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = NO EXTRACT_LOCAL_METHODS = NO HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = NO HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_BY_SCOPE_NAME = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_DIRECTORIES = YES FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = ..\include\json ..\src\lib_json FILE_PATTERNS = *.h *.cpp *.dox RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = YES INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES USE_HTAGS = NO VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO CHM_FILE = jsoncpp.chm HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml XML_SCHEMA = XML_DTD = XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = ..\include INCLUDE_FILE_PATTERNS = *.h PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = NO HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 MAX_DOT_GRAPH_HEIGHT = 1024 MAX_DOT_GRAPH_DEPTH = 1000 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO --- NEW FILE: .cvsignore --- docbuild *docbook* jsoncpp.qbk *.xml generate_catalog.py |
From: Baptiste L. <bl...@us...> - 2005-07-30 11:14:19
|
Update of /cvsroot/jsoncpp/jsoncpp/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3513/doc Log Message: Directory /cvsroot/jsoncpp/jsoncpp/doc added to the repository |
From: Baptiste L. <bl...@us...> - 2005-07-28 18:10:57
|
Update of /cvsroot/jsoncpp/jsoncpp/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25333 Added Files: test_array_05.expected test_array_05.json test_array_06.expected test_array_06.json Log Message: * tests to test rewrite of multi-line array based on max line length criteria. --- NEW FILE: test_array_06.json --- [ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "ccccccccccccccccccccccc", "dddddddddddddddddddddddddddddddddddddddddddddddddddd" ] --- NEW FILE: test_array_05.expected --- .=[] .[0]=1 .[1]=2 .[2]=3 .[3]=4 .[4]=5 .[5]=6 .[6]=7 .[7]=8 .[8]=9 .[9]=10 .[10]=11 .[11]=12 .[12]=13 .[13]=14 .[14]=15 .[15]=16 .[16]=17 .[17]=18 .[18]=19 .[19]=20 .[20]=21 .[21]=22 .[22]=23 .[23]=24 .[24]=25 .[25]=26 .[26]=27 .[27]=28 .[28]=29 .[29]=30 .[30]=31 .[31]=32 .[32]=33 .[33]=34 .[34]=35 .[35]=36 .[36]=37 .[37]=38 .[38]=39 .[39]=40 .[40]=41 .[41]=42 .[42]=43 .[43]=44 .[44]=45 .[45]=46 .[46]=47 .[47]=48 .[48]=49 .[49]=50 .[50]=51 .[51]=52 .[52]=53 .[53]=54 .[54]=55 .[55]=56 .[56]=57 .[57]=58 .[58]=59 .[59]=60 .[60]=61 .[61]=62 .[62]=63 .[63]=64 .[64]=65 .[65]=66 .[66]=67 .[67]=68 .[68]=69 .[69]=70 .[70]=71 .[71]=72 .[72]=73 .[73]=74 .[74]=75 .[75]=76 .[76]=77 .[77]=78 .[78]=79 .[79]=80 .[80]=81 .[81]=82 .[82]=83 .[83]=84 .[84]=85 .[85]=86 .[86]=87 .[87]=88 .[88]=89 .[89]=90 .[90]=91 .[91]=92 .[92]=93 .[93]=94 .[94]=95 .[95]=96 .[96]=97 .[97]=98 .[98]=99 --- NEW FILE: test_array_06.expected --- .=[] .[0]="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" .[1]="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" .[2]="ccccccccccccccccccccccc" .[3]="dddddddddddddddddddddddddddddddddddddddddddddddddddd" --- NEW FILE: test_array_05.json --- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] |
From: Baptiste L. <bl...@us...> - 2005-07-28 08:21:20
|
Update of /cvsroot/jsoncpp/jsoncpp/src/lib_json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23924/src/lib_json Modified Files: json_writer.cpp Log Message: * added implementation of StyledWriter which output JSON value formatted to be easy read by human. Index: json_writer.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/json_writer.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** json_writer.cpp 27 Jul 2005 22:28:08 -0000 1.2 --- json_writer.cpp 28 Jul 2005 08:21:11 -0000 1.3 *************** *** 132,135 **** --- 132,334 ---- + // Class StyledWriter + // ////////////////////////////////////////////////////////////////// + + StyledWriter::StyledWriter() + : rightMargin_( 74 ) + , indentSize_( 3 ) + { + } + + + std::string + StyledWriter::write( const Value &root ) + { + document_.clear(); + addChildValues_ = false; + indentString_.clear(); + writeValue( root ); + document_ += "\n"; + return document_; + } + + + void + StyledWriter::writeValue( const Value &value ) + { + switch ( value.type() ) + { + case nullValue: + pushValue( "null" ); + break; + case intValue: + pushValue( valueToString( value.asInt() ) ); + break; + case uintValue: + pushValue( valueToString( value.asUInt() ) ); + break; + case realValue: + pushValue( valueToString( value.asDouble() ) ); + break; + case stringValue: + pushValue( valueToQuotedString( value.asCString() ) ); + break; + case booleanValue: + pushValue( valueToString( value.asBool() ) ); + break; + case arrayValue: + writeArrayValue( value); + break; + case objectValue: + { + Value::Members members( value.getMemberNames() ); + if ( members.empty() ) + pushValue( "{}" ); + else + { + writeWithIndent( "{" ); + indent(); + for ( Value::Members::iterator it = members.begin(); + it != members.end(); + ++it ) + { + const std::string &name = *it; + if ( it != members.begin() ) + document_ += ","; + writeWithIndent( valueToQuotedString( name.c_str() ) ); + document_ += " : "; + writeValue( value[name] ); + } + unindent(); + writeWithIndent( "}" ); + } + } + break; + } + } + + + void + StyledWriter::writeArrayValue( const Value &value ) + { + int size = value.size(); + if ( size == 0 ) + pushValue( "[]" ); + else + { + bool isArrayMultiLine = isMultineArray( value ); + if ( isArrayMultiLine ) + { + writeWithIndent( "[" ); + indent(); + bool hasChildValue = !childValues_.empty(); + for ( int index =0; index < size; ++index ) + { + if ( index > 0 ) + document_ += ","; + if ( hasChildValue ) + writeWithIndent( childValues_[index] ); + else + { + writeIndent(); + writeValue( value[index] ); + } + } + unindent(); + writeWithIndent( "]" ); + } + else // output on a single line + { + assert( childValues_.size() == size ); + document_ += "[ "; + for ( int index =0; index < size; ++index ) + { + if ( index > 0 ) + document_ += ", "; + document_ += childValues_[index]; + } + document_ += " ]"; + } + } + } + + + bool + StyledWriter::isMultineArray( const Value &value ) + { + int size = value.size(); + bool isMultiLine = size*3 >= rightMargin_ ; + childValues_.clear(); + for ( int index =0; index < size && !isMultiLine; ++index ) + { + const Value &childValue = value[index]; + isMultiLine = isMultiLine || + ( (childValue.isArray() || childValue.isObject()) && + childValue.size() > 0 ); + } + if ( !isMultiLine ) // check if line length > max line length + { + childValues_.reserve( size ); + addChildValues_ = true; + int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]' + for ( int index =0; index < size && !isMultiLine; ++index ) + { + writeValue( value[index] ); + lineLength += int( childValues_[index].length() ); + } + addChildValues_ = false; + isMultiLine = isMultiLine || lineLength >= rightMargin_; + } + return isMultiLine; + } + + + void + StyledWriter::pushValue( const std::string &value ) + { + if ( addChildValues_ ) + childValues_.push_back( value ); + else + document_ += value; + } + + + void + StyledWriter::writeIndent() + { + if ( !document_.empty() ) + { + char last = document_[document_.length()-1]; + assert( last != '\n' ); + if ( last == ' ' ) // already indented + return; + document_ += '\n'; + } + document_ += indentString_; + } + + + void + StyledWriter::writeWithIndent( const std::string &value ) + { + writeIndent(); + document_ += value; + } + + + void + StyledWriter::indent() + { + indentString_ += std::string( indentSize_, ' ' ); + } + + + void + StyledWriter::unindent() + { + assert( int(indentString_.size()) >= indentSize_ ); + indentString_.resize( indentString_.size() - indentSize_ ); + } + } // namespace Json |
From: Baptiste L. <bl...@us...> - 2005-07-28 08:21:20
|
Update of /cvsroot/jsoncpp/jsoncpp/src/jsontest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23924/src/jsontest Modified Files: main.cpp Log Message: * added implementation of StyledWriter which output JSON value formatted to be easy read by human. Index: main.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/jsontest/main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.cpp 27 Jul 2005 22:28:08 -0000 1.2 --- main.cpp 28 Jul 2005 08:21:11 -0000 1.3 *************** *** 111,115 **** std::string &rewrite ) { ! Json::FastWriter writer; rewrite = writer.write( root ); FILE *fout = fopen( rewritePath.c_str(), "wt" ); --- 111,116 ---- std::string &rewrite ) { ! // Json::FastWriter writer; ! Json::StyledWriter writer; rewrite = writer.write( root ); FILE *fout = fopen( rewritePath.c_str(), "wt" ); |
From: Baptiste L. <bl...@us...> - 2005-07-28 08:21:20
|
Update of /cvsroot/jsoncpp/jsoncpp/include/json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23924/include/json Modified Files: json_writer.h Log Message: * added implementation of StyledWriter which output JSON value formatted to be easy read by human. Index: json_writer.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_writer.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json_writer.h 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json_writer.h 28 Jul 2005 08:21:10 -0000 1.2 *************** *** 10,14 **** class Value; - // @todo extends to allow rewriting while preserving existing comment & inserting other. class JSON_API FastWriter { --- 10,13 ---- *************** *** 22,25 **** --- 21,67 ---- }; + // @todo extends to allow rewriting while preserving existing comment & inserting other. + /* Write the JSON values in a human readable way. + * + * The rules for line break and indent are as follow: + * - Object value: + * - if empty then print {} without indent and line break + * - if not empty the print '{', line break & indent, print one value per line + * and then unindent and line break and print '}'. + * - Array value: + * - if empty then print [] without indent and line break + * - if the array contains no object value, empty array or some other value types, + * and all the values fit on one lines, then print the array on a single line. + * - otherwise, it the values do not fit on one line, or the array contains + * object or non empty array, then print one value per line. + */ + class JSON_API StyledWriter + { + public: + StyledWriter(); + + std::string write( const Value &root ); + + private: + void writeValue( const Value &value ); + void writeArrayValue( const Value &value ); + bool isMultineArray( const Value &value ); + void pushValue( const std::string &value ); + void writeIndent(); + void writeWithIndent( const std::string &value ); + void indent(); + void unindent(); + + typedef std::vector<std::string> ChildValues; + + ChildValues childValues_; + std::string document_; + std::string indentString_; + int rightMargin_; + int indentSize_; + bool addChildValues_; + }; + + std::string JSON_API valueToString( Value::Int value ); std::string JSON_API valueToString( Value::UInt value ); |
From: Baptiste L. <bl...@us...> - 2005-07-27 22:28:18
|
Update of /cvsroot/jsoncpp/jsoncpp/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27056/test Modified Files: .cvsignore runtests.py Log Message: * added FastWriter implementation and updated test (read the written input and check if correct). Index: .cvsignore =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/test/.cvsignore,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** .cvsignore 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- .cvsignore 27 Jul 2005 22:28:07 -0000 1.2 *************** *** 1 **** --- 1,4 ---- *.actual + *.actual-rewrite + *.rewrite + *.process-output Index: runtests.py =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/test/runtests.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** runtests.py 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- runtests.py 27 Jul 2005 22:28:07 -0000 1.2 *************** *** 10,14 **** jsontest_executable_path = os.path.normpath( os.path.abspath( sys.argv[1] ) ) ! def compareOutputs( expected, actual ): expected = expected.strip().replace('\r','').split('\n') actual = actual.strip().replace('\r','').split('\n') --- 10,14 ---- jsontest_executable_path = os.path.normpath( os.path.abspath( sys.argv[1] ) ) ! def compareOutputs( expected, actual, message ): expected = expected.strip().replace('\r','').split('\n') actual = actual.strip().replace('\r','').split('\n') *************** *** 28,38 **** return '' return lines[index].strip() ! return """ Difference at line %d: Expected: '%s' Actual: '%s' ! """ % (diff_line, safeGetLine(expected,diff_line), safeGetLine(actual,diff_line) ) tests = glob.glob( '*.json' ) --- 28,43 ---- return '' return lines[index].strip() ! return """ Difference in %s at line %d: Expected: '%s' Actual: '%s' ! """ % (message, diff_line, safeGetLine(expected,diff_line), safeGetLine(actual,diff_line) ) + def safeReadFile( path ): + try: + return file( base_path + '.actual', 'rt' ).read() + except: + return "" tests = glob.glob( '*.json' ) *************** *** 41,55 **** print 'TESTING:', input_path, pipe = os.popen( "%s %s" % (jsontest_executable_path, input_path) ) ! actual_output = pipe.read() status = pipe.close() ! actual_output_path = os.path.splitext(input_path)[0] + '.actual' ! file(actual_output_path,'wt').write( actual_output ) if status: print 'parsing failed' ! failed_tests.append( (input_path, 'Parsing failed:\n' + actual_output) ) else: expected_output_path = os.path.splitext(input_path)[0] + '.expected' expected_output = file( expected_output_path, 'rt' ).read() ! detail = compareOutputs( expected_output, actual_output ) if detail: print 'FAILED' --- 46,63 ---- print 'TESTING:', input_path, pipe = os.popen( "%s %s" % (jsontest_executable_path, input_path) ) ! process_output = pipe.read() status = pipe.close() ! base_path = os.path.splitext(input_path)[0] ! actual_output = safeReadFile( base_path + '.actual' ) ! actual_rewrite_output = safeReadFile( base_path + '.actual-rewrite' ) ! file(base_path + '.process-output','wt').write( process_output ) if status: print 'parsing failed' ! failed_tests.append( (input_path, 'Parsing failed:\n' + process_output) ) else: expected_output_path = os.path.splitext(input_path)[0] + '.expected' expected_output = file( expected_output_path, 'rt' ).read() ! detail = ( compareOutputs( expected_output, actual_output, 'input' ) ! or compareOutputs( expected_output, actual_rewrite_output, 'rewrite' ) ) if detail: print 'FAILED' |
From: Baptiste L. <bl...@us...> - 2005-07-27 22:28:18
|
Update of /cvsroot/jsoncpp/jsoncpp/src/jsontest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27056/src/jsontest Modified Files: main.cpp Log Message: * added FastWriter implementation and updated test (read the written input and check if correct). Index: main.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/jsontest/main.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** main.cpp 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- main.cpp 27 Jul 2005 22:28:08 -0000 1.2 *************** *** 24,52 **** static void ! printValueTree( Json::Value &value, const std::string &path = "." ) { switch ( value.type() ) { case Json::nullValue: ! printf( "%s=null\n", path.c_str() ); break; case Json::intValue: ! printf( "%s=%d\n", path.c_str(), value.asInt() ); break; case Json::uintValue: ! printf( "%s=%u\n", path.c_str(), value.asUInt() ); break; case Json::realValue: ! printf( "%s=%.16g\n", path.c_str(), value.asDouble() ); break; case Json::stringValue: ! printf( "%s=\"%s\"\n", path.c_str(), value.asString().c_str() ); break; case Json::booleanValue: ! printf( "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false" ); break; case Json::arrayValue: { ! printf( "%s=[]\n", path.c_str() ); int size = value.size(); for ( int index =0; index < size; ++index ) --- 24,52 ---- static void ! printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." ) { switch ( value.type() ) { case Json::nullValue: ! fprintf( fout, "%s=null\n", path.c_str() ); break; case Json::intValue: ! fprintf( fout, "%s=%d\n", path.c_str(), value.asInt() ); break; case Json::uintValue: ! fprintf( fout, "%s=%u\n", path.c_str(), value.asUInt() ); break; case Json::realValue: ! fprintf( fout, "%s=%.16g\n", path.c_str(), value.asDouble() ); break; case Json::stringValue: ! fprintf( fout, "%s=\"%s\"\n", path.c_str(), value.asString().c_str() ); break; case Json::booleanValue: ! fprintf( fout, "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false" ); break; case Json::arrayValue: { ! fprintf( fout, "%s=[]\n", path.c_str() ); int size = value.size(); for ( int index =0; index < size; ++index ) *************** *** 54,58 **** static char buffer[16]; sprintf( buffer, "[%d]", index ); ! printValueTree( value[index], path + buffer ); } } --- 54,58 ---- static char buffer[16]; sprintf( buffer, "[%d]", index ); ! printValueTree( fout, value[index], path + buffer ); } } *************** *** 60,64 **** case Json::objectValue: { ! printf( "%s={}\n", path.c_str() ); Json::Value::Members members( value.getMemberNames() ); std::string suffix = *(path.end()-1) == '.' ? "" : "."; --- 60,64 ---- case Json::objectValue: { ! fprintf( fout, "%s={}\n", path.c_str() ); Json::Value::Members members( value.getMemberNames() ); std::string suffix = *(path.end()-1) == '.' ? "" : "."; *************** *** 68,72 **** { const std::string &name = *it; ! printValueTree( value[name], path + suffix + name ); } } --- 68,72 ---- { const std::string &name = *it; ! printValueTree( fout, value[name], path + suffix + name ); } } *************** *** 78,81 **** --- 78,140 ---- + static int + parseAndSaveValueTree( const std::string &input, + const std::string &actual, + const std::string &kind, + Json::Value &root ) + { + Json::Reader reader; + bool parsingSuccessful = reader.parse( input, root ); + if ( !parsingSuccessful ) + { + printf( "Failed to parse %s file: \n%s\n", + kind.c_str(), + reader.getFormatedErrorMessages().c_str() ); + return 1; + } + + FILE *factual = fopen( actual.c_str(), "wt" ); + if ( !factual ) + { + printf( "Failed to create %s actual file.\n", kind.c_str() ); + return 2; + } + printValueTree( factual, root ); + fclose( factual ); + return 0; + } + + + static int + rewriteValueTree( const std::string &rewritePath, + const Json::Value &root, + std::string &rewrite ) + { + Json::FastWriter writer; + rewrite = writer.write( root ); + FILE *fout = fopen( rewritePath.c_str(), "wt" ); + if ( !fout ) + { + printf( "Failed to create rewrite file: %s\n", rewritePath.c_str() ); + return 2; + } + fprintf( fout, "%s\n", rewrite.c_str() ); + fclose( fout ); + return 0; + } + + + static std::string + removeSuffix( const std::string &path, + const std::string &extension ) + { + if ( extension.length() >= path.length() ) + return std::string(""); + std::string suffix = path.substr( path.length() - extension.length() ); + if ( suffix != extension ) + return std::string(""); + return path.substr( 0, path.length() - extension.length() ); + } + int main( int argc, const char *argv[] ) { *************** *** 83,87 **** { printf( "Usage: %s input-json-file", argv[0] ); ! return 2; } --- 142,146 ---- { printf( "Usage: %s input-json-file", argv[0] ); ! return 3; } *************** *** 93,104 **** } ! Json::Reader reader; Json::Value root; ! bool parsingSuccessful = reader.parse( input, root ); ! if ( parsingSuccessful ) ! printValueTree( root ); ! else ! printf( "%s\n", reader.getFormatedErrorMessages().c_str() ); ! return parsingSuccessful ? 0 : 1; } \ No newline at end of file --- 152,179 ---- } ! std::string basePath = removeSuffix( argv[1], ".json" ); ! if ( basePath.empty() ) ! { ! printf( "Bad input path. Path does not end with '.expected':\n%s\n", argv[1] ); ! return 3; ! } ! ! std::string actualPath = basePath + ".actual"; ! std::string rewritePath = basePath + ".rewrite"; ! std::string rewriteActualPath = basePath + ".actual-rewrite"; ! Json::Value root; ! int exitCode = parseAndSaveValueTree( input, actualPath, "input", root ); ! if ( exitCode == 0 ) ! { ! std::string rewrite; ! exitCode = rewriteValueTree( rewritePath, root, rewrite ); ! if ( exitCode == 0 ) ! { ! Json::Value rewriteRoot; ! exitCode = parseAndSaveValueTree( rewrite, rewriteActualPath, "rewrite", rewriteRoot ); ! } ! } ! return exitCode; } \ No newline at end of file |
From: Baptiste L. <bl...@us...> - 2005-07-27 22:28:18
|
Update of /cvsroot/jsoncpp/jsoncpp/makefiles/vs71 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27056/makefiles/vs71 Modified Files: jsoncpp.suo Log Message: * added FastWriter implementation and updated test (read the written input and check if correct). Index: jsoncpp.suo =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/makefiles/vs71/jsoncpp.suo,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvs57kJa3 and /tmp/cvskp9TyP differ |
From: Baptiste L. <bl...@us...> - 2005-07-27 22:28:18
|
Update of /cvsroot/jsoncpp/jsoncpp/src/lib_json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27056/src/lib_json Modified Files: json_writer.cpp Log Message: * added FastWriter implementation and updated test (read the written input and check if correct). Index: json_writer.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/json_writer.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json_writer.cpp 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json_writer.cpp 27 Jul 2005 22:28:08 -0000 1.2 *************** *** 1,4 **** #include <json/json_writer.h> - #include <algorithm> #include <utility> #include <assert.h> --- 1,3 ---- *************** *** 8,12 **** static void uintToString( unsigned int value, ! char *current ) { *--current = 0; --- 7,11 ---- static void uintToString( unsigned int value, ! char *¤t ) { *--current = 0; *************** *** 18,22 **** } while ( value != 0 ); - std::reverse( current, end ); } --- 17,20 ---- *************** *** 104,108 **** --- 102,110 ---- int size = value.size(); for ( int index =0; index < size; ++index ) + { + if ( index > 0 ) + document_ += ", "; writeValue( value[index] ); + } document_ += " ]"; } *************** *** 119,123 **** if ( it != members.begin() ) document_ += ", "; ! document_ += name; document_ += " : "; writeValue( value[name] ); --- 121,125 ---- if ( it != members.begin() ) document_ += ", "; ! document_ += valueToQuotedString( name.c_str() ); document_ += " : "; writeValue( value[name] ); |
From: Baptiste L. <bl...@us...> - 2005-07-27 22:28:18
|
Update of /cvsroot/jsoncpp/jsoncpp/include/json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27056/include/json Modified Files: json.h Log Message: * added FastWriter implementation and updated test (read the written input and check if correct). Index: json.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json.h 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json.h 27 Jul 2005 22:28:08 -0000 1.2 *************** *** 5,8 **** --- 5,9 ---- # include "json_value.h" # include "json_reader.h" + # include "json_writer.h" #endif // JSON_JSON_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2005-07-27 22:26:10
|
Update of /cvsroot/jsoncpp/jsoncpp/src/lib_json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26630/src/lib_json Modified Files: json_value.cpp Log Message: * fixed wrong assertions * added rough implementation of Json::Path support. Index: json_value.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/json_value.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** json_value.cpp 27 Jul 2005 07:38:14 -0000 1.2 --- json_value.cpp 27 Jul 2005 22:25:57 -0000 1.3 *************** *** 4,8 **** #define JSON_ASSERT_UNREACHABLE assert( false ) ! #define JSON_ASSERT( condition ) namespace Json { --- 4,8 ---- #define JSON_ASSERT_UNREACHABLE assert( false ) ! #define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw namespace Json { *************** *** 203,206 **** --- 203,207 ---- case objectValue: delete value_.map_; + break; default: JSON_ASSERT_UNREACHABLE; *************** *** 393,397 **** return 0; case intValue: - JSON_ASSERT( value_.int_ >= 0 && "Negative integer can not be converted to unsigned integer" ); return value_.int_; case uintValue: --- 394,397 ---- |
From: Baptiste L. <bl...@us...> - 2005-07-27 07:38:23
|
Update of /cvsroot/jsoncpp/jsoncpp/include/json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11379/include/json Modified Files: json_value.h Log Message: * added rough implementation of Path::resolve() & Path::make() Index: json_value.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_value.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json_value.h 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json_value.h 27 Jul 2005 07:38:15 -0000 1.2 *************** *** 207,210 **** --- 207,215 ---- const PathArgument &a5 = PathArgument() ); + const Value &resolve( const Value &root ) const; + Value resolve( const Value &root, + const Value &defaultValue ) const; + Value &make( Value &root ) const; + private: typedef std::vector<const PathArgument *> InArgs; |
From: Baptiste L. <bl...@us...> - 2005-07-27 07:38:23
|
Update of /cvsroot/jsoncpp/jsoncpp/src/lib_json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11379/src/lib_json Modified Files: json_value.cpp Log Message: * added rough implementation of Path::resolve() & Path::make() Index: json_value.cpp =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/json_value.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json_value.cpp 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json_value.cpp 27 Jul 2005 07:38:14 -0000 1.2 *************** *** 3,7 **** #include "assert.h" ! #define JSON_ASSERT_UNREACHABLE #define JSON_ASSERT( condition ) --- 3,7 ---- #include "assert.h" ! #define JSON_ASSERT_UNREACHABLE assert( false ) #define JSON_ASSERT( condition ) *************** *** 769,773 **** Value::isObject() const { ! return type_ == objectValue; } --- 769,773 ---- Value::isObject() const { ! return type_ == nullValue || type_ == objectValue; } *************** *** 895,897 **** --- 895,984 ---- + const Value & + Path::resolve( const Value &root ) const + { + const Value *node = &root; + for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) + { + const PathArgument &arg = *it; + if ( arg.kind_ == PathArgument::kindIndex ) + { + if ( !node->isArray() || node->isValidIndex( arg.index_ ) ) + { + // Error: unable to resolve path (array value expected at position... + } + node = &((*node)[arg.index_]); + } + else if ( arg.kind_ == PathArgument::kindKey ) + { + if ( !node->isObject() ) + { + // Error: unable to resolve path (object value expected at position...) + } + node = &((*node)[arg.key_]); + if ( node == &Value::null ) + { + // Error: unable to resolve path (object has no member named '' at position...) + } + } + } + return *node; + } + + + Value + Path::resolve( const Value &root, + const Value &defaultValue ) const + { + const Value *node = &root; + for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) + { + const PathArgument &arg = *it; + if ( arg.kind_ == PathArgument::kindIndex ) + { + if ( !node->isArray() || node->isValidIndex( arg.index_ ) ) + return defaultValue; + node = &((*node)[arg.index_]); + } + else if ( arg.kind_ == PathArgument::kindKey ) + { + if ( !node->isObject() ) + return defaultValue; + node = &((*node)[arg.key_]); + if ( node == &Value::null ) + return defaultValue; + } + } + return *node; + } + + + Value & + Path::make( Value &root ) const + { + Value *node = &root; + for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) + { + const PathArgument &arg = *it; + if ( arg.kind_ == PathArgument::kindIndex ) + { + if ( !node->isArray() ) + { + // Error: node is not an array at position ... + } + node = &((*node)[arg.index_]); + } + else if ( arg.kind_ == PathArgument::kindKey ) + { + if ( !node->isObject() ) + { + // Error: node is not an object at position... + } + node = &((*node)[arg.key_]); + } + } + return *node; + } + + } // namespace Json |
From: Baptiste L. <bl...@us...> - 2005-07-27 07:37:04
|
Update of /cvsroot/jsoncpp/jsoncpp/src/lib_json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11297/src/lib_json Modified Files: lib_json.vcproj Log Message: * updated Index: lib_json.vcproj =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/src/lib_json/lib_json.vcproj,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** lib_json.vcproj 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- lib_json.vcproj 27 Jul 2005 07:36:53 -0000 1.2 *************** *** 177,180 **** --- 177,183 ---- </File> <File + RelativePath="..\..\include\json\json_forwards.h"> + </File> + <File RelativePath=".\json_reader.cpp"> </File> |
From: Baptiste L. <bl...@us...> - 2005-07-27 07:36:38
|
Update of /cvsroot/jsoncpp/jsoncpp/include/json In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11223/include/json Modified Files: json_forwards.h Log Message: * updated Index: json_forwards.h =================================================================== RCS file: /cvsroot/jsoncpp/jsoncpp/include/json/json_forwards.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** json_forwards.h 27 Jul 2005 07:09:23 -0000 1.1.1.1 --- json_forwards.h 27 Jul 2005 07:36:26 -0000 1.2 *************** *** 6,9 **** --- 6,12 ---- class Value; class Reader; + class FastWriter; + class Path; + class PathArgument; } // namespace Json |