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(Type type,const std::string &value); XmlValue(Type type,const XmlData &data);

virtual ~XmlValue(); XmlValue(const XmlValue &); XmlValue &operator=(const XmlValue &);

Type getType() const;

bool isType(XmlValue::Type type) const bool isNumber() const; bool isString() const; bool isBoolean() const; bool isBinary() const; bool isNode() const;

bool isNull() const;

double asNumber() const; std::string asString() const; bool asBoolean() const; bool asBinary() const; DOMNode *asNode() const; const XmlDocument &asDocument() const;

bool operator==(const XmlValue &v) const bool equals(const XmlValue &v) const;

std::string getNodeName() const std::string getNodeValue() const std::string getNamespaceURI() const std::string getPrefix() const std::string getLocalName() const short getNodeType() const XmlValue getParentNode() const XmlValue getFirstChild() const XmlValue getLastChild() const XmlValue getPreviousSibling() const XmlValue getNextSibling() const XmlResults getAttributes() const XmlValue getOwnerElement() const ... };


Description: XmlValue

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 or ClassXmlValue Type
No parameterNONE
std::string or const char*STRING
doubleDOUBLE
boolBOOLEAN
XmlDocumentNODE
Type and std::stringString is converted to the specified type.
Type and XmlDataXmlData is converted to the specified type.

The Type may be any of of the following:

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.

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

Construct an XmlValue object of value type STRING.

Parameters

value
The XmlValue object value.

Description: XmlValue(double value)

Construct an XmlValue object of value type DOUBLE.

Parameters

value
The XmlValue object value.

Description: XmlValue(bool value)

Construct an XmlValue object of value type BOOLEAN.

Parameters

value
The XmlValue object value.

Description: XmlValue(Type, const std::string &value) or XmlValue(Type, const XmlData &value)

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

Parameters

type
The XmlValue object value type.
value
The XmlValue object value.

Description: XmlValue(XmlDocument &document)

Construct an XmlValue object of value type NODE.

Parameters

document
The XmlValue object value.

Description: XmlValue::isNumber()

Returns true if the XmlValue is one of the numeric types, such as DOUBLE, FLOAT, etc.


Description: XmlValue::isString()

Returns true if the XmlValue is one of type STRING.


Description: XmlValue::isBinary()

Returns true if the XmlValue is one of type BINARY.


Description: XmlValue::isBoolean()

Returns true if the XmlValue is one of type BOOLEAN.


Description: XmlValue::isNode()

Returns true if the XmlValue is one of type NODE.


Description: XmlValue::isNull()

Returns true if the XmlValue has no value (type NONE).


Description: XmlValue::getType()

Returns the type of the XmlValue from the enumeration XmlValue::Type.

Valid values for XmlValue::Type are NONE, NODE, ANY_SIMPLE_TYPE, ANY_URI, BASE_64_BINARY, BOOLEAN, DATE, DATE_TIME, DAY_TIME_DURATION, DECIMAL, DOUBLE, DURATION, FLOAT, G_DAY, G_MONTH, G_MONTH_DAY, G_YEAR, G_YEAR_MONTH, HEX_BINARY, NOTATION, QNAME, STRING, TIME, YEAR_MONTH_DURATION, UNTYPED_ATOMIC, BINARY.


Description: XmlValue::isType(XmlValue::Type type)

Indicates whether the XmlValue is of the specified type.

Valid values for XmlValue::Type are NONE, NODE, ANY_SIMPLE_TYPE, ANY_URI, BASE_64_BINARY, BOOLEAN, DATE, DATE_TIME, DAY_TIME_DURATION, DECIMAL, DOUBLE, DURATION, FLOAT, G_DAY, G_MONTH, G_MONTH_DAY, G_YEAR, G_YEAR_MONTH, HEX_BINARY, NOTATION, QNAME, STRING, TIME, YEAR_MONTH_DURATION, UNTYPED_ATOMIC, BINARY.


Description: XmlValue::asNumber()

Returns the value as a DOUBLE.


Description: XmlValue::asString()

Returns the value as a STRING.


Description: XmlValue::asBinary()

Returns the value as a BINARY if it of type XmlValue::BINARY.


Description: XmlValue::asBoolean()

Returns the value as a BOOLEAN.


Description: XmlValue::asDocument()

Returns the value as an XmlDocument.


Description: XmlValue::asNode()

Returns the value as a XercesC DOMNode.


Description: XmlValue::equals(XmlValue &value)

Determines if two XmlValue objects represent the same value. It returns true if the two XmlValue objects represent the same value.

Parameters

value
The value to compare this value with.

Description: XmlValue::getNodeName() const

Returns the name of the node contained in this XmlValue.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getNodeValue() const

Returns the node's value.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getNamespaceURI() const

Returns the URI used for the node's namespace.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getPrefix() const

Returns the prefix set for the node's namespace.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getLocalName() const

Returns the node's local name. For example, if a node has the namespace prefix, "prefix," and its qualified name is prefix:name, then 'name' is the local name.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getNodeType() const

Returns the short value for this node's XercesC DOMNode::NodeType.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getParentNode() const

Returns current node's parent. If the node has no parent, a null node is returned.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getFirstChild() const

Returns current node's first child node. If the node has no children, a null node is returned.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getLastChild() const

Returns current node's last child node. If the node has no children, a null node is returned.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getPreviousSibling() const

Returns the sibling node immediately preceding this node in the document. If the current node had no siblings preceding it in the document, a null node is returned.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getNextSibling() const

Returns the sibling node immediately following this node in the document. If the current node had no siblings following it in the document, a null node is returned.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getAttributes() const

Returns returns a XmlResults that contains all of the attributes appearing on this node.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


Description: XmlValue::getOwnerElement() const

If the current node is an attribute node, returns the document element node that contains this attribute node. Otherwise, XmlException::INVALID_VALUE is thrown.

If the node type is not XmlValue::NODE, XmlException::INVALID_VALUE is thrown.


APIRef

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