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

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

#include <writer.h>

类 nim_cpp_wrapper_util::Json::StyledWriter 继承关系图:
nim_cpp_wrapper_util::Json::Writer

Public 成员函数

 StyledWriter ()
 
 ~StyledWriter () override=default
 
String write (const Value &root) override
 Serialize a Value in JSON format.
 
- Public 成员函数 继承自 nim_cpp_wrapper_util::Json::Writer
virtual ~Writer ()
 
virtual String write (const Value &root)=0
 

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_
 
String document_
 
String indentString_
 
unsigned int rightMargin_ {74}
 
unsigned int indentSize_ {3}
 
bool addChildValues_ {false}
 

详细描述

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

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

构造及析构函数说明

◆ StyledWriter()

nim_cpp_wrapper_util::Json::StyledWriter::StyledWriter ( )
default

◆ ~StyledWriter()

nim_cpp_wrapper_util::Json::StyledWriter::~StyledWriter ( )
overridedefault

成员函数说明

◆ hasCommentForValue()

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

◆ indent()

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

◆ isMultilineArray()

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

◆ normalizeEOL()

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

◆ pushValue()

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

◆ unindent()

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

◆ write()

String nim_cpp_wrapper_util::Json::StyledWriter::write ( const Value root)
overridevirtual

Serialize a Value in JSON format.

参数
rootValue to serialize.
返回
String containing the JSON document that represents the root value.

实现了 nim_cpp_wrapper_util::Json::Writer.

◆ writeArrayValue()

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

◆ writeCommentAfterValueOnSameLine()

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

◆ writeCommentBeforeValue()

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

◆ writeIndent()

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

◆ writeValue()

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

◆ writeWithIndent()

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

类成员变量说明

◆ addChildValues_

bool nim_cpp_wrapper_util::Json::StyledWriter::addChildValues_ {false}
private

◆ childValues_

ChildValues nim_cpp_wrapper_util::Json::StyledWriter::childValues_
private

◆ document_

String nim_cpp_wrapper_util::Json::StyledWriter::document_
private

◆ indentSize_

unsigned int nim_cpp_wrapper_util::Json::StyledWriter::indentSize_ {3}
private

◆ indentString_

String nim_cpp_wrapper_util::Json::StyledWriter::indentString_
private

◆ rightMargin_

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

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