Mapper  0.9.0
API documentation
Public Member Functions | List of all members
OpenOrienteering::XmlElementWriter Class Reference

The XmlElementWriter helps to construct a single element in an XML document. More...

#include <xml_stream_util.h>

Public Member Functions

 XmlElementWriter (QXmlStreamWriter &xml, const QLatin1String &element_name)
 Begins a new element with the given name on the XML writer. More...
 
 XmlElementWriter (const XmlElementWriter &)=delete
 
 XmlElementWriter (XmlElementWriter &&)=delete
 
 ~XmlElementWriter ()
 Writes the end tag of the element. More...
 
XmlElementWriteroperator= (const XmlElementWriter &)=delete
 
XmlElementWriteroperator= (XmlElementWriter &&)=delete
 
void writeAttribute (const QLatin1String &qualifiedName, const char *value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const QString &value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const double value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const double value, int precision)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const float value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const float value, int precision)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const qint64 value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const int value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const unsigned int value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const long unsigned int value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, const quint64 value)
 Writes an attribute with the given name and value. More...
 
void writeAttribute (const QLatin1String &qualifiedName, bool value)
 Writes an attribute with the given name and value. More...
 
void write (const QRectF &area)
 Writes attributes named left, top, width and height, representing the given area. More...
 
void write (const QRectF &area, int precision)
 Writes attributes named left, top, width and height, representing the given area. More...
 
void write (const QSizeF &size)
 Writes attributes named width and height, representing the given size. More...
 
void write (const QSizeF &size, int precision)
 Writes attributes named width and height, representing the given size. More...
 
void write (const MapCoordVector &coords)
 Writes the coordinates vector as a simple text format. More...
 
void write (const QHash< QString, QString > &tags)
 Writes tags. More...
 

Detailed Description

The XmlElementWriter helps to construct a single element in an XML document.

It starts a new element on a QXmlStreamWriter when it is constructed, and it writes the end tag when it is destructed. After construction, but before (child) elements are created on the QXmlStreamWriter, it offers convenient functions for writing named attributes of common types.

Typical use:

{
// Construction, begins with start tag
XmlElementWriter coord(xml_writer, QLatin1String("coord"));
coord.writeAttribute(QLatin1String("x"), 34);
coord.writeAttribute(QLatin1String("y"), 3.4);
// Don't use coord once you wrote other data to the stream
writeChildElements(xml_writer);
} // coord goes out of scope here, destructor called, end tag written

Constructor & Destructor Documentation

◆ XmlElementWriter() [1/3]

OpenOrienteering::XmlElementWriter::XmlElementWriter ( QXmlStreamWriter xml,
const QLatin1String element_name 
)
inline

Begins a new element with the given name on the XML writer.

◆ XmlElementWriter() [2/3]

OpenOrienteering::XmlElementWriter::XmlElementWriter ( const XmlElementWriter )
delete

◆ XmlElementWriter() [3/3]

OpenOrienteering::XmlElementWriter::XmlElementWriter ( XmlElementWriter &&  )
delete

◆ ~XmlElementWriter()

OpenOrienteering::XmlElementWriter::~XmlElementWriter ( )
inline

Writes the end tag of the element.

Member Function Documentation

◆ operator=() [1/2]

XmlElementWriter& OpenOrienteering::XmlElementWriter::operator= ( const XmlElementWriter )
delete

◆ operator=() [2/2]

XmlElementWriter& OpenOrienteering::XmlElementWriter::operator= ( XmlElementWriter &&  )
delete

◆ write() [1/6]

void OpenOrienteering::XmlElementWriter::write ( const QRectF area)
inline

Writes attributes named left, top, width and height, representing the given area.

This methods uses Qt's default QString::number(qreal) implementation.

◆ write() [2/6]

void OpenOrienteering::XmlElementWriter::write ( const QRectF area,
int  precision 
)
inline

Writes attributes named left, top, width and height, representing the given area.

◆ write() [3/6]

void OpenOrienteering::XmlElementWriter::write ( const QSizeF size)
inline

Writes attributes named width and height, representing the given size.

This methods uses Qt's default QString::number(qreal) implementation.

◆ write() [4/6]

void OpenOrienteering::XmlElementWriter::write ( const QSizeF size,
int  precision 
)
inline

Writes attributes named width and height, representing the given size.

◆ write() [5/6]

void OpenOrienteering::XmlElementWriter::write ( const MapCoordVector coords)

Writes the coordinates vector as a simple text format.

This is much more efficient than saving each coordinate as rich XML.

◆ write() [6/6]

void OpenOrienteering::XmlElementWriter::write ( const QHash< QString, QString > &  tags)
inline

Writes tags.

◆ writeAttribute() [1/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const char *  value 
)
inline

Writes an attribute with the given name and value.

◆ writeAttribute() [2/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const QString value 
)
inline

Writes an attribute with the given name and value.

◆ writeAttribute() [3/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const double  value 
)
inline

Writes an attribute with the given name and value.

This methods uses Qt's default QString::number(double) implementation.

◆ writeAttribute() [4/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const double  value,
int  precision 
)
inline

Writes an attribute with the given name and value.

The precision represents the number of digits after the decimal point.

◆ writeAttribute() [5/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const float  value 
)
inline

Writes an attribute with the given name and value.

This methods uses Qt's default QString::number(float) implementation.

◆ writeAttribute() [6/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const float  value,
int  precision 
)
inline

Writes an attribute with the given name and value.

The precision represents the number of digits after the decimal point.

◆ writeAttribute() [7/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const qint64  value 
)
inline

Writes an attribute with the given name and value.

◆ writeAttribute() [8/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const int  value 
)
inline

Writes an attribute with the given name and value.

◆ writeAttribute() [9/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const unsigned int  value 
)
inline

Writes an attribute with the given name and value.

◆ writeAttribute() [10/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const long unsigned int  value 
)
inline

Writes an attribute with the given name and value.

◆ writeAttribute() [11/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
const quint64  value 
)
inline

Writes an attribute with the given name and value.

◆ writeAttribute() [12/12]

void OpenOrienteering::XmlElementWriter::writeAttribute ( const QLatin1String qualifiedName,
bool  value 
)
inline

Writes an attribute with the given name and value.


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