OmEspHelpers
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
OmXmlWriter Class Reference

#include <OmXmlWriter.h>

Inheritance diagram for OmXmlWriter:
OmIByteStream

Public Member Functions

 OmXmlWriter (OmIByteStream *consumer)
 Instantiate an XML writer to write into the specified buffer.
 
void beginElement (const char *elementName)
 Begins a new XML element, like <elementName>
 
void beginElement (const char *elementName, const char *attribute1, const char *value1)
 Begins a new XML element with one attribute already in it, like <elementName attr="value">
 
void addContent (const char *content)
 Adds text to an element, like <element>content</element>
 
void addContentRaw (const char *content)
 Adds text to the document ignoring XML rules But also needed things like rendering DOCTYPE at the start. Caution.
 
void addContentF (const char *fmt,...)
 Adds text to an element, using printf semantics.
 
void addAttribute (const char *attribute, const char *value)
 Adds an attribute to an element, like <element attr="value">
 
void addAttributeF (const char *attribute, const char *fmt,...)
 Adds an attribute to an element, using printf semantics.
 
void addAttributeFBig (int reserve, const char *attribute, const char *fmt,...)
 Handle oversized attribute. :-/.
 
void addAttributeUrlF (const char *attribute, const char *fmt,...)
 Adds an attribute to an element, using printf semantics, and %20 escapes.
 
void addAttribute (const char *attribute, long long int value)
 Adds an attribute to an element from an integer.
 
void addElement (const char *elementName)
 Adds an element with no attributes or content (no need for endElement()) like <hr/>
 
void addElement (const char *elementName, const char *content)
 Adds an element with content (no need for endElement()) like <h1>Content</h1>
 
void addElementF (const char *elementName, const char *fmt,...)
 Adds an element with content (no need for endElement()) like <h1>Content</h1>
 
void endElement ()
 Ends the most recent beginElement(). Caps them with either <element/> or </element>.
 
void endElement (const char *elementName)
 Ends most recent beginElement, and prints error message if element name does not match.
 
void endElements ()
 Ends any remaining elements.
 
void addRawContent (const char *rawContent)
 Add content directly to the output stream, no escaping or element balancing. You can definitely break your XML output with this! Use wisely.
 
void setIndenting (int onOff)
 Enables primitive formatting. Uses more bytes of buffer.
 
int getErrorCount ()
 Returns nonzero of any errors occurred, usually buffer overruns leading to missing portions.
 
unsigned int getByteCount ()
 Bytes written.
 
bool put (uint8_t ch) override
 
bool done () override
 
void beginAttribute (const char *attributeName)
 
void endAttribute ()
 
void putf (const char *fmt,...)
 
bool puts (const char *stuff, bool contentEscapes=false)
 
- Public Member Functions inherited from OmIByteStream
virtual bool putS (const char *s)
 convenience routine, same as put byte-by-byte.
 

Public Attributes

OmIByteStreamconsumer = 0
 
int depth = 0
 
int hasAnything [kOmXmlMaxDepth]
 
const char * elementName [kOmXmlMaxDepth]
 
int position = 0
 
bool indenting = false
 
int errorCount = 0
 
unsigned int byteCount = 0
 
const char * attributeName = 0
 
- Public Attributes inherited from OmIByteStream
bool isDone = false
 

Static Public Attributes

static const int kOmXmlMaxDepth = 20
 

Detailed Description

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

Member Function Documentation

◆ put()

bool OmXmlWriter::put ( uint8_t  ch)
overridevirtual

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.

Reimplemented from OmIByteStream.


The documentation for this class was generated from the following files: