![]() |
Mapper
0.9.0
API documentation
|
The XmlElementReader helps to read a single element in an XML document. More...
#include <xml_stream_util.h>
Public Member Functions | |
XmlElementReader (QXmlStreamReader &xml) | |
Constructs a new element reader on the given XML reader. More... | |
XmlElementReader (const XmlElementReader &)=delete | |
XmlElementReader (XmlElementReader &&)=delete | |
~XmlElementReader () | |
Destructor. More... | |
XmlElementReader & | operator= (const XmlElementReader &)=delete |
XmlElementReader & | operator= (XmlElementReader &&)=delete |
bool | hasAttribute (const QLatin1String &qualifiedName) const |
Tests whether the element has an attribute with the given name. More... | |
bool | hasAttribute (const QString &qualifiedName) const |
Tests whether the element has an attribute with the given name. More... | |
template<typename T > | |
T | attribute (const QLatin1String &qualifiedName) const |
Returns the value of an attribute of type T. More... | |
void | read (QRectF &area) |
Reads attributes named left, top, width, height into the given area object. More... | |
void | read (QSizeF &size) |
Reads attributes named width and height into the given size object. More... | |
void | read (MapCoordVector &coords) |
Reads the coordinates vector from a simple text format. More... | |
void | readForText (MapCoordVector &coords) |
Reads the coordinates vector for a text object. More... | |
void | read (QHash< QString, QString > &tags) |
Read tags. More... | |
template<> | |
QString | attribute (const QLatin1String &qualifiedName) const |
template<> | |
qint64 | attribute (const QLatin1String &qualifiedName) const |
template<> | |
int | attribute (const QLatin1String &qualifiedName) const |
template<> | |
unsigned int | attribute (const QLatin1String &qualifiedName) const |
template<> | |
long unsigned int | attribute (const QLatin1String &qualifiedName) const |
template<> | |
double | attribute (const QLatin1String &qualifiedName) const |
template<> | |
float | attribute (const QLatin1String &qualifiedName) const |
template<> | |
bool | attribute (const QLatin1String &qualifiedName) const |
template<> | |
QStringRef | attribute (const QLatin1String &qualifiedName) const |
The XmlElementReader helps to read a single element in an XML document.
It assumes to be on a QXmlStreamReader::StartElement when constructed, and it reads until the end of the current element, skipping any child nodes, when it is destructed. After construction, it offers convenient functions for reading named attributes of common types.
Typical use:
|
inline |
Constructs a new element reader on the given XML reader.
It assumes to be on a QXmlStreamReader::StartElement.
|
delete |
|
delete |
|
inline |
Destructor.
Reads until the end of the current element, skipping any child nodes.
|
inline |
Returns the value of an attribute of type T.
Apart from a number of specializations for common types, it has a general implementation which read the attribute as int and does static_cast to the actual type. This is useful for enumerations, but might also be a cause of buildtime or runtime errors.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Tests whether the element has an attribute with the given name.
Tests whether the element has an attribute with the given name.
|
delete |
|
delete |
|
inline |
Reads attributes named left, top, width, height into the given area object.
Counterpart for XmlElementWriter::write(const QRectF&, int).
|
inline |
Reads attributes named width and height into the given size object.
Counterpart for XmlElementWriter::write(const QSizeF&, int).
void OpenOrienteering::XmlElementReader::read | ( | MapCoordVector & | coords | ) |
Reads the coordinates vector from a simple text format.
This is much more efficient than loading each coordinate from rich XML.
void OpenOrienteering::XmlElementReader::readForText | ( | MapCoordVector & | coords | ) |
Reads the coordinates vector for a text object.
This is either a single anchor, or an anchor and a size, packed as a coordinates vector. Regular coordinate bounds checking is not applied to the size.