NIM PC Cross Platform SDK
载入中...
搜索中...
未找到
nim_cpp_wrapper_util::Json::StyledStreamWriter类 参考

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

#include <writer.h>

Public 成员函数

 StyledStreamWriter (String indentation="\t")
 
 ~StyledStreamWriter ()=default
 
void write (OStream &out, const Value &root)
 Serialize a Value in JSON format.
 

Private 类型

using ChildValues = std::vector< String >
 

Private 成员函数

void writeValue (const Value &value)
 
void writeArrayValue (const Value &value)
 
bool isMultilineArray (const Value &value)
 
void pushValue (const String &value)
 
void writeIndent ()
 
void writeWithIndent (const String &value)
 
void indent ()
 
void unindent ()
 
void writeCommentBeforeValue (const Value &root)
 
void writeCommentAfterValueOnSameLine (const Value &root)
 

静态 Private 成员函数

static bool hasCommentForValue (const Value &value)
 
static String normalizeEOL (const String &text)
 

Private 属性

ChildValues childValues_
 
OStreamdocument_
 
String indentString_
 
unsigned int rightMargin_ {74}
 
String indentation_
 
bool addChildValues_: 1
 
bool indented_: 1
 

详细描述

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:

  • Object value:
    • if empty then print {} without indent and line break
    • if not empty the print '{', line break & indent, print one value per line and then unindent and line break and print '}'.
  • Array value:
    • if empty then print [] without indent and line break
    • if the array contains no object value, empty array or some other value types, and all the values fit on one lines, then print the array on a single line.
    • otherwise, it the values do not fit on one line, or the array contains object or non empty array, then print one value per line.

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

参见
Reader, Value, Value::setComment()
弃用:
Use StreamWriterBuilder.

成员类型定义说明

◆ ChildValues

构造及析构函数说明

◆ StyledStreamWriter()

nim_cpp_wrapper_util::Json::StyledStreamWriter::StyledStreamWriter ( String  indentation = "\t")
参数
indentationEach level will be indented by this amount extra.

◆ ~StyledStreamWriter()

nim_cpp_wrapper_util::Json::StyledStreamWriter::~StyledStreamWriter ( )
default

成员函数说明

◆ hasCommentForValue()

bool nim_cpp_wrapper_util::Json::StyledStreamWriter::hasCommentForValue ( const Value value)
staticprivate

◆ indent()

void nim_cpp_wrapper_util::Json::StyledStreamWriter::indent ( )
private

◆ isMultilineArray()

bool nim_cpp_wrapper_util::Json::StyledStreamWriter::isMultilineArray ( const Value value)
private

◆ normalizeEOL()

static String nim_cpp_wrapper_util::Json::StyledStreamWriter::normalizeEOL ( const String text)
staticprivate

◆ pushValue()

void nim_cpp_wrapper_util::Json::StyledStreamWriter::pushValue ( const String value)
private

◆ unindent()

void nim_cpp_wrapper_util::Json::StyledStreamWriter::unindent ( )
private

◆ write()

void nim_cpp_wrapper_util::Json::StyledStreamWriter::write ( OStream out,
const Value root 
)

Serialize a Value in JSON format.

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

◆ writeArrayValue()

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

◆ writeCommentAfterValueOnSameLine()

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

◆ writeCommentBeforeValue()

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

◆ writeIndent()

void nim_cpp_wrapper_util::Json::StyledStreamWriter::writeIndent ( )
private

◆ writeValue()

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

◆ writeWithIndent()

void nim_cpp_wrapper_util::Json::StyledStreamWriter::writeWithIndent ( const String value)
private

类成员变量说明

◆ addChildValues_

bool nim_cpp_wrapper_util::Json::StyledStreamWriter::addChildValues_
private

◆ childValues_

ChildValues nim_cpp_wrapper_util::Json::StyledStreamWriter::childValues_
private

◆ document_

OStream* nim_cpp_wrapper_util::Json::StyledStreamWriter::document_
private

◆ indentation_

String nim_cpp_wrapper_util::Json::StyledStreamWriter::indentation_
private

◆ indented_

bool nim_cpp_wrapper_util::Json::StyledStreamWriter::indented_
private

◆ indentString_

String nim_cpp_wrapper_util::Json::StyledStreamWriter::indentString_
private

◆ rightMargin_

unsigned int nim_cpp_wrapper_util::Json::StyledStreamWriter::rightMargin_ {74}
private

该类的文档由以下文件生成: