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

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

Collaboration diagram for Json::StyledStreamWriter:
Collaboration graph
[legend]

Public Member Functions

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

Private Types

using ChildValues = std::vector< std::string >
 

Private Member Functions

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

Private Attributes

ChildValues childValues_
 
std::ostreamdocument_
 
std::string indentString_
 
int rightMargin_
 
std::string indentation_
 
bool addChildValues_
 

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:

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

Definition at line 154 of file json_writer.h.

Member Typedef Documentation

◆ ChildValues

Definition at line 190 of file json_writer.h.

Constructor & Destructor Documentation

◆ StyledStreamWriter()

Json::StyledStreamWriter::StyledStreamWriter ( std::string  indentation = "\t")

Definition at line 493 of file json_writer.cpp.

◆ ~StyledStreamWriter()

Json::StyledStreamWriter::~StyledStreamWriter ( )

Definition at line 158 of file json_writer.h.

Member Function Documentation

◆ 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.

Definition at line 499 of file json_writer.cpp.

◆ writeValue()

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

Definition at line 510 of file json_writer.cpp.

◆ writeArrayValue()

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

Definition at line 576 of file json_writer.cpp.

◆ isMultineArray()

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

Definition at line 633 of file json_writer.cpp.

◆ pushValue()

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

Definition at line 667 of file json_writer.cpp.

◆ writeIndent()

void Json::StyledStreamWriter::writeIndent ( )
private

Definition at line 676 of file json_writer.cpp.

◆ writeWithIndent()

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

Definition at line 694 of file json_writer.cpp.

◆ indent()

void Json::StyledStreamWriter::indent ( )
private

Definition at line 701 of file json_writer.cpp.

◆ unindent()

void Json::StyledStreamWriter::unindent ( )
private

Definition at line 707 of file json_writer.cpp.

Member Data Documentation

◆ childValues_

ChildValues Json::StyledStreamWriter::childValues_
private

Definition at line 192 of file json_writer.h.

◆ document_

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

Definition at line 193 of file json_writer.h.

◆ indentString_

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

Definition at line 194 of file json_writer.h.

◆ rightMargin_

int Json::StyledStreamWriter::rightMargin_
private

Definition at line 195 of file json_writer.h.

◆ indentation_

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

Definition at line 196 of file json_writer.h.

◆ addChildValues_

bool Json::StyledStreamWriter::addChildValues_
private

Definition at line 197 of file json_writer.h.