Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > Class Template Reference

Writer with indentation and spacing. More...

#include </__w/arcaneframework.github.io/arcaneframework.github.io/framework/arccore/src/common/arccore/common/internal/json/rapidjson/prettywriter.h>

Inheritance diagram for PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >:
Collaboration diagram for PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >:

Public Types

typedef Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > Base
typedef Base::Ch Ch
Public Types inherited from Writer< OutputStream, UTF8<>, UTF8<>, CrtAllocator, kWriteDefaultFlags >
typedef UTF8<>::Ch Ch

Public Member Functions

 PrettyWriter (OutputStream &os, StackAllocator *allocator=0, size_t levelDepth=Base::kDefaultLevelDepth)
 Constructor.
 PrettyWriter (StackAllocator *allocator=0, size_t levelDepth=Base::kDefaultLevelDepth)
PrettyWriterSetIndent (Ch indentChar, unsigned indentCharCount)
 Set custom indentation.
PrettyWriterSetFormatOptions (PrettyFormatOptions options)
 Set pretty writer formatting options.
Implementation of Handler
See also
Handler
bool Null ()
bool Bool (bool b)
bool Int (int i)
bool Uint (unsigned u)
bool Int64 (int64_t i64)
bool Uint64 (uint64_t u64)
bool Double (double d)
bool RawNumber (const Ch *str, SizeType length, bool copy=false)
bool String (const Ch *str, SizeType length, bool copy=false)
bool StartObject ()
bool Key (const Ch *str, SizeType length, bool copy=false)
bool EndObject (SizeType memberCount=0)
bool StartArray ()
bool EndArray (SizeType memberCount=0)
Public Member Functions inherited from Writer< OutputStream, UTF8<>, UTF8<>, CrtAllocator, kWriteDefaultFlags >
 Writer (OutputStream &os, CrtAllocator *stackAllocator=0, size_t levelDepth=kDefaultLevelDepth)
 Constructor.
void Reset (OutputStream &os)
 Reset the writer with a new stream.
bool IsComplete () const
 Checks whether the output is a complete JSON.
int GetMaxDecimalPlaces () const
void SetMaxDecimalPlaces (int maxDecimalPlaces)
 Sets the maximum number of decimal places for double output.
bool Null ()
bool Bool (bool b)
bool Int (int i)
bool Uint (unsigned u)
bool Int64 (int64_t i64)
bool Uint64 (uint64_t u64)
bool Double (double d)
 Writes the given double value to the stream.
bool RawNumber (const Ch *str, SizeType length, bool copy=false)
bool String (const Ch *str, SizeType length, bool copy=false)
bool StartObject ()
bool Key (const Ch *str, SizeType length, bool copy=false)
bool EndObject (SizeType memberCount=0)
bool StartArray ()
bool EndArray (SizeType elementCount=0)
bool RawValue (const Ch *json, size_t length, Type type)
 Write a raw JSON value.
void Flush ()
 Flush the output stream.

Convenience extensions

Ch indentChar_
unsigned indentCharCount_
PrettyFormatOptions formatOptions_
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.
void PrettyPrefix (Type type)
void WriteIndent ()
 PrettyWriter (const PrettyWriter &)
PrettyWriteroperator= (const PrettyWriter &)

Additional Inherited Members

Static Public Attributes inherited from Writer< OutputStream, UTF8<>, UTF8<>, CrtAllocator, kWriteDefaultFlags >
static const int kDefaultMaxDecimalPlaces
static const size_t kDefaultLevelDepth
Protected Member Functions inherited from Writer< OutputStream, UTF8<>, UTF8<>, CrtAllocator, kWriteDefaultFlags >
bool WriteInt (int i)
bool WriteUint (unsigned u)
bool WriteInt64 (int64_t i64)
bool WriteUint64 (uint64_t u)
bool WriteDouble (double d)
bool WriteNull ()
bool WriteBool (bool b)
bool WriteString (const Ch *str, SizeType length)
bool ScanWriteUnescapedString (GenericStringStream< UTF8<> > &is, size_t length)
bool WriteStartObject ()
bool WriteEndObject ()
bool WriteStartArray ()
bool WriteEndArray ()
bool WriteRawValue (const Ch *json, size_t length)
void Prefix (Type type)
bool EndValue (bool ret)
OutputStream * os_
internal::Stack< CrtAllocatorlevel_stack_
int maxDecimalPlaces_
bool hasRoot_

Detailed Description

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
class PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >

Writer with indentation and spacing.

Template Parameters
OutputStreamType of output os.
SourceEncodingEncoding of source string.
TargetEncodingEncoding of output stream.
StackAllocatorType of allocator for allocating memory of stack.

Definition at line 49 of file prettywriter.h.

Member Typedef Documentation

◆ Base

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
typedef Writer<OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags> PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Base

Definition at line 51 of file prettywriter.h.

◆ Ch

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
typedef Base::Ch PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Ch

Definition at line 52 of file prettywriter.h.

Constructor & Destructor Documentation

◆ PrettyWriter() [1/2]

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::PrettyWriter ( OutputStream & os,
StackAllocator * allocator = 0,
size_t levelDepth = Base::kDefaultLevelDepth )
inlineexplicit

Constructor.

Parameters
osOutput stream.
allocatorUser supplied allocator. If it is null, it will create a private one.
levelDepthInitial capacity of stack.

Definition at line 59 of file prettywriter.h.

Referenced by SetFormatOptions(), and SetIndent().

Here is the caller graph for this function:

◆ PrettyWriter() [2/2]

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::PrettyWriter ( StackAllocator * allocator = 0,
size_t levelDepth = Base::kDefaultLevelDepth )
inlineexplicit

Definition at line 63 of file prettywriter.h.

Member Function Documentation

◆ Bool()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Bool ( bool b)
inline

Definition at line 97 of file prettywriter.h.

◆ Double()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Double ( double d)
inline

Definition at line 102 of file prettywriter.h.

◆ EndArray()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::EndArray ( SizeType memberCount = 0)
inline

Definition at line 164 of file prettywriter.h.

◆ EndObject()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::EndObject ( SizeType memberCount = 0)
inline

Definition at line 138 of file prettywriter.h.

◆ Int()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Int ( int i)
inline

Definition at line 98 of file prettywriter.h.

◆ Int64()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Int64 ( int64_t i64)
inline

Definition at line 100 of file prettywriter.h.

◆ Key() [1/2]

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Key ( const Ch * str)
inline

Definition at line 189 of file prettywriter.h.

◆ Key() [2/2]

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Key ( const Ch * str,
SizeType length,
bool copy = false )
inline

Definition at line 130 of file prettywriter.h.

◆ Null()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Null ( )
inline

Definition at line 96 of file prettywriter.h.

◆ PrettyPrefix()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
void PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::PrettyPrefix ( Type type)
inlineprotected

Definition at line 209 of file prettywriter.h.

◆ RawNumber()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::RawNumber ( const Ch * str,
SizeType length,
bool copy = false )
inline

Definition at line 104 of file prettywriter.h.

◆ RawValue()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::RawValue ( const Ch * json,
size_t length,
Type type )
inline

Write a raw JSON value.

For user to write a stringified JSON as a value.

Parameters
jsonA well-formed JSON value. It should not contain null character within [0, length - 1] range.
lengthLength of the json.
typeType of the root of json.
Note
When using PrettyWriter::RawValue(), the result json may not be indented correctly.

Definition at line 202 of file prettywriter.h.

References RAPIDJSON_ASSERT.

◆ SetFormatOptions()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
PrettyWriter & PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::SetFormatOptions ( PrettyFormatOptions options)
inline

Set pretty writer formatting options.

Parameters
optionsFormatting options.

Definition at line 86 of file prettywriter.h.

References PrettyWriter().

Here is the call graph for this function:

◆ SetIndent()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
PrettyWriter & PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::SetIndent ( Ch indentChar,
unsigned indentCharCount )
inline

Set custom indentation.

Parameters
indentCharCharacter for indentation. Must be whitespace character (' ', '\t', '\n', '\r').
indentCharCountNumber of indent characters for each indentation level.
Note
The default indentation is 4 spaces.

Definition at line 76 of file prettywriter.h.

References PrettyWriter(), and RAPIDJSON_ASSERT.

Here is the call graph for this function:

◆ StartArray()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::StartArray ( )
inline

Definition at line 158 of file prettywriter.h.

◆ StartObject()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::StartObject ( )
inline

Definition at line 124 of file prettywriter.h.

◆ String() [1/2]

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::String ( const Ch * str)
inline

Simpler but slower overload.

Definition at line 188 of file prettywriter.h.

References String().

Referenced by String().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ String() [2/2]

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::String ( const Ch * str,
SizeType length,
bool copy = false )
inline

Definition at line 111 of file prettywriter.h.

◆ Uint()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Uint ( unsigned u)
inline

Definition at line 99 of file prettywriter.h.

◆ Uint64()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
bool PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::Uint64 ( uint64_t u64)
inline

Definition at line 101 of file prettywriter.h.

◆ WriteIndent()

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
void PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::WriteIndent ( )
inlineprotected

Definition at line 253 of file prettywriter.h.

Member Data Documentation

◆ formatOptions_

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
PrettyFormatOptions PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::formatOptions_
protected

Definition at line 260 of file prettywriter.h.

◆ indentChar_

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
Ch PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::indentChar_
protected

Definition at line 258 of file prettywriter.h.

◆ indentCharCount_

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
unsigned PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::indentCharCount_
protected

Definition at line 259 of file prettywriter.h.


The documentation for this class was generated from the following files: