PrettyWriter

Engine/source/persistence/rapidjson/prettywriter.h

Writer with indentation and spacing.

More...

Convenience extensions

bool
String(const Ch * str)

Simpler but slower overload.

bool
Key(const Ch * str)
bool
RawValue(const Ch * json, size_t length, Type type)

Write a raw JSON value.

Implementation of Handler

see:

Handler

bool
Null()
bool
Bool(bool b)
bool
Int(int i)
bool
Uint(unsigned u)
bool
bool
bool
Double(double d)
bool
RawNumber(const Ch * str, SizeType length, bool copy)
bool
String(const Ch * str, SizeType length, bool copy)
bool
bool
Key(const Ch * str, SizeType length, bool copy)
bool
EndObject(SizeType memberCount)
bool
bool
EndArray(SizeType memberCount)

Public Types

Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >
Base 

Public Functions

PrettyWriter(OutputStream & os, StackAllocator * allocator, size_t levelDepth)

Constructor.

PrettyWriter(StackAllocator * allocator, size_t levelDepth)

Set pretty writer formatting options.

SetIndent(Ch indentChar, unsigned indentCharCount)

Set custom indentation.

Detailed Description

Writer with indentation and spacing.

Parameters:

OutputStream

Type of output os.

SourceEncoding

Encoding of source string.

TargetEncoding

Encoding of output stream.

StackAllocator

Type of allocator for allocating memory of stack.

Convenience extensions

String(const Ch * str)

Simpler but slower overload.

Key(const Ch * str)

RawValue(const Ch * json, size_t length, Type type)

Write a raw JSON value.

For user to write a stringified JSON as a value.

Parameters:

json

A well-formed JSON value. It should not contain null character within [0, length - 1] range.

length

Length of the json.

type

Type of the root of json.

note:

When using PrettyWriter::RawValue(), the result json may not be indented correctly.

PrettyPrefix(Type type)

WriteIndent()

PrettyWriter(const PrettyWriter & )

operator=(const PrettyWriter & )

Ch indentChar_ 
unsigned indentCharCount_ 
PrettyFormatOptions formatOptions_ 

Implementation of Handler

see:

Handler

Null()

Bool(bool b)

Int(int i)

Uint(unsigned u)

Int64(int64_t i64)

Uint64(uint64_t u64)

Double(double d)

RawNumber(const Ch * str, SizeType length, bool copy)

String(const Ch * str, SizeType length, bool copy)

StartObject()

Key(const Ch * str, SizeType length, bool copy)

EndObject(SizeType memberCount)

StartArray()

EndArray(SizeType memberCount)

Public Types

typedef Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > Base 
typedef Base::Ch Ch 

Public Functions

PrettyWriter(OutputStream & os, StackAllocator * allocator, size_t levelDepth)

Constructor.

Parameters:

os

Output stream.

allocator

User supplied allocator. If it is null, it will create a private one.

levelDepth

Initial capacity of stack.

PrettyWriter(StackAllocator * allocator, size_t levelDepth)

SetFormatOptions(PrettyFormatOptions options)

Set pretty writer formatting options.

Parameters:

options

Formatting options.

SetIndent(Ch indentChar, unsigned indentCharCount)

Set custom indentation.

Parameters:

indentChar

Character for indentation. Must be whitespace character (' ', '\t', '\n', '\r').

indentCharCount

Number of indent characters for each indentation level.

note:

The default indentation is 4 spaces.