class DECLSPEC XMLIO_Document

Base class for document handling (see XML Spec [1]).

Inheritance:


Public Fields

[more]XMLIO_string characters
Buffer to store all incoming characters.
[more]XMLIO_Element* current_element
Current element, which gets all characters and start tag events for further processing.
[more]XMLIO_stack<XMLIO_Element*> element_stack
Stack with all elements.
[more]char* indent
Blanks ('current_indent' many).

Public Methods

[more] XMLIO_Document ()
Constructor.
[more]virtual ~XMLIO_Document ()
Destructor.
[more]virtual const char* toString () const
Returns name of class.
[more]void changeIndent (int change)
Changes current indentation by given value.
[more]void setIndent (int new_indent)
Sets current indentation to given value.
[more]int close ()
Closes file and clears stack.
[more]int flush () const
Flushes file stream.
[more]int open (const XMLIO_string& filename, const XMLIO_string& access_mode)
Opens XML file with given filename.
[more]int open (FILE* file, const XMLIO_string& my_access_mode)
Uses given C stream for input or output of document.
[more]int readDocument ()
Reads opened file and passes events to appropriate XML_Element objects.
[more]int write (const XMLIO_strstream& char_data) const
Writes character data (XML Spec [14]) from a strstream to file.
[more]int write (const XMLIO_string& char_data) const
Writes character data (XML Spec [14]) from a string to file.
[more]int write (const char* text) const
Writes character data (XML Spec [14]) to file.
[more]int writef (const char* templ, ...) const
Writes character data (XML Spec [14]) to file and behaves like fprintf.
[more]int writeEndl () const
Writes \n character and flushes buffer.
[more]int writeEndlIndent () const
Writes \n character, flushes buffer and writes indentation of the following line.
[more]int writeElement (XMLIO_Element* element)
Writes an element (XML Spec [39]).
[more]int writeComment (const char* templ, ... ) const
Writes a comment to file.
[more]int writeCDSect (const XMLIO_string& CDSect) const
Writes a character data section to file.
[more]int writeIndent () const
Writes indentation.
[more]int writeEndTag (const XMLIO_string& tag) const
Writes '</tagName>' to file (XML Spec [42]).
[more]int writeStartTag (const XMLIO_string& tag) const
Writes '<tagName>' to file (XML Spec [40]).
[more]int writeStartTag (const XMLIO_string& tag, const XMLIO_Attributes& attributes) const
Writes '<tagName attr1="key1" attr2="key2" .

Protected Fields

[more]XMLIO_string xml_filename
Name of opened file.

Protected Methods

[more]virtual int XMLIO_writeProlog ()
Writes the XML prolog (XML spec [22]).
[more]virtual int XMLIO_writeXMLDeclaration ()
Writes the XML declaration (first line in file) (XML specs [23]).
[more]virtual int XMLIO_writeDocTypeDeclaration ()
Writes the Document Type Declaration (XML specs [28]).
[more]virtual int XMLIO_writeTrailer ()
Is called when a document is closed and writes an optional trailer, which must be of Misc-type (XML specs [27]) after the main element (XML specs [1]).

Private Fields

[more]FILE* xml_file
XML file stream.
[more]XMLIO_AccessMode access_mode
Access mode.
[more]XMLIO_FileType xml_file_type
Type of opened file.
[more]mutable int current_indent
Current number of blanks for indentation.
[more]char* indent_block
Memory chunk with blanks and trailing \0.

Private Methods

[more]int writeAttribute (const XMLIO_string& key, const XMLIO_string& value) const
Writes 'attr="key"' to file (XML Spec [41]).
[more]int writeAttributes (const XMLIO_Attributes& attributes) const
Writes 'attr1="key1" attr2="key2" .
[more]int writeEmptyElement (const XMLIO_string& tag) const
Writes '<tagName/>' to file (XML Spec [44]).
[more]int writeEmptyElement (const XMLIO_string& tag, const XMLIO_Attributes& attributes) const
Writes '<tagName attr1="key1" attr2="key2" .

Private Members

[more]enum XMLIO_AccessMode
READ: File opened for reading.
[more]enum XMLIO_FileType
File types which can be processed by xmlio.


Inherited from XMLIO_Element:

Public Fields

oXMLIO_string tag
oXMLIO_Attributes attributes
oXMLIO_IndentationType xmlio_indent_type

Public Methods

ovirtual XMLIO_Element* XMLIO_startTag(const XMLIO_string& tag, XMLIO_Attributes &attrs)
ovirtual void XMLIO_endTag(const XMLIO_string& tag)
ovirtual void XMLIO_getCharacters(const XMLIO_string& characters)
ovirtual void XMLIO_getComment(const XMLIO_string& comment)
ovirtual void XMLIO_getProcessingInstruction(const XMLIO_string& target, const XMLIO_string& instructions)
ovirtual void XMLIO_finishedReading()
ovirtual bool XMLIO_remove() const
ovirtual const int XMLIO_writeContent(XMLIO_Document& doc)
ovirtual const XMLIO_string& XMLIO_getName() const
ovirtual XMLIO_Attributes& XMLIO_getAttributes()
ovirtual bool XMLIO_isEmpty() const
ovirtual void print() const


Documentation

Base class for document handling (see XML Spec [1]). This is not the root element, the root element should be instatiated in XMLIO_startTag The prolog is not yet fully supported.
oenum XMLIO_AccessMode
READ: File opened for reading. WRITE: File opened for writing. NONE: No file opened.

oenum XMLIO_FileType
File types which can be processed by xmlio. XMLIO_FT_FILE: Usual file. XMLIO_FT_CSTREAM: C stream (no need to open and close).

o XMLIO_Document()
Constructor.

ovirtual ~XMLIO_Document()
Destructor.

ovirtual const char* toString() const
Returns name of class. @depreciated

ovoid changeIndent(int change)
Changes current indentation by given value.

ovoid setIndent(int new_indent)
Sets current indentation to given value.

oint close()
Closes file and clears stack. Will be called automatically when destructor is called or a new file is opened. Returns fclose error code if 0 if no error occured.

oint flush() const
Flushes file stream. Returns error code of fflush or 0 if no error occured.

oint open(const XMLIO_string& filename, const XMLIO_string& access_mode)
Opens XML file with given filename. Access mode can either be "r" for reading or "w" for writing.
Returns:
Returns 0 on success or 1 otherwise.

oint open(FILE* file, const XMLIO_string& my_access_mode)
Uses given C stream for input or output of document. Access mode can either be "r" for reading or "w" for writing.
Returns:
Returns 0 on success or 1 otherwise.

oint readDocument()
Reads opened file and passes events to appropriate XML_Element objects. Initially all data will be passed to the XMLIO_Document which itself is a XMLIO_Element.
Returns:
Returns 0 on success or an error code otherwise.

oint write(const XMLIO_strstream& char_data) const
Writes character data (XML Spec [14]) from a strstream to file. Returns number of bytes written or fprintf error code.

oint write(const XMLIO_string& char_data) const
Writes character data (XML Spec [14]) from a string to file. Returns number of bytes written or fprintf error code.

oint write(const char* text) const
Writes character data (XML Spec [14]) to file.
Returns:
Returns number of bytes written or fprintf error code.

oint writef(const char* templ, ...) const
Writes character data (XML Spec [14]) to file and behaves like fprintf.
Returns:
Returns number of bytes written or fprintf error code.

oint writeEndl() const
Writes \n character and flushes buffer. Returns nr of bytes written or an negative error code.

oint writeEndlIndent() const
Writes \n character, flushes buffer and writes indentation of the following line. Returns nr of bytes written or an negative error code.

oint writeElement(XMLIO_Element* element)
Writes an element (XML Spec [39]). XMLIO_isEmpty() decides, whether an EmptyElement (XML Spec [44]) or StartTag, content and EndTag (XML Spec [40]-[43]) are used. If XMLIO_isEmpty() is true, element.XMLIO_writeContent(*this) is called. The correct way is the use of an iterator to access the elements content, but this is easier.
Returns:
Returns number of bytes written or an error code.

oint writeComment(const char* templ, ... ) const
Writes a comment to file. (XML Spec [15]) Returns number of bytes written or an error code.

oint writeCDSect(const XMLIO_string& CDSect) const
Writes a character data section to file. (XML Spec [18]-[21]) Returns number of bytes written or an error code.

oint writeIndent() const
Writes indentation. Returns number of bytes written or an error code.

oint writeEndTag(const XMLIO_string& tag) const
Writes '</tagName>' to file (XML Spec [42]).
Returns:
Returns the negative value of fprintf on error, otherwise the number of bytes written (>=0).

oint writeStartTag(const XMLIO_string& tag) const
Writes '<tagName>' to file (XML Spec [40]).
Returns:
Returns the negative value of fprintf on error, otherwise the number of bytes written (>=0).

oint writeStartTag(const XMLIO_string& tag, const XMLIO_Attributes& attributes) const
Writes '<tagName attr1="key1" attr2="key2" . >' to file (XML Spec [40]).
Returns:
Returns the negative value of fprintf on error, otherwise the number of bytes written (>=0).

oXMLIO_string characters
Buffer to store all incoming characters. This data will be send to current element at a) start tags, b) end tags, c) end of document.

oXMLIO_Element* current_element
Current element, which gets all characters and start tag events for further processing.

oXMLIO_stack<XMLIO_Element*> element_stack
Stack with all elements. In case of an end tag the top element of the stack will become active. The previous 'current element' will not get any futher anymore. Just the endTag() function is called to tell the previous 'current element' that it won't get any more data.

ochar* indent
Blanks ('current_indent' many).

ovirtual int XMLIO_writeProlog()
Writes the XML prolog (XML spec [22]). Only XMLDecl (XML specs [23]-[26]) is supported by calling XMLIO_writeXMLDeclaration()
Returns:
Returns nr of bytes written or an negative error code.

ovirtual int XMLIO_writeXMLDeclaration()
Writes the XML declaration (first line in file) (XML specs [23]). This is constant now: '<?xml version="1.0" encoding="ISO-8859-1"?>'.
Returns:
Returns number of bytes written or error code of fprintf.

ovirtual int XMLIO_writeDocTypeDeclaration()
Writes the Document Type Declaration (XML specs [28]). Returns number of bytes written or error code. By default does nothing and returns NULL.

ovirtual int XMLIO_writeTrailer()
Is called when a document is closed and writes an optional trailer, which must be of Misc-type (XML specs [27]) after the main element (XML specs [1]). By default this writes a newline character.
Returns:
Returns nr of bytes written or an negative error code.

oXMLIO_string xml_filename
Name of opened file.

oint writeAttribute(const XMLIO_string& key, const XMLIO_string& value) const
Writes 'attr="key"' to file (XML Spec [41]).
Returns:
Returns the negative value of fprintf on error, otherwise the number of bytes written (>=0).

oint writeAttributes(const XMLIO_Attributes& attributes) const
Writes 'attr1="key1" attr2="key2" . ' to file (XML Spec [40]).
Returns:
Returns the negative value of fprintf on error, otherwise the number of bytes written (>=0).

oint writeEmptyElement(const XMLIO_string& tag) const
Writes '<tagName/>' to file (XML Spec [44]).
Returns:
Returns the negative value of fprintf on error, otherwise the number of written bytes (>=0).

oint writeEmptyElement(const XMLIO_string& tag, const XMLIO_Attributes& attributes) const
Writes '<tagName attr1="key1" attr2="key2" . />' to file (XML Spec [44]).
Returns:
Returns the negative error code of fprintf on error, otherwise the number of bytes written (>=0).

oFILE* xml_file
XML file stream.

oXMLIO_AccessMode access_mode
Access mode.

oXMLIO_FileType xml_file_type
Type of opened file.

omutable int current_indent
Current number of blanks for indentation.

ochar* indent_block
Memory chunk with blanks and trailing \0.


Direct child classes:
ClusteringReader
XMLIO_ElementReader

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.