Rudiments

Public Member Functions | Protected Member Functions | List of all members
jsondom Class Reference

Inherits jsonsax, and dom.

## Public Member Functions
| jsondom ()
| jsondom (bool stringcacheenabled)
virtual | ~jsondom ()
bool | parseFile (const char *filename)
bool | parseString (const char *string)
void | createRootNode ()
virtual bool | write (output *out) const
Public Member Functions inherited from jsonsax
| jsonsax ()
virtual | ~jsonsax ()
Public Member Functions inherited from sax
| sax ()
virtual | ~sax ()
const char * | getError ()
Public Member Functions inherited from dom
| dom ()
| dom (bool stringcacheenabled)
virtual | ~dom ()
virtual domnode * | getRootNode () const
virtual domnode * | getNullNode () const
virtual bool | writeFile (const char *filename, mode_t perms) const
virtual bool | write (output *out, bool indent) const
bool | stringCacheEnabled ()

## Protected Member Functions
virtual bool | objectStart ()
virtual bool | memberStart ()
virtual bool | memberName (const char *name)
virtual bool | valueStart ()
virtual bool | stringValue (const char *value)
virtual bool | numberValue (const char *value)
virtual bool | trueValue ()
virtual bool | falseValue ()
virtual bool | nullValue ()
virtual bool | arrayStart ()
virtual bool | arrayEnd ()
virtual bool | valueEnd ()
virtual bool | memberEnd ()
virtual bool | objectEnd ()

## Detailed Description

The jsondom class implements a minimal JSON DOM parser.

## Constructor & Destructor Documentation

## ◆ jsondom() [1/2]

jsondom::jsondom | ( |  | ) |

Creates a new instance of the jsondom class.

## ◆ jsondom() [2/2]

jsondom::jsondom | ( | bool | stringcacheenabled | ) |

Creates a new instance of the jsondom class, allowing the user to enable or disable the "string cache" for this instance.

By default, as each domnode is added to the jsondom tree, tag and attribute names and values are stored in a string cache and pointers into the cache are assigned to each node. Reference counters are kept and the string is removed from the cache when no more nodes are using it. If the data is highly repetitive this conserves memory at the cost of speed.

If the string cache is disabled then memory is allocated in each domnode for names and values and freed when the domnode is freed. This is faster but uses much more memory.

## ◆ ~jsondom()

virtual jsondom::~jsondom | ( |  | ) |
| virtual

Deletes this instance of the jsondom class.

## Member Function Documentation

## ◆ arrayEnd()

virtual bool jsondom::arrayEnd | ( |  | ) |
| protected virtual

Gets called when an array end is parsed.

Reimplemented from jsonsax.

## ◆ arrayStart()

virtual bool jsondom::arrayStart | ( |  | ) |
| protected virtual

Gets called when an array start is parsed.

Reimplemented from jsonsax.

## ◆ createRootNode()

void jsondom::createRootNode | ( |  | ) |
| virtual

Creates a new root node. This is useful for building a tree from scratch.

Reimplemented from dom.

## ◆ falseValue()

virtual bool jsondom::falseValue | ( |  | ) |
| protected virtual

Gets called when a false value is parsed.

Reimplemented from jsonsax.

## ◆ memberEnd()

virtual bool jsondom::memberEnd | ( |  | ) |
| protected virtual

Gets called when a member end is parsed.

Reimplemented from jsonsax.

## ◆ memberName()

virtual bool jsondom::memberName | ( | const char * | name | ) |
| protected virtual

Gets called when a member name is parsed.

Reimplemented from jsonsax.

## ◆ memberStart()

virtual bool jsondom::memberStart | ( |  | ) |
| protected virtual

Gets called when a member start is parsed.

Reimplemented from jsonsax.

## ◆ nullValue()

virtual bool jsondom::nullValue | ( |  | ) |
| protected virtual

Gets called when a null value is parsed.

Reimplemented from jsonsax.

## ◆ numberValue()

virtual bool jsondom::numberValue | ( | const char * | value | ) |
| protected virtual

Gets called when a number value is parsed.

Reimplemented from jsonsax.

## ◆ objectEnd()

virtual bool jsondom::objectEnd | ( |  | ) |
| protected virtual

Gets called when an object end is parsed.

Reimplemented from jsonsax.

## ◆ objectStart()

virtual bool jsondom::objectStart | ( |  | ) |
| protected virtual

Gets called when an object start is parsed.

Reimplemented from jsonsax.

## ◆ parseFile()

bool jsondom::parseFile | ( | const char * | filename | ) |
| virtual

Parses file "filename" and generates a DOM tree.

Implements dom.

## ◆ parseString()

bool jsondom::parseString | ( | const char * | string | ) |
| virtual

Parses string "string" and generates a DOM tree.

Implements dom.

## ◆ stringValue()

virtual bool jsondom::stringValue | ( | const char * | value | ) |
| protected virtual

Gets called when a string value is parsed.

Reimplemented from jsonsax.

## ◆ trueValue()

virtual bool jsondom::trueValue | ( |  | ) |
| protected virtual

Gets called when a true value is parsed.

Reimplemented from jsonsax.

## ◆ valueEnd()

virtual bool jsondom::valueEnd | ( |  | ) |
| protected virtual

Gets called when an value end is parsed.

Reimplemented from jsonsax.

## ◆ valueStart()

virtual bool jsondom::valueStart | ( |  | ) |
| protected virtual

Gets called when a value start is parsed.

Reimplemented from jsonsax.

## ◆ write()

virtual bool jsondom::write | ( | output * | out | ) | const
| virtual

Writes the current DOM tree to "out".

Reimplemented from dom.