XmlValue

API Ref

#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; ... };


Description: XmlValue

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 ClassXmlValue Type
No parameterNull
std::string or const char*String
doubleNumber
boolBoolean
XmlDocumentDocument
DOMNodeNode
type and std::stringString 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.


Description: XmlValue()


Description: XmlValue(std::string) or XmlValue(const char *)

Construct an XmlValue object of value type String.

Parameters

v
The XmlValue object value.

Description: XmlValue(double)

Construct an XmlValue object of value type Number.

Parameters

v
The XmlValue object value.

Description: XmlValue(bool)

Construct an XmlValue object of value type Boolean.

Parameters

v
The XmlValue object value.

Description: XmlValue(Type, std::string)

Construct an XmlValue object of the value type provided, converting the string value to the specified type.

Parameters

type
The XmlValue object value type.

v
The XmlValue object value.

Description: XmlValue(XmlDocument)

Construct an XmlValue object of value type Document.

Parameters

v
The XmlValue object value.

Description: XmlValue.isNumber(XmlQueryContext)

Test if the XmlValue is of type Number.

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.

Returns true if the value is a Number.


Description: XmlValue.isString(XmlQueryContext)

Test if the XmlValue is of type String.

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.

Returns true if the value is a String.


Description: XmlValue.isBoolean(XmlQueryContext)

Test if the XmlValue is of type Boolean.

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.

Returns true if the value is a Boolean.


Description: XmlValue.isNode(XmlQueryContext)

Test if the XmlValue is of type Node.

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.

Returns true if the value is a Node.


Description: XmlValue.isDocument(XmlQueryContext)

Test if the XmlValue is of type Node.

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.

Returns true if the value is a Node.


Description: XmlValue.isVariable(XmlQueryContext)

Test if the XmlValue is of type Node.

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.

Returns true if the value is a Node.


Description: XmlValue.getType(XmlQueryContext)

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.

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.

Description: XmlValue.asNumber(XmlQueryContext)

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.
Returns the value as a Number.

Description: XmlValue.asString(XmlQueryContext)

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.
Returns the value as a String.

Description: XmlValue.asBoolean(XmlQueryContext)

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.
Returns the value as a Boolean

Description: XmlValue.asDocument(XmlQueryContext)

Parameters

context
The query context is required to determine the value of an XmlValue of type variable.
Returns the value as a Document.

Description: XmlValue.isNull()

The isNull() method returns true if the XmlValue has no value.


Description: XmlValue.equals(XmlValue,XmlQueryContext)

The equals() method determines if two XmlValue objects represent the same value.

Parameters

value
The value to compare this value with.

context
The query context is required to determine the value of an XmlValue of type variable.
Returns true if the 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.

Errors

The XmlValue cast methods may fail and throw XmlException, encapsulating one of the following non-zero errors:

NO_VARIABLE_BINDING
No query context was provided, or the query context does not contain a value for the XmlValue of type variable.

Class

XmlContainer, XmlDocument, XmlException, XmlIndexSpecification, XmlQueryContext, XmlQueryExpression, XmlResults, XmlUpdateContext, XmlValue

APIRef

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.