GClasses
GClasses::GDomNode Class Reference

Detailed Description

Represents a single node in a DOM.

#include <GDom.h>

Public Types

Public Member Functions

GDomNodeaddField (GDom *pDoc, const char *szName, GDomNode *pNode)
 Adds a field with the specified name to this object. Throws if this is not an object type Returns pNode. (Yes, it returns the same node that you pass in. This is useful for writing compact marshalling code.) More...
 
GDomNodeaddItem (GDom *pDoc, GDomNode *pNode)
 Adds an item to a list node. Returns a pointer to the item passed in (pNode). More...
 
bool asBool () const
 Returns the boolean value stored by this node. Throws if this is not a bool type. More...
 
double asDouble () const
 Returns the double value stored by this node. Throws if this is not a double type. More...
 
long long asInt () const
 Returns the 64-bit integer value stored by this node. Throws if this is not an integer type. More...
 
const char * asString () const
 Returns the string value stored by this node. Throws if this is not a string type. More...
 
GDomNodefield (const char *szName) const
 Returns the node with the specified field name. Throws if this is not an object type. Throws if there is no field with the name specified by szName. More...
 
GDomNodefieldIfExists (const char *szName) const
 Returns the node with the specified field name. Throws if this is not an object type. Returns NULL if this is an object type, but there is no field with the specified name. More...
 
void saveJson (const char *filename) const
 Writes this node to a JSON file. More...
 
nodetype type () const
 Returns the type of this node. More...
 
void writeJson (std::ostream &stream) const
 Writes this node in JSON format. More...
 
size_t writeJsonCpp (std::ostream &stream, size_t col) const
 Writes this node in JSON format, escaped in a manner suitable for hard-coding in a C/C++ string. More...
 
void writeJsonPretty (std::ostream &stream, size_t indents) const
 Writes this node in JSON format indented in a manner suitable for human readability. More...
 
void writeXml (std::ostream &stream, const char *szLabel) const
 Writes this node as XML. More...
 

Protected Member Functions

size_t reverseFieldOrder () const
 Reverses the order of the fiels in the object and returns the number of fields. Assumes this GDomNode is a object node. Behavior is undefined if it is not an object node. More...
 
size_t reverseItemOrder () const
 Reverses the order of the items in the list and returns the number of items in the list. Assumes this GDomNode is a list node. Behavior is undefined if it is not a list node. More...
 
void writeXmlInlineValue (std::ostream &stream)
 

Friends

class GDom
 
class GDomListIterator
 

Member Enumeration Documentation

Enumerator
type_obj 
type_list 
type_bool 
type_int 
type_double 
type_string 
type_null 

Member Function Documentation

GDomNode* GClasses::GDomNode::addField ( GDom pDoc,
const char *  szName,
GDomNode pNode 
)

Adds a field with the specified name to this object. Throws if this is not an object type Returns pNode. (Yes, it returns the same node that you pass in. This is useful for writing compact marshalling code.)

GDomNode* GClasses::GDomNode::addItem ( GDom pDoc,
GDomNode pNode 
)

Adds an item to a list node. Returns a pointer to the item passed in (pNode).

bool GClasses::GDomNode::asBool ( ) const
inline

Returns the boolean value stored by this node. Throws if this is not a bool type.

double GClasses::GDomNode::asDouble ( ) const
inline

Returns the double value stored by this node. Throws if this is not a double type.

long long GClasses::GDomNode::asInt ( ) const
inline

Returns the 64-bit integer value stored by this node. Throws if this is not an integer type.

const char* GClasses::GDomNode::asString ( ) const
inline

Returns the string value stored by this node. Throws if this is not a string type.

GDomNode* GClasses::GDomNode::field ( const char *  szName) const
inline

Returns the node with the specified field name. Throws if this is not an object type. Throws if there is no field with the name specified by szName.

GDomNode* GClasses::GDomNode::fieldIfExists ( const char *  szName) const

Returns the node with the specified field name. Throws if this is not an object type. Returns NULL if this is an object type, but there is no field with the specified name.

size_t GClasses::GDomNode::reverseFieldOrder ( ) const
protected

Reverses the order of the fiels in the object and returns the number of fields. Assumes this GDomNode is a object node. Behavior is undefined if it is not an object node.

Note
This method is hackishly marked const because it is always used twice, such that it has no net effect.
Returns
The number of fields
size_t GClasses::GDomNode::reverseItemOrder ( ) const
protected

Reverses the order of the items in the list and returns the number of items in the list. Assumes this GDomNode is a list node. Behavior is undefined if it is not a list node.

Note
This method is hackishly marked const because it is always used twice, such that it has no net effect.
Returns
The number of items in the list
void GClasses::GDomNode::saveJson ( const char *  filename) const

Writes this node to a JSON file.

nodetype GClasses::GDomNode::type ( ) const
inline

Returns the type of this node.

void GClasses::GDomNode::writeJson ( std::ostream &  stream) const

Writes this node in JSON format.

size_t GClasses::GDomNode::writeJsonCpp ( std::ostream &  stream,
size_t  col 
) const

Writes this node in JSON format, escaped in a manner suitable for hard-coding in a C/C++ string.

void GClasses::GDomNode::writeJsonPretty ( std::ostream &  stream,
size_t  indents 
) const

Writes this node in JSON format indented in a manner suitable for human readability.

void GClasses::GDomNode::writeXml ( std::ostream &  stream,
const char *  szLabel 
) const

Writes this node as XML.

void GClasses::GDomNode::writeXmlInlineValue ( std::ostream &  stream)
protected

Friends And Related Function Documentation

friend class GDom
friend
friend class GDomListIterator
friend

Member Data Documentation

bool GClasses::GDomNode::m_bool
double GClasses::GDomNode::m_double
long long GClasses::GDomNode::m_int
GDomObjField* GClasses::GDomNode::m_pLastField
GDomListItem* GClasses::GDomNode::m_pLastItem
char GClasses::GDomNode::m_string[8]