Rudiments
Public Member Functions | Protected Member Functions | List of all members
csvdom Class Reference

Inherits csvsax, and dom.

Public Member Functions

 csvdom ()
 
 csvdom (bool stringcacheenabled)
 
virtual ~csvdom ()
 
bool parseFile (const char *filename)
 
bool parseString (const char *string)
 
void createRootNode ()
 
bool write (output *out, bool indent) const
 
- Public Member Functions inherited from csvsax
 csvsax ()
 
virtual ~csvsax ()
 
void setQuote (char quote)
 
char getQuote () const
 
void setDelimiter (char delimiter)
 
char getDelimiter () const
 
- 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 domnodegetRootNode () const
 
virtual domnodegetNullNode () const
 
virtual bool writeFile (const char *filename, mode_t perms) const
 
virtual bool write (output *out) const
 
bool stringCacheEnabled ()
 

Protected Member Functions

virtual bool headerStart ()
 
virtual bool column (const char *name, bool quoted)
 
virtual bool headerEnd ()
 
virtual bool bodyStart ()
 
virtual bool rowStart ()
 
virtual bool field (const char *value, bool quoted)
 
virtual bool rowEnd ()
 
virtual bool bodyEnd ()
 

Detailed Description

The csvdom class implements a minimal CSV DOM parser.

Constructor & Destructor Documentation

◆ csvdom() [1/2]

csvdom::csvdom ( )

Creates a new instance of the csvdom class.

◆ csvdom() [2/2]

csvdom::csvdom ( bool  stringcacheenabled)

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

By default, as each csvdomnode is added to the csvdom 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 csvdomnode for names and values and freed when the csvdomnode is freed. This is faster but uses much more memory.

◆ ~csvdom()

virtual csvdom::~csvdom ( )
virtual

Deletes this instance of the csvdom class.

Member Function Documentation

◆ bodyEnd()

virtual bool csvdom::bodyEnd ( )
protectedvirtual

Gets called when the end of the body is encountered.

Reimplemented from csvsax.

◆ bodyStart()

virtual bool csvdom::bodyStart ( )
protectedvirtual

Gets called when the start of the body is encountered.

Reimplemented from csvsax.

◆ column()

virtual bool csvdom::column ( const char *  name,
bool  quoted 
)
protectedvirtual

Gets called when a column name is parsed.

Reimplemented from csvsax.

◆ createRootNode()

void csvdom::createRootNode ( )
virtual

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

Reimplemented from dom.

◆ field()

virtual bool csvdom::field ( const char *  value,
bool  quoted 
)
protectedvirtual

Gets called when a field is parsed.

Reimplemented from csvsax.

◆ headerEnd()

virtual bool csvdom::headerEnd ( )
protectedvirtual

Gets called when the end of the header is encountered.

Reimplemented from csvsax.

◆ headerStart()

virtual bool csvdom::headerStart ( )
protectedvirtual

Gets called when the start of the header is encountered.

Reimplemented from csvsax.

◆ parseFile()

bool csvdom::parseFile ( const char *  filename)
virtual

Parses file "filename" and generates a DOM tree.

Implements dom.

◆ parseString()

bool csvdom::parseString ( const char *  string)
virtual

Parses string "string" and generates a DOM tree.

Implements dom.

◆ rowEnd()

virtual bool csvdom::rowEnd ( )
protectedvirtual

Gets called when the end of a row is encountered.

Reimplemented from csvsax.

◆ rowStart()

virtual bool csvdom::rowStart ( )
protectedvirtual

Gets called when the start of a row is encountered.

Reimplemented from csvsax.

◆ write()

bool csvdom::write ( output out,
bool  indent 
) const
virtual

Writes the current 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.

Reimplemented from dom.