HydraExpress™ C++ API Reference Guide

 
Loading...
Searching...
No Matches
rwsf::XmlStringWriter Class Reference

Implements an rwsf::XmlWriter that uses an std::string as a data sink. More...

#include <rwsf/core/XmlStringWriter.h>

Inheritance diagram for rwsf::XmlStringWriter:
rwsf::XmlWriter

Public Member Functions

 XmlStringWriter (size_t capacity=RWSF_STR_WRITER_BUFFER_SIZE)
void flush ()
size_t getBufferLength () const
size_t getLength () const
std::string getString () const
void resize (size_t size)
void writeToSink (char)
void writeToSink (const char *, size_t)
virtual void writeToSink (const std::string &text)
Public Member Functions inherited from rwsf::XmlWriter
 XmlWriter ()
void addNamespace (const rwsf::XmlNamespace &ns)
void addNamespaceDecl (const rwsf::XmlNamespace &ns)
void decrementIndent ()
int getCurrentIndent () const
bool getIgnoreWhitespace () const
bool getMustEscapeTextDefault () const
int getSizeOfIndent () const
void incrementIndent ()
void setCurrentIndent (int indent)
void setIgnoreWhitespace (bool ignore)
void setMustEscapeTextDefault (bool escape)
int setSizeOfIndent (int indentSize)
void write (const char *textData, size_t textLength, bool mustEscapeText)
void write (const std::string &text)
void write (const std::string &text, bool mustEscapeText)
void writeAttribute (const rwsf::XmlName &name, const char *valueData, size_t valueLength)
void writeAttribute (const rwsf::XmlName &name, const char *valueData, size_t valueLength, bool mustEscapeText)
void writeAttribute (const rwsf::XmlName &name, const std::string &value)
void writeAttribute (const rwsf::XmlName &name, const std::string &value, bool mustEscapeText)
void writeAttribute (const std::string &name, const char *valueData, size_t valueLength)
void writeAttribute (const std::string &name, const char *valueData, size_t valueLength, bool mustEscapeText)
void writeAttribute (const std::string &name, const std::string &value)
void writeAttribute (const std::string &name, const std::string &value, bool mustEscapeText)
void writeElementEnd (const rwsf::XmlName &name)
void writeElementStart (const rwsf::XmlName &name, const rwsf::XmlAttributeSet &attributes=rwsf::XmlAttributeSet(), bool emptyElement=false, const rwsf::XmlName &schemaType=rwsf::XmlName())
void writeIndentChars ()
void writeNewLine ()
void writeSimpleElement (const rwsf::XmlName &name, const char *valueData, size_t valueLength, const rwsf::XmlName &schemaType, bool includeTypeAttribute)
void writeSimpleElement (const rwsf::XmlName &name, const char *valueData, size_t valueLength, const rwsf::XmlName &schemaType, bool mustEscapeText, bool includeTypeAttribute)
void writeSimpleElement (const rwsf::XmlName &name, const char *valueData, size_t valueLength, const std::string &schemaType, bool includeTypeAttribute)
void writeSimpleElement (const rwsf::XmlName &name, const char *valueData, size_t valueLength, const std::string &schemaType, bool mustEscapeText, bool includeTypeAttribute)
void writeSimpleElement (const rwsf::XmlName &name, const std::string &value, const rwsf::XmlName &schemaType, bool includeTypeAttribute)
void writeSimpleElement (const rwsf::XmlName &name, const std::string &value, const std::string &schemaType, bool includeTypeAttribute)
void writeSimpleElement (const rwsf::XmlName &name, const std::string &value, const std::string &schemaType, bool mustEscapeText, bool includeTypeAttribute)
void writeSimpleElement (const std::string &name, const char *valueData, size_t valueLength, const std::string &schemaType, bool includeTypeAttribute)
void writeSimpleElement (const std::string &name, const char *valueData, size_t valueLength, const std::string &schemaType, bool mustEscapeText, bool includeTypeAttribute)
void writeSimpleElement (const std::string &name, const std::string &value, const std::string &schemaType, bool includeTypeAttribute)
void writeSimpleElement (const std::string &name, const std::string &value, const std::string &schemaType, bool mustEscapeText, bool includeTypeAttribute)

(Note that these are not member symbols.)

static const size_t RWSF_STR_WRITER_BUFFER_SIZE

Additional Inherited Members

Static Public Attributes inherited from rwsf::XmlWriter
static const std::string Blank
static const std::string Colon
static const std::string EndTag
static const std::string EqualToAndQuotes
static const std::string FalseValue
static const std::string MarkupAmpersand
static const std::string MarkupApos
static const std::string MarkupCR
static const std::string MarkupGt
static const std::string MarkupLt
static const std::string MarkupQuotes
static const std::string Newline
static const std::string Quotes
static const std::string StartEndTag
static const std::string StartTag
static const std::string TrueValue
static const std::string UnpairedTag
static const std::string WhiteSpace
static const std::string XmlNamespaceTag

Detailed Description

Class rwsf::XmlStringWriter implements an rwsf::XmlWriter that uses an std::string as a data sink. This class provides a string buffer-based implementation of the rwsf::XmlWriter interface to aid in writing XML content to a string.

This class inherits most functions from rwsf::XmlWriter.

Constructor & Destructor Documentation

◆ XmlStringWriter()

rwsf::XmlStringWriter::XmlStringWriter ( size_t capacity = RWSF_STR_WRITER_BUFFER_SIZE)

Constructs an rwsf::XmlStringWriter that contains an empty std::string. The initial capacity of the underlying buffer is set to capacity. The default capacity is defined by RWSF_STR_WRITER_BUFFER_SIZE.

Member Function Documentation

◆ flush()

void rwsf::XmlStringWriter::flush ( )
virtual

Ensures any buffered data has been written.

Implements rwsf::XmlWriter.

◆ getBufferLength()

size_t rwsf::XmlStringWriter::getBufferLength ( ) const

Returns the length of the buffer.

◆ getLength()

size_t rwsf::XmlStringWriter::getLength ( ) const

Returns the length of the std::string this object contains.

◆ getString()

std::string rwsf::XmlStringWriter::getString ( ) const

Returns the std::string this object contains.

◆ resize()

void rwsf::XmlStringWriter::resize ( size_t size)

Resizes this rwsf::XmlStringWriter object's internal character buffer to size. If size is less than the current position in the buffer, the buffer is truncated to the new size and the position set to the end of the buffer.

◆ writeToSink() [1/3]

void rwsf::XmlStringWriter::writeToSink ( char c)
virtual

Pure virtual function. In a derived class, this function writes a single character c to the underlying data sink.

Implements rwsf::XmlWriter.

◆ writeToSink() [2/3]

void rwsf::XmlStringWriter::writeToSink ( const char * str,
size_t len )
virtual

Pure virtual function. In a derived class, this function writes the contents of str limited to the length of len to the underlying data sink.

Implements rwsf::XmlWriter.

◆ writeToSink() [3/3]

virtual void rwsf::XmlWriter::writeToSink ( const std::string & text)
inlinevirtual

Writes a string text to the underlying data sink. By default this function calls the writeToSink(const char* str, size_t len) function with the appropriate data and length.

Reimplemented from rwsf::XmlWriter.

◆ RWSF_STR_WRITER_BUFFER_SIZE

const size_t RWSF_STR_WRITER_BUFFER_SIZE
related

This constant declares the size of the XmlStringWriter internal buffer. The built-in default size is 4kb (4096 bytes).

Copyright © 2026 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.