XmlValue |
#include <DbXml.hpp>class DbXml::XmlValue { public: XmlValue(); XmlValue(const std::string &value); XmlValue(const char *value); XmlValue(double value); XmlValue(bool value); XmlValue(XmlDocument &value); XmlValue(DOMNode &value, XmlDocument *document); XmlValue(Type type,const std::string &value); virtual ~XmlValue(); XmlValue(const XmlValue &); XmlValue &operator=(const XmlValue &); Type getType(const XmlQueryContext *context=0) const; bool isNumber(const XmlQueryContext *context=0) const; bool isString(const XmlQueryContext *context=0) const; bool isBoolean(const XmlQueryContext *context=0) const; bool isNode(const XmlQueryContext *context=0) const; bool isDocument(const XmlQueryContext *context=0) const; bool isVariable(const XmlQueryContext *context=0) const; bool isNull() const; double asNumber(const XmlQueryContext *context=0) const; std::string asString(const XmlQueryContext *context=0) const; bool asBoolean(const XmlQueryContext *context=0) const; DOMNode *asNode(const XmlQueryContext *context=0) const; XmlDocument asDocument(const XmlQueryContext *context=0) const; bool equals(const XmlValue &value, const XmlQueryContext *context=0) const; ... };
The XmlValue class encapsulates the value of a node in an XML document. XPath 1.0 defines three value types: Boolean, String, and Number. Berkeley DB XML additionally defines the value types None, Node, Document, and Variable.
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 or Class | XmlValue Type |
---|---|
No parameter | Null |
std::string or const char* | String |
double | Number |
bool | Boolean |
XmlDocument | Document |
DOMNode | Node |
type and std::string | String is converted to the specified type. |
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.
Construct an XmlValue object of value type String.
Construct an XmlValue object of value type Number.
Construct an XmlValue object of value type Boolean.
Construct an XmlValue object of the value type provided, converting the string value to the specified type.
Construct an XmlValue object of value type Document.
Test if the XmlValue is of type Number.
Returns true if the value is a Number.
Test if the XmlValue is of type String.
Returns true if the value is a String.
Test if the XmlValue is of type Boolean.
Returns true if the value is a Boolean.
Test if the XmlValue is of type Node.
Returns true if the value is a Node.
Test if the XmlValue is of type Node.
Returns true if the value is a Node.
Test if the XmlValue is of type Node.
Returns true if the value is a Node.
Returns the type of the XmlValue from the enumeration XmlValue::Type. The enumeration values are XmlValue::NONE, XmlValue::STRING, XmlValue::NUMBER, XmlValue::BOOLEAN, XmlValue::DOCUMENT, XmlValue::NODE, XmlValue::VARIABLE.
The isNull() method returns true if the XmlValue has no value.
The equals() method determines if two XmlValue objects represent the same value.
The copy constructor and assignment operator are provided for this class. The class is implemented using a handle-body idiom. When a handle is copied both handles maintain a reference to the same body.
The XmlValue cast methods may fail and throw XmlException, encapsulating one of the following non-zero errors:
Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.