Nebula
Loading...
Searching...
No Matches
IO::JsonWriter Class Reference

#include <jsonwriter.h>

Detailed Description

Write Json-formatted data to a stream.

Inherits IO::StreamWriter.

Public Member Functions

 JsonWriter ()
 constructor
 
virtual ~JsonWriter ()
 destructor
 
virtual bool Open ()
 begin writing the stream
 
virtual void Close ()
 end writing the stream
 
void BeginArray (const char *nodeName=nullptr)
 begin a new array node
 
void BeginObject (const char *nodeName=nullptr)
 begin a new node that can host key-value pairs
 
void End ()
 end current object or array
 
template<typename T >
void Add (const T &value, const Util::String &name="")
 add a value to the current array node
 
template<unsigned int N>
void Add (Util::BitField< N > const &value, const Util::String &name="")
 add bitfield of N size
 
void Add (const char *value, const Util::String &name="")
 special handling for const strings
 
template<>
void Add (const Util::String &value, const Util::String &name)
 
template<>
void Add (const Util::StringAtom &value, const Util::String &name)
 
template<>
void Add (const Util::FourCC &value, const Util::String &name)
 
template<>
void Add (const bool &value, const Util::String &name)
 
template<>
void Add (const char &value, const Util::String &name)
 
template<>
void Add (const uchar &value, const Util::String &name)
 
template<>
void Add (const int &value, const Util::String &name)
 
template<>
void Add (const unsigned int &value, const Util::String &name)
 
template<>
void Add (const uint64_t &value, const Util::String &name)
 
template<>
void Add (const float &value, const Util::String &name)
 
template<>
void Add (const Math::vec3 &value, const Util::String &name)
 
template<>
void Add (const Math::vec4 &value, const Util::String &name)
 
template<>
void Add (const Util::Color &value, const Util::String &name)
 
template<>
void Add (const Math::quat &value, const Util::String &name)
 
template<>
void Add (const Math::vec2 &value, const Util::String &name)
 
template<>
void Add (const Math::mat4 &value, const Util::String &name)
 
template<>
void Add (const Math::transform44 &value, const Util::String &name)
 
template<>
void Add (const Util::Variant &value, const Util::String &name)
 
template<>
void Add (const Util::Guid &value, const Util::String &name)
 
template<>
void Add (const Util::Array< int > &value, const Util::String &name)
 
template<>
void Add (const Util::Array< Util::String > &value, const Util::String &name)
 
template<>
void Add (const Util::String &value, const Util::String &name)
 
template<>
void Add (const Util::StringAtom &value, const Util::String &name)
 
template<>
void Add (const Util::FourCC &value, const Util::String &name)
 
template<>
void Add (const bool &value, const Util::String &name)
 
template<>
void Add (const char &value, const Util::String &name)
 
template<>
void Add (const uchar &value, const Util::String &name)
 
template<>
void Add (const int &value, const Util::String &name)
 
template<>
void Add (const unsigned int &value, const Util::String &name)
 
template<>
void Add (const float &value, const Util::String &name)
 
template<>
void Add (const Math::vec3 &value, const Util::String &name)
 
template<>
void Add (const Math::vec4 &value, const Util::String &name)
 
template<>
void Add (const Math::vec2 &value, const Util::String &name)
 
template<>
void Add (const Math::mat4 &value, const Util::String &name)
 
template<>
void Add (const Math::transform44 &value, const Util::String &name)
 
template<>
void Add (const Util::Variant &value, const Util::String &name)
 
template<>
void Add (const Util::Guid &value, const Util::String &name)
 
template<>
void Add (const Util::Array< int > &value, const Util::String &name)
 
template<>
void Add (const Util::Array< Util::String > &value, const Util::String &name)
 
- Public Member Functions inherited from IO::StreamWriter
 StreamWriter ()
 constructor
 
virtual ~StreamWriter ()
 destructor
 
void SetStream (const Ptr< Stream > &s)
 set stream to write to
 
const Ptr< Stream > & GetStream () const
 get currently set stream
 
bool HasStream () const
 return true if a stream is set
 
bool IsOpen () const
 return true if currently open
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Private Member Functions

 __DeclareClass (JsonWriter)
 

Private Attributes

pjson::document * document
 add a value to current object node
 
Util::Stack< pjson::value_variant * > hierarchy
 
Util::Stack< Util::StringnameHierarchy
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 
- Protected Attributes inherited from IO::StreamWriter
Ptr< Streamstream
 
bool isOpen
 
bool streamWasOpen
 

Constructor & Destructor Documentation

◆ JsonWriter()

IO::JsonWriter::JsonWriter ( )

constructor

◆ ~JsonWriter()

IO::JsonWriter::~JsonWriter ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

IO::JsonWriter::__DeclareClass ( JsonWriter )
private

◆ Add() [1/42]

template<>
void IO::JsonWriter::Add ( const bool & value,
const Util::String & name )

◆ Add() [2/42]

template<>
void IO::JsonWriter::Add ( const bool & value,
const Util::String & name )

◆ Add() [3/42]

template<>
void IO::JsonWriter::Add ( const char & value,
const Util::String & name )

◆ Add() [4/42]

template<>
void IO::JsonWriter::Add ( const char & value,
const Util::String & name )

◆ Add() [5/42]

void IO::JsonWriter::Add ( const char * value,
const Util::String & name = "" )

special handling for const strings

◆ Add() [6/42]

template<>
void IO::JsonWriter::Add ( const float & value,
const Util::String & name )

◆ Add() [7/42]

template<>
void IO::JsonWriter::Add ( const float & value,
const Util::String & name )

◆ Add() [8/42]

template<>
void IO::JsonWriter::Add ( const int & value,
const Util::String & name )

◆ Add() [9/42]

template<>
void IO::JsonWriter::Add ( const int & value,
const Util::String & name )

◆ Add() [10/42]

template<>
void IO::JsonWriter::Add ( const Math::mat4 & value,
const Util::String & name )

◆ Add() [11/42]

template<>
void IO::JsonWriter::Add ( const Math::mat4 & value,
const Util::String & name )

◆ Add() [12/42]

template<>
void IO::JsonWriter::Add ( const Math::quat & value,
const Util::String & name )

◆ Add() [13/42]

template<>
void IO::JsonWriter::Add ( const Math::transform44 & value,
const Util::String & name )

◆ Add() [14/42]

template<>
void IO::JsonWriter::Add ( const Math::transform44 & value,
const Util::String & name )

◆ Add() [15/42]

template<>
void IO::JsonWriter::Add ( const Math::vec2 & value,
const Util::String & name )

◆ Add() [16/42]

template<>
void IO::JsonWriter::Add ( const Math::vec2 & value,
const Util::String & name )

◆ Add() [17/42]

template<>
void IO::JsonWriter::Add ( const Math::vec3 & value,
const Util::String & name )

◆ Add() [18/42]

template<>
void IO::JsonWriter::Add ( const Math::vec3 & value,
const Util::String & name )

◆ Add() [19/42]

template<>
void IO::JsonWriter::Add ( const Math::vec4 & value,
const Util::String & name )

◆ Add() [20/42]

template<>
void IO::JsonWriter::Add ( const Math::vec4 & value,
const Util::String & name )

◆ Add() [21/42]

template<typename T >
void IO::JsonWriter::Add ( const T & value,
const Util::String & name = "" )

add a value to the current array node

◆ Add() [22/42]

template<>
void IO::JsonWriter::Add ( const uchar & value,
const Util::String & name )

◆ Add() [23/42]

template<>
void IO::JsonWriter::Add ( const uchar & value,
const Util::String & name )

◆ Add() [24/42]

template<>
void IO::JsonWriter::Add ( const uint64_t & value,
const Util::String & name )

◆ Add() [25/42]

template<>
void IO::JsonWriter::Add ( const unsigned int & value,
const Util::String & name )

◆ Add() [26/42]

template<>
void IO::JsonWriter::Add ( const unsigned int & value,
const Util::String & name )

◆ Add() [27/42]

template<>
void IO::JsonWriter::Add ( const Util::Array< int > & value,
const Util::String & name )

◆ Add() [28/42]

template<>
void IO::JsonWriter::Add ( const Util::Array< int > & value,
const Util::String & name )

◆ Add() [29/42]

template<>
void IO::JsonWriter::Add ( const Util::Array< Util::String > & value,
const Util::String & name )

◆ Add() [30/42]

template<>
void IO::JsonWriter::Add ( const Util::Array< Util::String > & value,
const Util::String & name )

◆ Add() [31/42]

template<>
void IO::JsonWriter::Add ( const Util::Color & value,
const Util::String & name )

◆ Add() [32/42]

template<>
void IO::JsonWriter::Add ( const Util::FourCC & value,
const Util::String & name )

◆ Add() [33/42]

template<>
void IO::JsonWriter::Add ( const Util::FourCC & value,
const Util::String & name )

◆ Add() [34/42]

template<>
void IO::JsonWriter::Add ( const Util::Guid & value,
const Util::String & name )

◆ Add() [35/42]

template<>
void IO::JsonWriter::Add ( const Util::Guid & value,
const Util::String & name )

◆ Add() [36/42]

template<>
void IO::JsonWriter::Add ( const Util::String & value,
const Util::String & name )

◆ Add() [37/42]

template<>
void IO::JsonWriter::Add ( const Util::String & value,
const Util::String & name )

◆ Add() [38/42]

template<>
void IO::JsonWriter::Add ( const Util::StringAtom & value,
const Util::String & name )

◆ Add() [39/42]

template<>
void IO::JsonWriter::Add ( const Util::StringAtom & value,
const Util::String & name )

◆ Add() [40/42]

template<>
void IO::JsonWriter::Add ( const Util::Variant & value,
const Util::String & name )

◆ Add() [41/42]

template<>
void IO::JsonWriter::Add ( const Util::Variant & value,
const Util::String & name )

◆ Add() [42/42]

template<unsigned int N>
void IO::JsonWriter::Add ( Util::BitField< N > const & value,
const Util::String & name = "" )
inline

add bitfield of N size

◆ BeginArray()

void IO::JsonWriter::BeginArray ( const char * nodeName = nullptr)

begin a new array node

◆ BeginObject()

void IO::JsonWriter::BeginObject ( const char * nodeName = nullptr)

begin a new node that can host key-value pairs

◆ Close()

void IO::JsonWriter::Close ( )
virtual

end writing the stream

Reimplemented from IO::StreamWriter.

◆ End()

void IO::JsonWriter::End ( )

end current object or array

◆ Open()

bool IO::JsonWriter::Open ( )
virtual

begin writing the stream

Reimplemented from IO::StreamWriter.

Member Data Documentation

◆ document

pjson::document* IO::JsonWriter::document
private

add a value to current object node

◆ hierarchy

Util::Stack<pjson::value_variant*> IO::JsonWriter::hierarchy
private

◆ nameHierarchy

Util::Stack<Util::String> IO::JsonWriter::nameHierarchy
private

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