15 #ifndef RAPIDJSON_PRETTYWRITER_H_
16 #define RAPIDJSON_PRETTYWRITER_H_
22 RAPIDJSON_DIAG_OFF(effc++)
34 template<
typename OutputStream,
typename SourceEncoding = UTF8<>,
typename TargetEncoding = UTF8<>,
typename StackAllocator = CrtAllocator>
35 class PrettyWriter :
public Writer<OutputStream, SourceEncoding, TargetEncoding, StackAllocator> {
54 RAPIDJSON_ASSERT(indentChar ==
' ' || indentChar ==
'\t' || indentChar ==
'\n' || indentChar ==
'\r');
79 #if RAPIDJSON_HAS_STDSTRING
80 bool String(
const std::basic_string<Ch>& str) {
97 bool empty =
Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;
121 bool empty =
Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;
207 #endif // RAPIDJSON_RAPIDJSON_H_
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:322
bool WriteInt(int i)
Definition: writer.h:204
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
JSON writer.
Definition: writer.h:54
object
Definition: rapidjson.h:646
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
void PutN(FileWriteStream &stream, char c, size_t n)
Implement specialized version of PutN() with memset() for better performance.
Definition: filewritestream.h:85
array
Definition: rapidjson.h:647
Ch indentChar_
Definition: prettywriter.h:192
bool StartObject()
Definition: prettywriter.h:85
PrettyWriter & operator=(const PrettyWriter &)
bool WriteStartArray()
Definition: writer.h:314
static const size_t kDefaultLevelDepth
Definition: writer.h:188
Base::Ch Ch
Definition: prettywriter.h:38
false
Definition: rapidjson.h:644
size_t valueCount
number of values in this level
Definition: writer.h:184
bool EndArray(SizeType memberCount=0)
Definition: prettywriter.h:117
bool String(const Ch *str, SizeType length, bool copy=false)
Definition: prettywriter.h:73
bool WriteBool(bool b)
Definition: writer.h:194
signed __int64 int64_t
Definition: stdint.h:89
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator > Base
Definition: prettywriter.h:37
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:338
bool StartArray()
Definition: prettywriter.h:111
Information for each nested level.
Definition: writer.h:182
bool WriteEndArray()
Definition: writer.h:315
void WriteIndent()
Definition: prettywriter.h:187
bool Key(const Ch *str)
Definition: prettywriter.h:142
SourceEncoding::Ch Ch
Definition: writer.h:56
string
Definition: rapidjson.h:648
bool hasRoot_
Definition: writer.h:339
bool WriteDouble(double d)
Definition: writer.h:236
bool WriteString(const Ch *str, SizeType length)
Definition: writer.h:244
PrettyWriter & SetIndent(Ch indentChar, unsigned indentCharCount)
Set custom indentation.
Definition: prettywriter.h:53
unsigned __int64 uint64_t
Definition: stdint.h:90
bool WriteEndObject()
Definition: writer.h:313
bool Int64(int64_t i64)
Definition: prettywriter.h:69
bool Double(double d)
Definition: prettywriter.h:71
number
Definition: rapidjson.h:649
size_t GetSize() const
Definition: stack.h:129
OutputStream * os_
Definition: writer.h:337
bool WriteStartObject()
Definition: writer.h:312
void PrettyPrefix(Type type)
Definition: prettywriter.h:146
float length(float v)
Definition: vectorMath.h:208
bool inArray
true if in array, otherwise in object
Definition: writer.h:185
bool Bool(bool b)
Definition: prettywriter.h:66
bool Null()
Definition: prettywriter.h:65
bool String(const Ch *str)
Simpler but slower overload.
Definition: prettywriter.h:141
PrettyWriter(OutputStream &os, StackAllocator *allocator=0, size_t levelDepth=Base::kDefaultLevelDepth)
Constructor.
Definition: prettywriter.h:45
bool Uint(unsigned u)
Definition: prettywriter.h:68
bool Key(const Ch *str, SizeType length, bool copy=false)
Definition: prettywriter.h:91
true
Definition: rapidjson.h:645
bool WriteUint64(uint64_t u64)
Definition: writer.h:228
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:30
bool WriteNull()
Definition: writer.h:190
bool WriteUint(unsigned u)
Definition: writer.h:212
Type
Type of JSON value.
Definition: rapidjson.h:642
bool Int(int i)
Definition: prettywriter.h:67
unsigned indentCharCount_
Definition: prettywriter.h:193
bool Uint64(uint64_t u64)
Definition: prettywriter.h:70
Writer with indentation and spacing.
Definition: prettywriter.h:35
null
Definition: rapidjson.h:643
bool EndObject(SizeType memberCount=0)
Definition: prettywriter.h:93
bool WriteInt64(int64_t i64)
Definition: writer.h:220