My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
QhpXmlWriter Class Reference

#include <qhpxmlwriter.h>

Public Member Functions

 QhpXmlWriter ()
 
 ~QhpXmlWriter ()
 
void setIndentLevel (int level)
 
void setCompressionEnabled (bool enabled)
 
void insert (QhpXmlWriter const &source)
 
void dumpTo (QFile &file)
 
void open (char const *elementName, char const *const *attributes=0)
 
void openClose (char const *elementName, char const *const *attributes=0)
 
void openCloseContent (char const *elementName, char const *content)
 
void close (char const *elementName)
 
void declaration (char const *version, char const *encoding)
 

Static Public Member Functions

static char * dupEscaped (const char *source)
 

Private Member Functions

void indent ()
 
void newLine ()
 
void openPureHelper (char const *elementName, char const *const *attributes, bool close)
 
void openPure (char const *elementName, char const *const *attributes=0)
 
void openClosePure (char const *elementName, char const *const *attributes=0)
 
void closePure (char const *elementName)
 

Private Attributes

QGString m_backend
 
FTextStream m_out
 
int m_indentLevel
 
bool m_curLineIndented
 
bool m_compress
 

Detailed Description

Definition at line 25 of file qhpxmlwriter.h.

Constructor & Destructor Documentation

QhpXmlWriter::QhpXmlWriter ( )

Definition at line 22 of file qhpxmlwriter.cpp.

QhpXmlWriter::~QhpXmlWriter ( )

Definition at line 28 of file qhpxmlwriter.cpp.

{
}

Member Function Documentation

void QhpXmlWriter::close ( char const *  elementName)

Definition at line 79 of file qhpxmlwriter.cpp.

References closePure(), indent(), m_indentLevel, and newLine().

Referenced by Qhp::addContentsItem(), Qhp::finalize(), and Qhp::initialize().

{
indent();
closePure(elementName);
}
void QhpXmlWriter::closePure ( char const *  elementName)
private

Definition at line 153 of file qhpxmlwriter.cpp.

References m_out.

Referenced by close(), and openCloseContent().

{
m_out << "</" << elementName << ">";
}
void QhpXmlWriter::declaration ( char const *  version,
char const *  encoding 
)

Definition at line 87 of file qhpxmlwriter.cpp.

References m_out, and newLine().

Referenced by Qhp::initialize().

{
m_out << "<?xml version=\"" << version << "\" encoding=\"" << encoding << "\"?>";
}
void QhpXmlWriter::dumpTo ( QFile &  file)

Definition at line 47 of file qhpxmlwriter.cpp.

References m_backend.

Referenced by Qhp::finalize().

{
file.writeBlock(m_backend.data(), m_backend.length());
}
static char* QhpXmlWriter::dupEscaped ( const char *  source)
static
void QhpXmlWriter::indent ( )
private

Definition at line 93 of file qhpxmlwriter.cpp.

References m_curLineIndented, m_indentLevel, and m_out.

Referenced by close(), open(), openClose(), and openCloseContent().

{
{
return;
}
for (int i = 0; i < m_indentLevel; i++)
{
m_out << " ";
}
}
void QhpXmlWriter::insert ( QhpXmlWriter const &  source)

Definition at line 42 of file qhpxmlwriter.cpp.

References m_backend, and m_out.

Referenced by Qhp::finalize().

{
m_out << source.m_backend.data();
}
void QhpXmlWriter::newLine ( )
private

Definition at line 106 of file qhpxmlwriter.cpp.

References m_compress, m_curLineIndented, and m_out.

Referenced by close(), declaration(), open(), openClose(), and openCloseContent().

{
if (!m_compress)
{
m_out << "\n";
}
}
void QhpXmlWriter::open ( char const *  elementName,
char const *const *  attributes = 0 
)

Definition at line 52 of file qhpxmlwriter.cpp.

References indent(), m_indentLevel, newLine(), and openPure().

Referenced by Qhp::handlePrevSection(), and Qhp::initialize().

{
indent();
openPure(elementName, attributes);
}
void QhpXmlWriter::openClose ( char const *  elementName,
char const *const *  attributes = 0 
)

Definition at line 61 of file qhpxmlwriter.cpp.

References indent(), newLine(), and openClosePure().

Referenced by Qhp::addIndexItem(), and Qhp::handlePrevSection().

{
indent();
openClosePure(elementName, attributes);
}
void QhpXmlWriter::openCloseContent ( char const *  elementName,
char const *  content 
)

Definition at line 69 of file qhpxmlwriter.cpp.

References closePure(), convertToXML(), indent(), m_out, newLine(), and openPure().

Referenced by Qhp::addFile(), and Qhp::initialize().

{
indent();
openPure(elementName);
m_out << convertToXML(content);
closePure(elementName);
}
void QhpXmlWriter::openClosePure ( char const *  elementName,
char const *const *  attributes = 0 
)
private

Definition at line 147 of file qhpxmlwriter.cpp.

References openPureHelper().

Referenced by openClose().

{
openPureHelper(elementName, attributes, true);
}
void QhpXmlWriter::openPure ( char const *  elementName,
char const *const *  attributes = 0 
)
private

Definition at line 141 of file qhpxmlwriter.cpp.

References openPureHelper().

Referenced by open(), and openCloseContent().

{
openPureHelper(elementName, attributes, false);
}
void QhpXmlWriter::openPureHelper ( char const *  elementName,
char const *const *  attributes,
bool  close 
)
private

Definition at line 115 of file qhpxmlwriter.cpp.

References convertToXML(), and m_out.

Referenced by openClosePure(), and openPure().

{
m_out << "<" << elementName;
if (attributes)
{
for (char const * const * walker = attributes;
walker[0]; walker += 2)
{
char const * const key = walker[0];
char const * const value = walker[1];
if (!value)
{
continue;
}
m_out << " " << key << "=\"" << convertToXML(value) << "\"";
}
}
if (close)
{
m_out << " /";
}
m_out << ">";
}
void QhpXmlWriter::setCompressionEnabled ( bool  enabled)

Definition at line 37 of file qhpxmlwriter.cpp.

References m_compress.

{
m_compress = enabled;
}
void QhpXmlWriter::setIndentLevel ( int  level)

Definition at line 32 of file qhpxmlwriter.cpp.

References m_indentLevel.

Referenced by Qhp::Qhp().

{
m_indentLevel = level;
}

Member Data Documentation

QGString QhpXmlWriter::m_backend
private

Definition at line 56 of file qhpxmlwriter.h.

Referenced by dumpTo(), and insert().

bool QhpXmlWriter::m_compress
private

Definition at line 60 of file qhpxmlwriter.h.

Referenced by newLine(), and setCompressionEnabled().

bool QhpXmlWriter::m_curLineIndented
private

Definition at line 59 of file qhpxmlwriter.h.

Referenced by indent(), and newLine().

int QhpXmlWriter::m_indentLevel
private

Definition at line 58 of file qhpxmlwriter.h.

Referenced by close(), indent(), open(), and setIndentLevel().

FTextStream QhpXmlWriter::m_out
private

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