CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
Json::StyledStreamWriter Class Reference

Writes a Value in JSON format in a human friendly way, to a stream rather than to a string. More...

#include <writer.h>

Public Member Functions

 StyledStreamWriter (std::string indentation="\)
 
void write (std::ostream &out, const Value &root)
 Serialize a Value in JSON format. More...
 
 ~StyledStreamWriter ()
 

Private Types

typedef std::vector< std::string > ChildValues
 

Private Member Functions

bool hasCommentForValue (const Value &value)
 
void indent ()
 
bool isMultineArray (const Value &value)
 
void pushValue (const std::string &value)
 
void unindent ()
 
void writeArrayValue (const Value &value)
 
void writeCommentAfterValueOnSameLine (const Value &root)
 
void writeCommentBeforeValue (const Value &root)
 
void writeIndent ()
 
void writeValue (const Value &value)
 
void writeWithIndent (const std::string &value)
 

Static Private Member Functions

static std::string normalizeEOL (const std::string &text)
 

Private Attributes

bool addChildValues_
 
ChildValues childValues_
 
std::ostream * document_
 
std::string indentation_
 
std::string indentString_
 
int rightMargin_
 

Detailed Description

Writes a Value in JSON format in a human friendly way, to a stream rather than to a string.

The rules for line break and indent are as follow:

If the Value have comments then they are outputed according to their CommentPlacement.

Parameters
indentationEach level will be indented by this amount extra.
See also
Reader, Value, Value::setComment()

Definition at line 119 of file writer.h.

Member Typedef Documentation

◆ ChildValues

typedef std::vector<std::string> Json::StyledStreamWriter::ChildValues
private

Definition at line 146 of file writer.h.

Constructor & Destructor Documentation

◆ StyledStreamWriter()

Json::StyledStreamWriter::StyledStreamWriter ( )

◆ ~StyledStreamWriter()

Json::StyledStreamWriter::~StyledStreamWriter ( )
inline

Definition at line 122 of file writer.h.

122 {}

Member Function Documentation

◆ hasCommentForValue()

bool Json::StyledStreamWriter::hasCommentForValue ( const Value value)
private

◆ indent()

void Json::StyledStreamWriter::indent ( )
private

◆ isMultineArray()

bool Json::StyledStreamWriter::isMultineArray ( const Value value)
private

◆ normalizeEOL()

static std::string Json::StyledStreamWriter::normalizeEOL ( const std::string &  text)
staticprivate

◆ pushValue()

void Json::StyledStreamWriter::pushValue ( const std::string &  value)
private

◆ unindent()

void Json::StyledStreamWriter::unindent ( )
private

◆ write()

void Json::StyledStreamWriter::write ( std::ostream &  out,
const Value root 
)

Serialize a Value in JSON format.

Parameters
outStream to write to. (Can be ostringstream, e.g.)
rootValue to serialize.
Note
There is no point in deriving from Writer, since write() should not return a value.

Referenced by pkg.AbstractPkg::generate().

◆ writeArrayValue()

void Json::StyledStreamWriter::writeArrayValue ( const Value value)
private

◆ writeCommentAfterValueOnSameLine()

void Json::StyledStreamWriter::writeCommentAfterValueOnSameLine ( const Value root)
private

◆ writeCommentBeforeValue()

void Json::StyledStreamWriter::writeCommentBeforeValue ( const Value root)
private

◆ writeIndent()

void Json::StyledStreamWriter::writeIndent ( )
private

◆ writeValue()

void Json::StyledStreamWriter::writeValue ( const Value value)
private

◆ writeWithIndent()

void Json::StyledStreamWriter::writeWithIndent ( const std::string &  value)
private

Member Data Documentation

◆ addChildValues_

bool Json::StyledStreamWriter::addChildValues_
private

Definition at line 153 of file writer.h.

◆ childValues_

ChildValues Json::StyledStreamWriter::childValues_
private

Definition at line 148 of file writer.h.

◆ document_

std::ostream* Json::StyledStreamWriter::document_
private

Definition at line 149 of file writer.h.

◆ indentation_

std::string Json::StyledStreamWriter::indentation_
private

Definition at line 152 of file writer.h.

◆ indentString_

std::string Json::StyledStreamWriter::indentString_
private

Definition at line 150 of file writer.h.

◆ rightMargin_

int Json::StyledStreamWriter::rightMargin_
private

Definition at line 151 of file writer.h.