OmXmlWriter

Superclass:
Declared In:

Introduction

Writes formatted XML to an OmIByteStream, streaming as it goes (mostly)



Member Functions

addAttribute(const char *, const char *)

Adds an attribute to an element, like <element attr="value">

addAttribute(const char *, long long int)

Adds an attribute to an element from an integer

addAttributeF

Adds an attribute to an element, using printf semantics

addAttributeFBig

Handle oversized attribute. :-/

addAttributeUrlF

Adds an attribute to an element, using printf semantics, and %20 escapes.

addContent

Adds text to an element, like <element>content</element>

addContentF

Adds text to an element, using printf semantics

addContentRaw

Adds text to the document ignoring XML rules But also needed things like rendering DOCTYPE at the start. Caution.

addElement(const char *)

Adds an element with no attributes or content (no need for endElement()) like <hr/>

addElement(const char *, const char *)

Adds an element with content (no need for endElement()) like <h1>Content</h1>

addElementF

Adds an element with content (no need for endElement()) like <h1>Content</h1>

beginElement(const char *)

Begins a new XML element, like <elementName>

beginElement(const char *, const char *, const char *)

Begins a new XML element with one attribute already in it, like <elementName attr="value">

endElement()

Ends the most recent beginElement(). Caps them with either <element/> or </element>.

endElement(const char *)

Ends most recent beginElement, and prints error message if element name does not match.

endElements

Ends any remaining elements.

getByteCount

Bytes written.

getErrorCount

Returns nonzero of any errors occurred, usually buffer overruns leading to missing portions.

OmXmlWriter

Instantiate an XML writer to write into the specified buffer

put
setIndenting

Enables primitive formatting. Uses more bytes of buffer.


addAttribute(const char *, const char *)


Adds an attribute to an element, like <element attr="value">

public

void addAttribute( const char *attribute, const char *value);

addAttribute(const char *, long long int)


Adds an attribute to an element from an integer

public

void addAttribute( const char *attribute, long long int value);

addAttributeF


Adds an attribute to an element, using printf semantics

public

void addAttributeF( const char *attribute, const char *fmt, ...);

addAttributeFBig


Handle oversized attribute. :-/

public

void addAttributeFBig( int reserve, const char *attribute, const char *fmt, ...);

addAttributeUrlF


Adds an attribute to an element, using printf semantics, and %20 escapes.

public

void addAttributeUrlF( const char *attribute, const char *fmt, ...);

addContent


Adds text to an element, like <element>content</element>

public

void addContent( const char *content);

addContentF


Adds text to an element, using printf semantics

public

void addContentF( const char *fmt, ...);

addContentRaw


Adds text to the document ignoring XML rules But also needed things like rendering DOCTYPE at the start. Caution.

public

void addContentRaw( const char *content);

addElement(const char *)


Adds an element with no attributes or content (no need for endElement()) like <hr/>

public

void addElement( const char *elementName);

addElement(const char *, const char *)


Adds an element with content (no need for endElement()) like <h1>Content</h1>

public

void addElement( const char *elementName, const char *content);

addElementF


Adds an element with content (no need for endElement()) like <h1>Content</h1>

public

void addElementF( const char *elementName, const char *fmt, ...);

beginElement(const char *)


Begins a new XML element, like <elementName>

public

void beginElement( const char *elementName);

beginElement(const char *, const char *, const char *)


Begins a new XML element with one attribute already in it, like <elementName attr="value">

public

void beginElement( const char *elementName, const char *attribute1, const char *value1);

endElement()


Ends the most recent beginElement(). Caps them with either <element/> or </element>.

public

void endElement();

endElement(const char *)


Ends most recent beginElement, and prints error message if element name does not match.

public

void endElement( const char *elementName);

endElements


Ends any remaining elements.

public

void endElements();

getByteCount


Bytes written.

public

unsigned int getByteCount();

getErrorCount


Returns nonzero of any errors occurred, usually buffer overruns leading to missing portions.

public

int getErrorCount();

OmXmlWriter


Instantiate an XML writer to write into the specified buffer

public

OmXmlWriter( OmIByteStream *consumer);

put


public

bool put( uint8_t ch) override;
Discussion

Our own put. OmXmlWriter needs to know what context it's in, to manage escapes correctly. also relies upon some new concepts like beginAttribute, <stream a big attribute value>, endAttribute.


setIndenting


Enables primitive formatting. Uses more bytes of buffer.

public

void setIndenting( int onOff);