#include <DbXml.hpp> class DbXml::XmlValue { public: XmlValue(); XmlValue(const std::string &value); XmlValue(const char *value); XmlValue(double value); XmlValue(bool value); XmlValue(const XmlDocument &document); XmlValue(Type type, const std::string &value); XmlValue(const std::string &typeURI, const std::string &typeName, const std::string &value); XmlValue(Type type, const XmlData &data); virtual ~XmlValue(); XmlValue(const XmlValue &); XmlValue &operator=(const XmlValue &); bool operator==(const XmlValue &v) const bool equals(const XmlValue &v) const; bool isNull() const; ... };
The XmlValue
class encapsulates the value of a node in an
XML document. The type of the value may be any one of the enumerated
types in the XmlValue::Type
enumeration. There are convenience operators for specially handling
the types of STRING, DOUBLE, and BOOLEAN, as well as a constructor to
make an XmlValue
from
XmlDocument
.
The XmlValue
class provides several constructors, each of
which maps a C++ type or Berkeley DB XML class onto an appropriate
XmlValue
type. The following table lists the
constructor parameter mappings.
C++ Type | XmlValueType |
---|---|
No Parameter | NONE |
std::string or const char * | STRING |
double | DOUBLE |
bool | BOOLEAN |
XmlDocument | NODE |
Type and std::string | String is converted to the specified type. |
Type and XmlData |
XmlData is converted to
the specified type.
|
The Type may be any of of the following:
XmlValue::NONE | XmlValue::G_DAY |
XmlValue::NODE | XmlValue::G_MONTH |
XmlValue::ANY_SIMPLE_TYPE | XmlValue::G_MONTH_DAY |
XmlValue::ANY_URI | XmlValue::G_YEAR |
XmlValue::BASE_64_BINARY | XmlValue::G_YEAR_MONTH |
XmlValue::BOOLEAN | XmlValue::HEX_BINARY |
XmlValue::DATE | XmlValue::NOTATION |
XmlValue::DATE_TIME | XmlValue::QNAME |
XmlValue::DATE_TIME_DURATION | XmlValue::STRING |
XmlValue::DECIMAL | XmlValue::TIME |
XmlValue::DOUBLE | XmlValue::YEAR_MONTH_DURATION |
XmlValue::DURATION | XmlValue::UNTYPE_ATOMIC |
XmlValue::FLOAT | XmlValue::BINARY |
The XmlValue
class implements a set of methods
that test if the XmlValue
is of a named type.
The XmlValue
class also implements a set of
methods that return the XmlValue
as a value of
a specified type. If the XmlValue
is of type
variable and no query context is provided when calling the test or
cast methods, or no binding can be found for the variable, an
exception is thrown.
In addition to type conversion, the XmlValue
class also provides DOM-like navigation functions. Using these, you
can retrieve features from the underlying document, such as the
parent, an attribute, or a child of the current node.
This object is not thread-safe, and can only be safely used by one thread at a time in an application.
The following constructors are available for this class:
XmlValue(std:string &value)
or
XmlValue(const char *value)
Construct an XmlValue
object of type
STRING
.
XmlValue(double value)
Construct an XmlValue
object of type
DOUBLE
.
XmlValue(bool value)
Construct an XmlValue
object of type
BOOLEAN
.
XmlValue(Type, std:string &value)
or
XmlValue(TYPE, const XmlData &value)
Construct an XmlValue
object of the
value Type
, converting the string value
to the specified type.
XmlValue(const std::string &typeURI, const std::string &typeName, const std::string &value)
Construct an XmlValue
object of
the URI and type name provided, converting the string value
to the specified type.
XmlValue(XmlDocument &document)
Construct an XmlValue
object of type
NODE
.