CppUnit project page CppUnit home page

writer.h

Go to the documentation of this file.
00001 #ifndef JSON_WRITER_H_INCLUDED
00002 # define JSON_WRITER_H_INCLUDED
00003 
00004 # include "value.h"
00005 # include <vector>
00006 # include <string>
00007 
00008 namespace Json {
00009 
00010    class Value;
00011 
00018    class JSON_API FastWriter
00019    {
00020    public:
00021       std::string write( const Value &root );
00022 
00023    private:
00024       void writeValue( const Value &value );
00025 
00026       std::string document_;
00027    };
00028 
00047    class JSON_API StyledWriter
00048    {
00049    public:
00050       StyledWriter();
00051 
00056       std::string write( const Value &root );
00057 
00058    private:
00059       void writeValue( const Value &value );
00060       void writeArrayValue( const Value &value );
00061       bool isMultineArray( const Value &value );
00062       void pushValue( const std::string &value );
00063       void writeIndent();
00064       void writeWithIndent( const std::string &value );
00065       void indent();
00066       void unindent();
00067       void writeCommentBeforeValue( const Value &root );
00068       void writeCommentAfterValueOnSameLine( const Value &root );
00069       bool hasCommentForValue( const Value &value );
00070       static std::string normalizeEOL( const std::string &text );
00071 
00072       typedef std::vector<std::string> ChildValues;
00073 
00074       ChildValues childValues_;
00075       std::string document_;
00076       std::string indentString_;
00077       int rightMargin_;
00078       int indentSize_;
00079       bool addChildValues_;
00080    };
00081 
00082    std::string JSON_API valueToString( Value::Int value );
00083    std::string JSON_API valueToString( Value::UInt value );
00084    std::string JSON_API valueToString( double value );
00085    std::string JSON_API valueToString( bool value );
00086    std::string JSON_API valueToQuotedString( const char *value );
00087 
00088 } // namespace Json
00089 
00090 
00091 
00092 #endif // JSON_WRITER_H_INCLUDED

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers