textwolf  0.2
Public Types | Public Member Functions | List of all members
textwolf::XMLPrinter< IOCharset, AppCharset, BufferType > Class Template Reference

Character encoding dependent XML printer. More...

#include <xmlprinter.hpp>

Public Types

enum  State { Init, Content, TagAttribute, TagElement }
 Internal state. More...
 

Public Member Functions

void printToBuffer (const char *src, std::size_t srcsize, BufferType &buf) const
 Prints a character string to an STL back insertion sequence buffer in the IO character set encoding. More...
 
void printEsc (char ch, BufferType &buf, unsigned int nof_echr, const char *echr, const char **estr) const
 print a character substitute or the character itself More...
 
void printToBufferSubstChr (const char *src, std::size_t srcsize, BufferType &buf, unsigned int nof_echr, const char *echr, const char **estr) const
 print a value with some characters replaced by a string More...
 
void printToBufferAttributeValue (const char *src, std::size_t srcsize, BufferType &buf) const
 print attribute value string More...
 
void printToBufferContent (const char *src, std::size_t srcsize, BufferType &buf) const
 print content value string More...
 
void printToBuffer (char ch, BufferType &buf) const
 Prints a character to an STL back insertion sequence buffer in the IO character set encoding. More...
 
 XMLPrinter (bool subDocument=false)
 Default constructor. More...
 
 XMLPrinter (const IOCharset &output_, bool subDocument=false)
 Constructor. More...
 
 XMLPrinter (const XMLPrinter &o)
 Copy constructor. More...
 
void reset (bool subDocument=false)
 Reset the state. More...
 
bool printHeader (const char *encoding, const char *standalone, BufferType &buf)
 Prints an XML header (version "1.0") More...
 
bool printDoctype (const char *rootid, const char *publicid, const char *systemid, BufferType &buf)
 Prints an XML <!DOCTYPE ...> declaration. More...
 
bool exitTagContext (BufferType &buf)
 Close the current tag attribute context opened. More...
 
bool printOpenTag (const char *src, std::size_t srcsize, BufferType &buf)
 Print the start of an open tag. More...
 
bool printAttribute (const char *src, std::size_t srcsize, BufferType &buf)
 Print the start of an attribute name. More...
 
bool printValue (const char *src, std::size_t srcsize, BufferType &buf)
 Print a content or attribute value depending on context. More...
 
bool printCloseTag (BufferType &buf)
 Print the close of the current tag open. More...
 
State state () const
 Get the current internal state. More...
 
const char * lasterror () const
 Get the last error occurred. More...
 

Detailed Description

template<class IOCharset, class AppCharset, class BufferType>
class textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >

Character encoding dependent XML printer.

Template Parameters
IOCharsetCharacter set encoding of input and output
AppCharsetCharacter set encoding of the application processor
BufferTypeSTL back insertion sequence to use for printing output

Member Enumeration Documentation

template<class IOCharset , class AppCharset , class BufferType >
enum textwolf::XMLPrinter::State

Internal state.

Enumerator
Init 
Content 
TagAttribute 
TagElement 

Constructor & Destructor Documentation

template<class IOCharset , class AppCharset , class BufferType >
textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::XMLPrinter ( bool  subDocument = false)
inlineexplicit

Default constructor.

Parameters
[in]subDocumentdo not require an Xml header to be printed if set to true
Note
Uses the default code pages (IsoLatin-1 for IsoLatin) for output
template<class IOCharset , class AppCharset , class BufferType >
textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::XMLPrinter ( const IOCharset &  output_,
bool  subDocument = false 
)
inlineexplicit

Constructor.

Parameters
[in]output_character set encoding instance (with the code page tables needed) for output
[in]subDocumentdo not require an Xml header to be printed if set to true
template<class IOCharset , class AppCharset , class BufferType >
textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::XMLPrinter ( const XMLPrinter< IOCharset, AppCharset, BufferType > &  o)
inline

Copy constructor.

Member Function Documentation

template<class IOCharset , class AppCharset , class BufferType >
bool textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::exitTagContext ( BufferType &  buf)
inline

Close the current tag attribute context opened.

Parameters
[out]bufbuffer to print to
Returns
true on success, false if failed (check lasterror())
template<class IOCharset , class AppCharset , class BufferType >
const char* textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::lasterror ( ) const
inline

Get the last error occurred.

Returns
the last error string
template<class IOCharset , class AppCharset , class BufferType >
bool textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printAttribute ( const char *  src,
std::size_t  srcsize,
BufferType &  buf 
)
inline

Print the start of an attribute name.

Parameters
[in]srcstart of the attribute name
[in]srcsizelength of the attribute name in bytes
[out]bufbuffer to print to
Returns
true on success, false if failed (check lasterror())
template<class IOCharset , class AppCharset , class BufferType >
bool textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printCloseTag ( BufferType &  buf)
inline

Print the close of the current tag open.

Parameters
[out]bufbuffer to print to
Returns
true on success, false if failed (check lasterror())
template<class IOCharset , class AppCharset , class BufferType >
bool textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printDoctype ( const char *  rootid,
const char *  publicid,
const char *  systemid,
BufferType &  buf 
)
inline

Prints an XML <!DOCTYPE ...> declaration.

Parameters
[in]rootidroot element name
[in]publicidPUBLIC attribute
[in]systemidSYSTEM attribute
[out]bufbuffer to print to
Returns
true on success, false if failed (check lasterror())
template<class IOCharset , class AppCharset , class BufferType >
void textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printEsc ( char  ch,
BufferType &  buf,
unsigned int  nof_echr,
const char *  echr,
const char **  estr 
) const
inline

print a character substitute or the character itself

Parameters
[in]chcharacter to print
[in,out]bufbuffer to print to
[in]nof_echrnumber of elements in echr and estr
[in]echrASCII characters to substitute
[in]estrASCII strings to substitute with (array parallel to echr)
template<class IOCharset , class AppCharset , class BufferType >
bool textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printHeader ( const char *  encoding,
const char *  standalone,
BufferType &  buf 
)
inline

Prints an XML header (version "1.0")

Parameters
[in]encodingcharacter set encoding name
[in]standalonestandalone attribute ("yes","no" or NULL for undefined)
[out]bufbuffer to print to
Returns
true on success, false if failed (check lasterror())
template<class IOCharset , class AppCharset , class BufferType >
bool textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printOpenTag ( const char *  src,
std::size_t  srcsize,
BufferType &  buf 
)
inline

Print the start of an open tag.

Parameters
[in]srcstart of the tag name
[in]srcsizelength of the tag name in bytes
[out]bufbuffer to print to
Returns
true on success, false if failed (check lasterror())
template<class IOCharset , class AppCharset , class BufferType >
void textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printToBuffer ( const char *  src,
std::size_t  srcsize,
BufferType &  buf 
) const
inline

Prints a character string to an STL back insertion sequence buffer in the IO character set encoding.

Parameters
[in]srcpointer to string to print
[in]srcsizesize of src in bytes
[out]bufbuffer to append result to
template<class IOCharset , class AppCharset , class BufferType >
void textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printToBuffer ( char  ch,
BufferType &  buf 
) const
inline

Prints a character to an STL back insertion sequence buffer in the IO character set encoding.

Parameters
[in]chcharacter to print
[in,out]bufbuffer to print to
template<class IOCharset , class AppCharset , class BufferType >
void textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printToBufferAttributeValue ( const char *  src,
std::size_t  srcsize,
BufferType &  buf 
) const
inline

print attribute value string

Parameters
[in]srcpointer to attribute value string to print
[in]srcsizesize of src in bytes
[in,out]bufbuffer to print to
template<class IOCharset , class AppCharset , class BufferType >
void textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printToBufferContent ( const char *  src,
std::size_t  srcsize,
BufferType &  buf 
) const
inline

print content value string

Parameters
[in]srcpointer to content string to print
[in]srcsizesize of src in bytes
[in,out]bufbuffer to print to
template<class IOCharset , class AppCharset , class BufferType >
void textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printToBufferSubstChr ( const char *  src,
std::size_t  srcsize,
BufferType &  buf,
unsigned int  nof_echr,
const char *  echr,
const char **  estr 
) const
inline

print a value with some characters replaced by a string

Parameters
[in]srcpointer to attribute value string to print
[in]srcsizesize of src in bytes
[in,out]bufbuffer to print to
[in]nof_echrnumber of elements in echr and estr
[in]echrASCII characters to substitute
[in]estrASCII strings to substitute with (array parallel to echr)
template<class IOCharset , class AppCharset , class BufferType >
bool textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::printValue ( const char *  src,
std::size_t  srcsize,
BufferType &  buf 
)
inline

Print a content or attribute value depending on context.

Parameters
[in]srcstart of the value
[in]srcsizelength of the value in bytes
[out]bufbuffer to print to
Returns
true on success, false if failed (check lasterror())
template<class IOCharset , class AppCharset , class BufferType >
void textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::reset ( bool  subDocument = false)
inline

Reset the state.

Parameters
[in]subDocumentdo not require an Xml header to be printed if set to true
template<class IOCharset , class AppCharset , class BufferType >
State textwolf::XMLPrinter< IOCharset, AppCharset, BufferType >::state ( ) const
inline

Get the current internal state.

Returns
the current state

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