Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > Class Template Reference

Writer with indentation and spacing. More...

#include <fwd.h>

Inheritance diagram for PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >:
Writer< 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, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >
typedef SourceEncoding::Ch Ch
 

Public Member Functions

 PrettyWriter (OutputStream &os, StackAllocator *allocator=0, size_t levelDepth=Base::kDefaultLevelDepth)
 Constructor. More...
 
 PrettyWriter (StackAllocator *allocator=0, size_t levelDepth=Base::kDefaultLevelDepth)
 
PrettyWriterSetIndent (Ch indentChar, unsigned indentCharCount)
 Set custom indentation. More...
 
PrettyWriterSetFormatOptions (PrettyFormatOptions options)
 Set pretty writer formatting options. More...
 
bool RawValue (const Ch *json, size_t length, Type type)
 Write a raw JSON value. More...
 
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)
 
Convenience extensions
bool String (const Ch *str)
 Simpler but slower overload. More...
 
bool Key (const Ch *str)
 
- Public Member Functions inherited from Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >
 Writer (OutputStream &os, StackAllocator *stackAllocator=0, size_t levelDepth=kDefaultLevelDepth)
 Constructor. More...
 
 Writer (StackAllocator *allocator=0, size_t levelDepth=kDefaultLevelDepth)
 
void Reset (OutputStream &os)
 Reset the writer with a new stream. More...
 
bool IsComplete () const
 Checks whether the output is a complete JSON. More...
 
int GetMaxDecimalPlaces () const
 
void SetMaxDecimalPlaces (int maxDecimalPlaces)
 Sets the maximum number of decimal places for double output. More...
 
bool RawValue (const Ch *json, size_t length, Type type)
 Write a raw JSON value. More...
 
void Flush ()
 Flush the output stream. More...
 
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. More...
 
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 String (const Ch *const &str)
 Simpler but slower overload. More...
 
bool Key (const Ch *const &str)
 

Protected Member Functions

void PrettyPrefix (Type type)
 
void WriteIndent ()
 
- Protected Member Functions inherited from Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >
bool WriteNull ()
 
bool WriteBool (bool b)
 
bool WriteInt (int i)
 
bool WriteUint (unsigned u)
 
bool WriteInt64 (int64_t i64)
 
bool WriteUint64 (uint64_t u64)
 
bool WriteDouble (double d)
 
bool WriteString (const Ch *str, SizeType length)
 
bool ScanWriteUnescapedString (GenericStringStream< SourceEncoding > &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)
 
template<>
bool WriteInt (int i)
 
template<>
bool WriteUint (unsigned u)
 
template<>
bool WriteInt64 (int64_t i64)
 
template<>
bool WriteUint64 (uint64_t u)
 
template<>
bool WriteDouble (double d)
 

Protected Attributes

Ch indentChar_
 
unsigned indentCharCount_
 
PrettyFormatOptions formatOptions_
 
- Protected Attributes inherited from Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >
OutputStream * os_
 
internal::Stack< StackAllocator > level_stack_
 
int maxDecimalPlaces_
 
bool hasRoot_
 

Private Member Functions

 PrettyWriter (const PrettyWriter &)
 
PrettyWriteroperator= (const PrettyWriter &)
 

Additional Inherited Members

- Static Public Attributes inherited from Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >
static const int kDefaultMaxDecimalPlaces = 324
 
- Static Protected Attributes inherited from Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >
static const size_t kDefaultLevelDepth = 32
 

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 100 of file fwd.h.

Member Typedef Documentation

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 50 of file prettywriter.h.

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 51 of file prettywriter.h.

Constructor & Destructor Documentation

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 58 of file prettywriter.h.

58  :
59  Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4), formatOptions_(kFormatDefault) {}
unsigned indentCharCount_
Definition: prettywriter.h:258
PrettyFormatOptions formatOptions_
Definition: prettywriter.h:259
Default pretty formatting.
Definition: prettywriter.h:36
Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > Base
Definition: prettywriter.h:50
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 62 of file prettywriter.h.

62  :
63  Base(allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
unsigned indentCharCount_
Definition: prettywriter.h:258
Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > Base
Definition: prettywriter.h:50
template<typename OutputStream , typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::PrettyWriter ( const PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > &  )
private

Member Function Documentation

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 96 of file prettywriter.h.

bool EndValue(bool ret)
Definition: writer.h:494
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
false
Definition: rapidjson.h:620
static bool * b
Definition: config.cpp:1043
true
Definition: rapidjson.h:621
bool WriteBool(bool b)
Definition: writer.h:300
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 101 of file prettywriter.h.

bool EndValue(bool ret)
Definition: writer.h:494
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
number
Definition: rapidjson.h:625
bool WriteDouble(double d)
Definition: writer.h:348
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 163 of file prettywriter.h.

163  {
164  (void)memberCount;
165  RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));
166  RAPIDJSON_ASSERT(Base::level_stack_.template Top<typename Base::Level>()->inArray);
167  bool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;
168 
169  if (!empty && !(formatOptions_ & kFormatSingleLineArray)) {
170  Base::os_->Put('\n');
171  WriteIndent();
172  }
173  bool ret = Base::EndValue(Base::WriteEndArray());
174  (void)ret;
175  RAPIDJSON_ASSERT(ret == true);
176  if (Base::level_stack_.Empty()) // end of json text
177  Base::Flush();
178  return true;
179  }
bool EndValue(bool ret)
Definition: writer.h:494
void WriteIndent()
Definition: prettywriter.h:252
void Flush()
Flush the output stream.
Definition: writer.h:281
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
PrettyFormatOptions formatOptions_
Definition: prettywriter.h:259
Level
Definition: Level.h:13
OutputStream * os_
Definition: writer.h:500
bool WriteEndArray()
Definition: writer.h:457
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:501
Format arrays on a single line.
Definition: prettywriter.h:37
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
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 137 of file prettywriter.h.

137  {
138  (void)memberCount;
139  RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); // not inside an Object
140  RAPIDJSON_ASSERT(!Base::level_stack_.template Top<typename Base::Level>()->inArray); // currently inside an Array, not Object
141  RAPIDJSON_ASSERT(0 == Base::level_stack_.template Top<typename Base::Level>()->valueCount % 2); // Object has a Key without a Value
142 
143  bool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;
144 
145  if (!empty) {
146  Base::os_->Put('\n');
147  WriteIndent();
148  }
149  bool ret = Base::EndValue(Base::WriteEndObject());
150  (void)ret;
151  RAPIDJSON_ASSERT(ret == true);
152  if (Base::level_stack_.Empty()) // end of json text
153  Base::Flush();
154  return true;
155  }
bool EndValue(bool ret)
Definition: writer.h:494
void WriteIndent()
Definition: prettywriter.h:252
void Flush()
Flush the output stream.
Definition: writer.h:281
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Level
Definition: Level.h:13
OutputStream * os_
Definition: writer.h:500
bool WriteEndObject()
Definition: writer.h:455
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:501
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
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 97 of file prettywriter.h.

bool EndValue(bool ret)
Definition: writer.h:494
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
number
Definition: rapidjson.h:625
bool WriteInt(int i)
Definition: writer.h:312
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 99 of file prettywriter.h.

bool EndValue(bool ret)
Definition: writer.h:494
bool WriteInt64(int64_t i64)
Definition: writer.h:330
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
number
Definition: rapidjson.h:625
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 129 of file prettywriter.h.

129 { return String(str, length, copy); }
T copy(T const &v)
bool String(const Ch *str, SizeType length, bool copy=false)
Definition: prettywriter.h:110
static QCString str
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 188 of file prettywriter.h.

188 { return Key(str, internal::StrLen(str)); }
bool Key(const Ch *str, SizeType length, bool copy=false)
Definition: prettywriter.h:129
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:31
static QCString str
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 95 of file prettywriter.h.

bool EndValue(bool ret)
Definition: writer.h:494
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
bool WriteNull()
Definition: writer.h:295
null
Definition: rapidjson.h:619
template<typename OutputStream , typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
PrettyWriter& PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags >::operator= ( const PrettyWriter< OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags > &  )
private
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 208 of file prettywriter.h.

208  {
209  (void)type;
210  if (Base::level_stack_.GetSize() != 0) { // this value is not at root
211  typename Base::Level* level = Base::level_stack_.template Top<typename Base::Level>();
212 
213  if (level->inArray) {
214  if (level->valueCount > 0) {
215  Base::os_->Put(','); // add comma if it is not the first element in array
217  Base::os_->Put(' ');
218  }
219 
220  if (!(formatOptions_ & kFormatSingleLineArray)) {
221  Base::os_->Put('\n');
222  WriteIndent();
223  }
224  }
225  else { // in object
226  if (level->valueCount > 0) {
227  if (level->valueCount % 2 == 0) {
228  Base::os_->Put(',');
229  Base::os_->Put('\n');
230  }
231  else {
232  Base::os_->Put(':');
233  Base::os_->Put(' ');
234  }
235  }
236  else
237  Base::os_->Put('\n');
238 
239  if (level->valueCount % 2 == 0)
240  WriteIndent();
241  }
242  if (!level->inArray && level->valueCount % 2 == 0)
243  RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name
244  level->valueCount++;
245  }
246  else {
247  RAPIDJSON_ASSERT(!Base::hasRoot_); // Should only has one and only one root.
248  Base::hasRoot_ = true;
249  }
250  }
void WriteIndent()
Definition: prettywriter.h:252
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
PrettyFormatOptions formatOptions_
Definition: prettywriter.h:259
Level
Definition: Level.h:13
bool hasRoot_
Definition: writer.h:503
OutputStream * os_
Definition: writer.h:500
string
Definition: rapidjson.h:624
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:501
Format arrays on a single line.
Definition: prettywriter.h:37
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 103 of file prettywriter.h.

103  {
104  RAPIDJSON_ASSERT(str != 0);
105  (void)copy;
107  return Base::EndValue(Base::WriteString(str, length));
108  }
bool EndValue(bool ret)
Definition: writer.h:494
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
number
Definition: rapidjson.h:625
bool WriteString(const Ch *str, SizeType length)
Definition: writer.h:376
T copy(T const &v)
static QCString str
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 201 of file prettywriter.h.

201  {
202  RAPIDJSON_ASSERT(json != 0);
204  return Base::EndValue(Base::WriteRawValue(json, length));
205  }
bool EndValue(bool ret)
Definition: writer.h:494
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
bool WriteRawValue(const Ch *json, size_t length)
Definition: writer.h:459
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 85 of file prettywriter.h.

85  {
87  return *this;
88  }
PrettyFormatOptions formatOptions_
Definition: prettywriter.h:259
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 75 of file prettywriter.h.

75  {
76  RAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\t' || indentChar == '\n' || indentChar == '\r');
77  indentChar_ = indentChar;
78  indentCharCount_ = indentCharCount;
79  return *this;
80  }
unsigned indentCharCount_
Definition: prettywriter.h:258
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
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 157 of file prettywriter.h.

157  {
159  new (Base::level_stack_.template Push<typename Base::Level>()) typename Base::Level(true);
160  return Base::WriteStartArray();
161  }
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
array
Definition: rapidjson.h:623
Level
Definition: Level.h:13
bool WriteStartArray()
Definition: writer.h:456
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:501
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 123 of file prettywriter.h.

123  {
125  new (Base::level_stack_.template Push<typename Base::Level>()) typename Base::Level(false);
126  return Base::WriteStartObject();
127  }
object
Definition: rapidjson.h:622
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
Level
Definition: Level.h:13
bool WriteStartObject()
Definition: writer.h:454
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:501
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 110 of file prettywriter.h.

110  {
111  RAPIDJSON_ASSERT(str != 0);
112  (void)copy;
114  return Base::EndValue(Base::WriteString(str, length));
115  }
bool EndValue(bool ret)
Definition: writer.h:494
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
string
Definition: rapidjson.h:624
bool WriteString(const Ch *str, SizeType length)
Definition: writer.h:376
T copy(T const &v)
static QCString str
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 187 of file prettywriter.h.

187 { return String(str, internal::StrLen(str)); }
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:31
bool String(const Ch *str, SizeType length, bool copy=false)
Definition: prettywriter.h:110
static QCString str
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 98 of file prettywriter.h.

bool EndValue(bool ret)
Definition: writer.h:494
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
bool WriteUint(unsigned u)
Definition: writer.h:321
number
Definition: rapidjson.h:625
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 100 of file prettywriter.h.

bool EndValue(bool ret)
Definition: writer.h:494
void PrettyPrefix(Type type)
Definition: prettywriter.h:208
bool WriteUint64(uint64_t u64)
Definition: writer.h:339
number
Definition: rapidjson.h:625
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 252 of file prettywriter.h.

252  {
253  size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_;
254  PutN(*Base::os_, static_cast<typename OutputStream::Ch>(indentChar_), count);
255  }
unsigned indentCharCount_
Definition: prettywriter.h:258
void PutN(FileWriteStream &stream, char c, size_t n)
Implement specialized version of PutN() with memset() for better performance.
Level
Definition: Level.h:13
OutputStream * os_
Definition: writer.h:500
size_t GetSize() const
Definition: stack.h:177
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:501

Member Data Documentation

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 259 of file prettywriter.h.

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 257 of file prettywriter.h.

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 258 of file prettywriter.h.


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