rippled
Loading...
Searching...
No Matches
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...

#include <json_writer.h>

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

Public Member Functions

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

Private Types

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

Private Member Functions

void writeValue (Value const &value)
 
void writeArrayValue (Value const &value)
 
bool isMultineArray (Value const &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 136 of file json_writer.h.

Member Typedef Documentation

◆ ChildValues

Definition at line 172 of file json_writer.h.

Constructor & Destructor Documentation

◆ StyledStreamWriter()

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

Definition at line 485 of file json_writer.cpp.

◆ ~StyledStreamWriter()

Json::StyledStreamWriter::~StyledStreamWriter ( )

Definition at line 140 of file json_writer.h.

Member Function Documentation

◆ write()

void Json::StyledStreamWriter::write ( std::ostream out,
Value const &  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 491 of file json_writer.cpp.

◆ writeValue()

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

Definition at line 502 of file json_writer.cpp.

◆ writeArrayValue()

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

Definition at line 568 of file json_writer.cpp.

◆ isMultineArray()

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

Definition at line 627 of file json_writer.cpp.

◆ pushValue()

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

Definition at line 661 of file json_writer.cpp.

◆ writeIndent()

void Json::StyledStreamWriter::writeIndent ( )
private

Definition at line 670 of file json_writer.cpp.

◆ writeWithIndent()

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

Definition at line 688 of file json_writer.cpp.

◆ indent()

void Json::StyledStreamWriter::indent ( )
private

Definition at line 695 of file json_writer.cpp.

◆ unindent()

void Json::StyledStreamWriter::unindent ( )
private

Definition at line 701 of file json_writer.cpp.

Member Data Documentation

◆ childValues_

ChildValues Json::StyledStreamWriter::childValues_
private

Definition at line 174 of file json_writer.h.

◆ document_

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

Definition at line 175 of file json_writer.h.

◆ indentString_

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

Definition at line 176 of file json_writer.h.

◆ rightMargin_

int Json::StyledStreamWriter::rightMargin_
private

Definition at line 177 of file json_writer.h.

◆ indentation_

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

Definition at line 178 of file json_writer.h.

◆ addChildValues_

bool Json::StyledStreamWriter::addChildValues_
private

Definition at line 179 of file json_writer.h.