JsonWriter Class Reference

#include <Pt/Json/JsonWriter.h>

Writes JSON to a text stream.

Public Member Functions

 JsonWriter ()
 Constructor.
 
 JsonWriter (std::basic_ostream< Char > &os)
 Constructs with output stream.
 
 ~JsonWriter ()
 Destructor.
 
bool isFormatting () const
 Returns true if indentation should be written.
 
void setFormatting (bool value)
 Indicates wether indentation should be written.
 
const Pt::Stringindent () const
 Returns the indentation string.
 
void setIndent (const Pt::String &indent)
 Sets the indentation string.
 
void reset ()
 Clears the writer state and output. More...
 
void reset (std::basic_ostream< Char > &os)
 Clears the writer state and output. More...
 
std::basic_ostream< Char > * output ()
 Returns the output stream or a nullptr if none was set.
 
void writeObject ()
 Writes the begin of an object.
 
void writeObjectEnd ()
 Writes the end of an object.
 
void writeArray ()
 Writes the begin of an array.
 
void writeArrayEnd ()
 Writes the end of an array.
 
void writeMember (const Pt::Char *name, std::size_t nameSize)
 Writes a member.
 
void writeMember (const Pt::String &name)
 Writes a member.
 
void writeMember (const char *name)
 Writes a member.
 
void writeString (const Pt::Char *value, std::size_t valueSize)
 Writes a string value.
 
void writeString (const Pt::String &value)
 Writes a string value.
 
void writeInt (Pt::int64_t value)
 Writes an integer value.
 
void writeUInt (Pt::uint64_t value)
 Writes an unsigned integer value.
 
void writeFloat (long double value)
 Writes an float value.
 
void writeBool (bool value)
 Writes an boolean value.
 
void writeNull ()
 Writes an null value.
 

Member Function Documentation

◆ reset() [1/2]

void reset ( )

Ther output stream is removed and the writer state is reset to write a new document. The formatting options are not changed.

◆ reset() [2/2]

void reset ( std::basic_ostream< Char > &  os)

The output stream is set and the writer state is reset to write a new document. The formatting options are not changed.