Rudiments
Public Member Functions | List of all members
dom Class Referenceabstract

Inherits collection.

Inherited by csvdom, inidom, jsondom, propdom, and xmldom.

Public Member Functions

 dom ()
 
 dom (bool stringcacheenabled)
 
virtual ~dom ()
 
virtual const char * getType ()
 
virtual bool parse (input *in)=0
 
virtual bool parseFile (const char *filename)=0
 
virtual bool parseString (const char *string)=0
 
virtual domnodegetRootNode ()
 
virtual domnodegetNullNode ()
 
virtual void createRootNode ()
 
virtual ssize_t writeFile (const char *filename, mode_t perms)
 
virtual ssize_t writeFile (const char *filename, mode_t perms, bool indent)
 
virtual ssize_t write ()
 
virtual ssize_t write (bool indent)
 
virtual ssize_t write (output *out)
 
virtual ssize_t write (output *out, bool indent)
 
virtual ssize_t writeXml ()
 
virtual ssize_t writeXml (bool indent)
 
virtual ssize_t writeXml (output *out)
 
virtual ssize_t writeXml (output *out, bool indent)
 
bool getStringCacheEnabled ()
 
- Public Member Functions inherited from collection
 collection ()
 
 collection (collection &c)
 
collectionoperator= (collection &c)
 
virtual ~collection ()
 
virtual uint64_t getCount ()=0
 
comparatorgetComparator ()
 
void setComparator (comparator *newcomp)
 
virtual bool isReadOnly ()
 
virtual bool isBlockBased ()
 
virtual uint64_t getBlockSize ()
 
virtual bool isSequentialAccess ()
 
virtual void setManageValues (bool manage)
 
virtual bool getManageValues ()
 
virtual void setManageArrayValues (bool manage)
 
virtual bool getManageArrayValues ()
 
virtual void setManageKeys (bool manage)
 
virtual bool getManageKeys ()
 
virtual void setManageArrayKeys (bool manage)
 
virtual bool getManageArrayKeys ()
 
virtual bool clear ()=0
 
virtual ssize_t writeJson ()=0
 
virtual ssize_t writeJson (bool indent)=0
 
virtual ssize_t writeJson (output *out)=0
 
virtual ssize_t writeJson (output *out, bool indent)=0
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

The dom class implements a minimal DOM-style parser.

Constructor & Destructor Documentation

◆ dom() [1/2]

dom::dom ( )

Creates a new instance of the dom class.

◆ dom() [2/2]

dom::dom ( bool  stringcacheenabled)

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

By default, as each domnode is added to the dom 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.

◆ ~dom()

virtual dom::~dom ( )
virtual

Deletes this instance of the dom class.

Member Function Documentation

◆ createRootNode()

virtual void dom::createRootNode ( )
virtual

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

Reimplemented in xmldom, propdom, jsondom, inidom, and csvdom.

◆ getNullNode()

virtual domnode* dom::getNullNode ( )
virtual

Returns the null node of the DOM tree.

◆ getRootNode()

virtual domnode* dom::getRootNode ( )
virtual

Returns the root node of the DOM tree.

◆ getStringCacheEnabled()

bool dom::getStringCacheEnabled ( )

Returns true if the string cache is enabled and false if it is disabled.

◆ getType()

virtual const char* dom::getType ( )
virtual

Returns "dom".

Implements collection.

Reimplemented in xmldom, propdom, jsondom, inidom, and csvdom.

◆ parse()

virtual bool dom::parse ( input in)
pure virtual

Parses generic input "in" and generates a DOM tree.

Implemented in xmldom, propdom, jsondom, inidom, and csvdom.

◆ parseFile()

virtual bool dom::parseFile ( const char *  filename)
pure virtual

Parses file "filename" and generates a DOM tree.

Implemented in xmldom, propdom, jsondom, inidom, and csvdom.

◆ parseString()

virtual bool dom::parseString ( const char *  string)
pure virtual

Parses string "string" and generates a DOM tree.

Implemented in xmldom, propdom, jsondom, inidom, and csvdom.

◆ write() [1/4]

virtual ssize_t dom::write ( )
virtual

Writes a representation of the DOM tree to standard output.

Implements collection.

◆ write() [2/4]

virtual ssize_t dom::write ( bool  indent)
virtual

Writes a representation of the DOM tree to standard output.

If "indent" is true, then the output is automatically indented. If "indent" is false, then the tree is output as-is.

◆ write() [3/4]

virtual ssize_t dom::write ( output out)
virtual

Writes a representation of the DOM tree to "out".

Implements collection.

◆ write() [4/4]

virtual ssize_t dom::write ( output out,
bool  indent 
)
virtual

Writes a representation of the DOM tree to "out".

If "indent" is true, then the output is automatically indented. If "indent" is false, then the tree is output as-is.

◆ writeFile() [1/2]

virtual ssize_t dom::writeFile ( const char *  filename,
mode_t  perms 
)
virtual

Writes the DOM tree to "filename" and sets permissions of the file to "perms".

◆ writeFile() [2/2]

virtual ssize_t dom::writeFile ( const char *  filename,
mode_t  perms,
bool  indent 
)
virtual

Writes the DOM tree to "filename" and sets permissions of the file to "perms".

If "indent" is true, then the output is automatically indented. If "indent" is false, then the tree is output as-is.

◆ writeXml() [1/4]

virtual ssize_t dom::writeXml ( )
virtual

Writes an XML representation of the DOM tree to standard output.

◆ writeXml() [2/4]

virtual ssize_t dom::writeXml ( bool  indent)
virtual

Writes an XML representation of the DOM tree to standard output.

If "indent" is true, then the output is automatically indented. If "indent" is false, then the tree is written without indentation.

◆ writeXml() [3/4]

virtual ssize_t dom::writeXml ( output out)
virtual

Writes an XML representation of the DOM tree to "out".

◆ writeXml() [4/4]

virtual ssize_t dom::writeXml ( output out,
bool  indent 
)
virtual

Writes an XML representation of the DOM tree to "out".

If "indent" is true, then the output is automatically indented. If "indent" is false, then the tree is written without indentation.