lib

KoXmlWriter Class Reference

#include <KoXmlWriter.h>

List of all members.


Detailed Description

A class for writing out XML (to any QIODevice), with a special attention on performance.

The XML is being written out along the way, which avoids requiring the entire document in memory (like QDom does), and avoids using QTextStream at all (which in Qt3 has major performance issues when converting to utf8).

Definition at line 36 of file KoXmlWriter.h.


Public Member Functions

 KoXmlWriter (QIODevice *dev, int indentLevel=0)
 ~KoXmlWriter ()
QIODevice * device () const
void startDocument (const char *rootElemName, const char *publicId=0, const char *systemId=0)
void endDocument ()
void startElement (const char *tagName, bool indentInside=true)
void addAttribute (const char *attrName, const QString &value)
void addAttribute (const char *attrName, int value)
void addAttribute (const char *attrName, uint value)
void addAttribute (const char *attrName, double value)
void addAttributePt (const char *attrName, double value)
void addAttribute (const char *attrName, const QCString &value)
void addAttribute (const char *attrName, const char *value)
void endElement ()
void addTextNode (const QString &str)
void addTextNode (const QCString &cstr)
void addTextNode (const char *cstr)
void addProcessingInstruction (const char *cstr)
void addCompleteElement (const char *cstr)
void addCompleteElement (QIODevice *dev)
void addManifestEntry (const QString &fullPath, const QString &mediaType)
void addConfigItem (const QString &configName, const QString &value)
void addConfigItem (const QString &configName, bool value)
void addConfigItem (const QString &configName, int value)
void addConfigItem (const QString &configName, double value)
void addConfigItem (const QString &configName, long value)
void addConfigItem (const QString &configName, short value)
void addTextSpan (const QString &text)
void addTextSpan (const QString &text, const QMap< int, int > &tabCache)
int indentLevel () const

Constructor & Destructor Documentation

KoXmlWriter::KoXmlWriter QIODevice *  dev,
int  indentLevel = 0
 

Create a KoXmlWriter instance to write out an XML document into the given QIODevice.

Definition at line 29 of file KoXmlWriter.cpp.

KoXmlWriter::~KoXmlWriter  ) 
 

Destructor.

Definition at line 44 of file KoXmlWriter.cpp.


Member Function Documentation

void KoXmlWriter::addAttribute const char *  attrName,
const char *  value
 

Add an attribute to the current element.

Definition at line 180 of file KoXmlWriter.cpp.

void KoXmlWriter::addAttribute const char *  attrName,
const QCString &  value
[inline]
 

Overloaded version of the one taking a const char* argument, for convenience.

Definition at line 110 of file KoXmlWriter.h.

void KoXmlWriter::addAttribute const char *  attrName,
double  value
 

Add an attribute whose value is a floating point number The number is written out with the highest possible precision (unlike QString::number and setNum, which default to 6 digits).

Definition at line 192 of file KoXmlWriter.cpp.

void KoXmlWriter::addAttribute const char *  attrName,
uint  value
[inline]
 

Add an attribute whose value is an unsigned integer.

Definition at line 90 of file KoXmlWriter.h.

void KoXmlWriter::addAttribute const char *  attrName,
int  value
[inline]
 

Add an attribute whose value is an integer.

Definition at line 82 of file KoXmlWriter.h.

void KoXmlWriter::addAttribute const char *  attrName,
const QString &  value
[inline]
 

Overloaded version of addAttribute( const char*, const char* ), which is a bit slower because it needs to convert value to utf8 first.

Definition at line 76 of file KoXmlWriter.h.

void KoXmlWriter::addAttributePt const char *  attrName,
double  value
 

Add an attribute which represents a distance, measured in pt The number is written out with the highest possible precision (unlike QString::number and setNum, which default to 6 digits), and the unit name ("pt") is appended to it.

Definition at line 199 of file KoXmlWriter.cpp.

void KoXmlWriter::addCompleteElement QIODevice *  dev  ) 
 

This is quite a special-purpose method, not for everyday use.

It adds a complete element (with its attributes and child elements) as a child of the current element. The iodevice is supposed to be escaped for XML already, so it will usually come from another KoXmlWriter. This is usually used with KTempFile.

Definition at line 123 of file KoXmlWriter.cpp.

void KoXmlWriter::addCompleteElement const char *  cstr  ) 
 

This is quite a special-purpose method, not for everyday use.

It adds a complete element (with its attributes and child elements) as a child of the current element. The string is supposed to be escaped for XML already, so it will usually come from another KoXmlWriter.

Definition at line 116 of file KoXmlWriter.cpp.

void KoXmlWriter::addConfigItem const QString &  configName,
short  value
 

Note:
OASIS-specific

Definition at line 336 of file KoXmlWriter.cpp.

void KoXmlWriter::addConfigItem const QString &  configName,
long  value
 

Note:
OASIS-specific

Definition at line 327 of file KoXmlWriter.cpp.

void KoXmlWriter::addConfigItem const QString &  configName,
double  value
 

Note:
OASIS-specific

Definition at line 318 of file KoXmlWriter.cpp.

void KoXmlWriter::addConfigItem const QString &  configName,
int  value
 

Note:
OASIS-specific

Definition at line 309 of file KoXmlWriter.cpp.

void KoXmlWriter::addConfigItem const QString &  configName,
bool  value
 

Note:
OASIS-specific

Definition at line 300 of file KoXmlWriter.cpp.

void KoXmlWriter::addConfigItem const QString &  configName,
const QString &  value
 

Special helper for writing config item into settings.xml.

Note:
OASIS-specific

Definition at line 291 of file KoXmlWriter.cpp.

void KoXmlWriter::addManifestEntry const QString &  fullPath,
const QString &  mediaType
 

Special helper for writing "manifest" files This is equivalent to startElement/2*addAttribute/endElement This API will probably have to change (or not be used anymore) when we add support for encrypting/signing.

Note:
OASIS-specific

Definition at line 283 of file KoXmlWriter.cpp.

void KoXmlWriter::addProcessingInstruction const char *  cstr  ) 
 

Adds a processing instruction.

This writes a processing instruction, like <?foo bar blah?>, where foo is the target, and the rest is the data.

Processing instructions are used in XML to keep processor-specific information in the text of the document.

Definition at line 172 of file KoXmlWriter.cpp.

void KoXmlWriter::addTextNode const char *  cstr  ) 
 

Adds a text node as a child of the current element.

This is appends the litteral content of str to the contents of the element. E.g. addTextNode( "foo" ) inside a <p> element gives <p>foo</p>, and startElement( "b" ); endElement( "b" ); addTextNode( "foo" ) gives <p><b/>foo</p>

Definition at line 163 of file KoXmlWriter.cpp.

void KoXmlWriter::addTextNode const QCString &  cstr  )  [inline]
 

Overloaded version of the one taking a const char* argument.

Definition at line 130 of file KoXmlWriter.h.

void KoXmlWriter::addTextNode const QString &  str  )  [inline]
 

Overloaded version of addTextNode( const char* ), which is a bit slower because it needs to convert str to utf8 first.

Definition at line 126 of file KoXmlWriter.h.

void KoXmlWriter::addTextSpan const QString &  text,
const QMap< int, int > &  tabCache
 

Overloaded version of addTextSpan which takes an additional tabCache map.

Parameters:
text the text to write
tabCache optional map allowing to find a tab for a given character index
Note:
OASIS-specific

Definition at line 351 of file KoXmlWriter.cpp.

void KoXmlWriter::addTextSpan const QString &  text  ) 
 

Adds a text span as nodes of the current element.

Unlike KoXmlWriter::addTextNode it handles tabulations, linebreaks, and multiple spaces by using the appropriate OASIS tags.

Parameters:
text the text to write
Note:
OASIS-specific

Definition at line 345 of file KoXmlWriter.cpp.

void KoXmlWriter::endDocument  ) 
 

Call this to terminate an XML document.

Definition at line 68 of file KoXmlWriter.cpp.

void KoXmlWriter::endElement  ) 
 

Terminate the current element.

After this you should start a new one (sibling), add a sibling text node, or close another one (end of siblings).

Definition at line 140 of file KoXmlWriter.cpp.

int KoXmlWriter::indentLevel  )  const [inline]
 

Returns:
the current indentation level. Useful when creating a sub-KoXmlWriter (see addCompleteElement)

Definition at line 221 of file KoXmlWriter.h.

void KoXmlWriter::startDocument const char *  rootElemName,
const char *  publicId = 0,
const char *  systemId = 0
 

Start the XML document.

This writes out the <?xml?> tag with utf8 encoding, and the DOCTYPE.

Parameters:
rootElemName the name of the root element, used in the DOCTYPE tag.
publicId the public identifier, e.g. "-//OpenOffice.org//DTD OfficeDocument 1.0//EN"
systemId the system identifier, e.g. "office.dtd" or a full URL to it.

Definition at line 50 of file KoXmlWriter.cpp.

void KoXmlWriter::startElement const char *  tagName,
bool  indentInside = true
 

Start a new element, as a child of the current element.

Parameters:
tagName the name of the tag. Warning: this string must remain alive until endElement, no copy is internally made. Usually tagName is a string constant so this is no problem anyway.
indentInside if set to false, there will be no indentation inside this tag. This is useful for elements where whitespace matters.

Definition at line 103 of file KoXmlWriter.cpp.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys