Public Member Functions | Static Public Member Functions | Friends | List of all members
Item Class Reference

The Zorba Item interface. More...

Public Member Functions

void close ()
 Free all resources aquired by this Item. More...
 
Iterator getAtomizationValue () const
 Get the atomization value of the Item. More...
 
Iterator getAttributes () const
 Get an iterator for the attributes of this (node) Item. More...
 
bool getBooleanValue () const
 Get the bool value of the boolean Item. More...
 
Iterator getChildren () const
 Get an iterator for the children of this (node) Item. More...
 
double getDoubleValue () const
 Get the int value of the Item. More...
 
Item getEBV () const
 Get the effective boolean value of the Item. More...
 
int getIntValue () const
 Get the int value of the Item. More...
 
std::string getLocalName () const
 Get the value of a QName's local name. More...
 
long long getLongValue () const
 Get the long value of the Item. More...
 
std::string getNamespace () const
 Get the (optional) value of a QName's namespace. More...
 
std::vector< std::pair
< std::string, std::string > > 
getNamespaceBindings ()
 Get a vector for the namespace bindings of this (element) Item. More...
 
int getNodeKind () const
 Get the type of this (node) Item. More...
 
bool getNodeName (Item &aNodeName) const
 Get the name of this (node) Item. More...
 
Item getParent () const
 Get parent of this (node) Item. More...
 
std::string getPrefix () const
 Get the (optional) value of a QName's prefix. More...
 
std::string getStringValue () const
 Get the string value of the Item. More...
 
Item getType () const
 Get the type of the Item. More...
 
unsigned int getUnsignedIntValue () const
 
bool isAtomic () const
 Check if the Item is an atomic Item. More...
 
bool isNaN () const
 Check if the value of the Item is not a number (NaN). More...
 
bool isNode () const
 Check if the Item is a node Item. More...
 
bool isNull () const
 Check if the Item is null. More...
 
bool isPosOrNegInf () const
 Check if the value of the Item is positive or negative infinity. More...
 
 Item ()
 Default constructor. More...
 
 Item (const Item &aItem)
 Copy constructor. More...
 
 Item (const zorba::Item &aZItem)
 Constructor that is used to construct Items in the Zorba engine itself. More...
 
std::string serialize () const
 Serializes the object. More...
 
std::string serialize (SerializationOptions serOptions) const
 Serializes the object. More...
 
void serializeToStream (ZorbaIOStream &aStream) const
 Serializes the object. More...
 
void serializeToStream (ZorbaIOStream &aStream, SerializationOptions serOptions) const
 Serializes the object. More...
 

Static Public Member Functions

static Item createEmptyItem ()
 Static constructor. More...
 

Friends

class Collection
 
class CollectionManager
 
class DocumentManager
 
class DynamicContext
 
class ItemFactory
 
class ItemSequence
 
class Iterator
 
class SingletonIterator
 
class StaticCollectionManager
 
class StaticContext
 

Detailed Description

The Zorba Item interface.

This class is the Zorba representation of an Item as defined in the XQuery 1.0 and XPath 2.0 Data Model (XDM); see http://www.w3.org/TR/xpath-datamodel/.

Instances of the XDM are a sequence, i.e. an ordered collection of zero or more items. In the Zorba API, a sequence is represented by the ItemSequence class.

The Item class is the union of all XQuery node and atomic types. The class provides functions to access the information of an Item. Note that not all functions are defined on every Item kind. If a function is called on an Item that does not provide the called function, an ZXQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE error is raised.

Instances of the Item class are always passed by copy. To check whether a given Item is valid isNull() can be called which returns true if the given Item is not valid and false otherwise. A new atomic Item can be created using the ItemFactory. A new node Item should be created by the result of a query.

Examples:
ruby_test.rb.

Definition at line 39 of file Item.h.

Constructor & Destructor Documentation

Item::Item ( )
inline

Default constructor.

Definition at line 57 of file Item.h.

Item::Item ( const Item aItem)
inline

Copy constructor.

Definition at line 60 of file Item.h.

Item::Item ( const zorba::Item &  aZItem)
inline

Constructor that is used to construct Items in the Zorba engine itself.

This constructor is for internal use only.

Definition at line 65 of file Item.h.

Member Function Documentation

void Item::close ( )

Free all resources aquired by this Item.

After calling close() on an Item the Item is invalidated, i.e. a subsequent call to isNull() will return true.

Note that calling this function is usually not necessary because close() is implicitly called by the destructor. Calling close() is only necessary if the resources aquired by an Item should be released before the Item goes out of scope, i.e. the destructor is called.

Also note that this function is available for all types of Items.

static Item Item::createEmptyItem ( )
static

Static constructor.

Iterator Item::getAtomizationValue ( ) const

Get the atomization value of the Item.

The atomization value is the value that is returned by atomization (see http://www.w3.org/TR/xquery/#id-atomization). Note that this function is available for all types of Items.

Returns
Item the atomization value of the Item.
Exceptions
ZorbaExceptionif an error occured.
Iterator Item::getAttributes ( ) const

Get an iterator for the attributes of this (node) Item.

Note that this function is only available for node Items.

Returns
Iterator over the attributes of this node.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not of type node.
bool Item::getBooleanValue ( ) const

Get the bool value of the boolean Item.

Note that this function is only available for Items of type boolean.

Returns
true if the boolean value is true, false otherwise.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not of type boolean.
Iterator Item::getChildren ( ) const

Get an iterator for the children of this (node) Item.

Note that this function is only available for node Items.

Returns
Iterator over the children of this node.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not of type node.
double Item::getDoubleValue ( ) const

Get the int value of the Item.

Returns
Item the int value of the Item.
Exceptions
ZorbaExceptionif an error occured.
Item Item::getEBV ( ) const

Get the effective boolean value of the Item.

The effective boolean value is the result of applying the fn:boolean function on the Item (see http://www.w3.org/TR/xpath-functions/#func-boolean). Note that this function is available for all types of Items.

Returns
Item the effective boolean value of the Item
Exceptions
ZorbaExceptionif an error occured.
int Item::getIntValue ( ) const

Get the int value of the Item.

Returns
Item the int value of the Item.
Exceptions
ZorbaExceptionif an error occured.
std::string Item::getLocalName ( ) const

Get the value of a QName's local name.

Note that this function is only available for Items of type QName.

Returns
String the local name of the QName.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not a QName.
long long Item::getLongValue ( ) const

Get the long value of the Item.

Returns
Item the long value of the Item.
Exceptions
ZorbaExceptionif an error occured.
std::string Item::getNamespace ( ) const

Get the (optional) value of a QName's namespace.

Note that this function is only available for Items of type QName.

Returns
String the namespace URI of the QName.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not a QName.
std::vector< std::pair< std::string, std::string > > Item::getNamespaceBindings ( )

Get a vector for the namespace bindings of this (element) Item.

Note that this function is only available for element Items.

Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not of type element.
int Item::getNodeKind ( ) const

Get the type of this (node) Item.

Note that this function is only available for node Items.

Returns
int the kind of this node (the avaialble kinds can be found in the store::StoreConsts class)
Exceptions
ZorbaExceptionif an error occured (e.g. the Item is not of type node).
bool Item::getNodeName ( Item aNodeName) const

Get the name of this (node) Item.

Note that this function is only available for node Items.

Returns
bool if the name of the node was retrieved successfully
Parameters
aNodeNamethe name of the node
Exceptions
ZorbaExceptionif an error occured (e.g. the Item is not of type node).
Item Item::getParent ( ) const

Get parent of this (node) Item.

Note that this function is only available for node Items.

Returns
element or document parent node of this node.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not of type node.
std::string Item::getPrefix ( ) const

Get the (optional) value of a QName's prefix.

Note that this function is only available for Items of type QName.

Returns
String the prefix of the QName.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not a QName.
std::string Item::getStringValue ( ) const

Get the string value of the Item.

The string value is the string that is extracted by calling the fn:string function on the Item (see http://www.w3.org/TR/xpath-functions/#func-string). Note that this function is available for all types of Items.

Returns
Item the string value of the Item.
Exceptions
ZorbaExceptionif an error occured.
Item Item::getType ( ) const

Get the type of the Item.

See http://www.w3.org/TR/xpath-datamodel/#types. Note that this function is available for all types of Items.

Returns
Item the type of the Item as a QName Item
Exceptions
ZorbaExceptionif an error occured.
unsigned int Item::getUnsignedIntValue ( ) const
bool Item::isAtomic ( ) const

Check if the Item is an atomic Item.

Note that this function is available for all types of Items.

Returns
true if the Item is an atomic Item, false otherwise.
bool Item::isNaN ( ) const

Check if the value of the Item is not a number (NaN).

Note that this function is only available for numeric Items (e.g. Double or Float).

Returns
true if the Item is NaN, false otherwise.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not a numeric type.
bool Item::isNode ( ) const

Check if the Item is a node Item.

Note that this function is available for all types of Items.

Returns
true if the Item is of type node, false otherwise.
bool Item::isNull ( ) const

Check if the Item is null.

If this function returns true, the Item is not valid. Note that this function is available for all types of Items.

Returns
true if the Item is null, false otherwise.
bool Item::isPosOrNegInf ( ) const

Check if the value of the Item is positive or negative infinity.

Note that this function is only available for numeric Items (e.g. Double or Float).

Returns
true if the Item is +/-INF, false otherwise.
Exceptions
ZorbaExceptionif an error occured, e.g. the Item is not a numeric type.
std::string Item::serialize ( ) const

Serializes the object.

Returns a string with the value of the object serialized

Returns
The string value of the Item.
Exceptions
ZorbaExceptionif an error occured.
std::string Item::serialize ( SerializationOptions  serOptions) const

Serializes the object.

Returns a string with the value of the object serialized

Parameters
serOptionsThe serialization options for this Item
Returns
The string value of the Item.
Exceptions
ZorbaExceptionif an error occured.
void Item::serializeToStream ( ZorbaIOStream aStream) const

Serializes the object.

Put the serialized object into the specified stream.

Parameters
aStreamThe stream to write the value of the Item.
Exceptions
ZorbaExceptionif an error occured.
void Item::serializeToStream ( ZorbaIOStream aStream,
SerializationOptions  serOptions 
) const

Serializes the object.

Put the serialized object into the specified stream.

Parameters
aStreamThe stream to write the value of the Item.
serOptionsThe serialization options for this Item
Exceptions
ZorbaExceptionif an error occured.

Friends And Related Function Documentation

friend class Collection
friend

Definition at line 47 of file Item.h.

friend class CollectionManager
friend

Definition at line 48 of file Item.h.

friend class DocumentManager
friend

Definition at line 43 of file Item.h.

friend class DynamicContext
friend

Definition at line 45 of file Item.h.

friend class ItemFactory
friend

Definition at line 46 of file Item.h.

friend class ItemSequence
friend

Definition at line 50 of file Item.h.

friend class Iterator
friend

Definition at line 41 of file Item.h.

friend class SingletonIterator
friend

Definition at line 44 of file Item.h.

friend class StaticCollectionManager
friend

Definition at line 49 of file Item.h.

friend class StaticContext
friend

Definition at line 42 of file Item.h.


The documentation for this class was generated from the following file:
blog comments powered by Disqus