CMS 3D CMS Logo

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

Writes a Value in JSON format in a human friendly way. More...

#include <writer.h>

Inheritance diagram for Json::StyledWriter:
Json::Writer

Public Member Functions

 StyledWriter ()
 
std::string write (const Value &root) override
 Serialize a Value in JSON format. More...
 
 ~StyledWriter () override
 
- Public Member Functions inherited from Json::Writer
virtual ~Writer ()
 

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::string document_
 
int indentSize_
 
std::string indentString_
 
int rightMargin_
 

Detailed Description

Writes a Value in JSON format in a human friendly way.

The rules for line break and indent are as follow:

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

See also
Reader, Value, Value::setComment()

Definition at line 63 of file writer.h.

Member Typedef Documentation

◆ ChildValues

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

Definition at line 89 of file writer.h.

Constructor & Destructor Documentation

◆ StyledWriter()

Json::StyledWriter::StyledWriter ( )

◆ ~StyledWriter()

Json::StyledWriter::~StyledWriter ( )
inlineoverride

Definition at line 66 of file writer.h.

66 {}

Member Function Documentation

◆ hasCommentForValue()

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

◆ indent()

void Json::StyledWriter::indent ( )
private

◆ isMultineArray()

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

◆ normalizeEOL()

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

◆ pushValue()

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

◆ unindent()

void Json::StyledWriter::unindent ( )
private

◆ write()

std::string Json::StyledWriter::write ( const Value root)
overridevirtual

Serialize a Value in JSON format.

Parameters
rootValue to serialize.
Returns
String containing the JSON document that represents the root value.

Implements Json::Writer.

Referenced by pkg.AbstractPkg::generate().

◆ writeArrayValue()

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

◆ writeCommentAfterValueOnSameLine()

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

◆ writeCommentBeforeValue()

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

◆ writeIndent()

void Json::StyledWriter::writeIndent ( )
private

◆ writeValue()

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

◆ writeWithIndent()

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

Member Data Documentation

◆ addChildValues_

bool Json::StyledWriter::addChildValues_
private

Definition at line 96 of file writer.h.

◆ childValues_

ChildValues Json::StyledWriter::childValues_
private

Definition at line 91 of file writer.h.

◆ document_

std::string Json::StyledWriter::document_
private

Definition at line 92 of file writer.h.

◆ indentSize_

int Json::StyledWriter::indentSize_
private

Definition at line 95 of file writer.h.

◆ indentString_

std::string Json::StyledWriter::indentString_
private

Definition at line 93 of file writer.h.

◆ rightMargin_

int Json::StyledWriter::rightMargin_
private

Definition at line 94 of file writer.h.