SaxonC 12.7.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
XdmItem Class Reference

The class XdmItem represents an item in a sequence, as defined by the XDM data model. More...

#include <XdmItem.h>

Inheritance diagram for XdmItem:
XdmValue XdmAtomicValue XdmFunctionItem XdmNode XdmArray XdmMap

Public Member Functions

 XdmItem ()
 Default constructor.
 
 XdmItem (int64_t objRef)
 XdmItem constructor to create an object which is a wrapper for a Java XdmItem object - internal use only.
 
 XdmItem (const XdmItem &item)
 XdmItem copy constructor.
 
bool operator== (const XdmItem &other) const
 
virtual ~XdmItem ()
 Destructor method for XdmItem.
 
virtual void incrementRefCount ()
 Increment reference count of this XdmItem - internal use only.
 
virtual void decrementRefCount ()
 Decrement reference count of this XdmItem - internal use only.
 
virtual bool isAtomic ()
 Determine whether the item is an atomic value or some other type of item.
 
virtual bool isNode ()
 Determine whether the item is a node or some other type of item.
 
virtual bool isFunction ()
 Determine whether the item is an XDM function or some other type of item.
 
virtual bool isMap ()
 Determine whether the item is an XDM map or some other type of item.
 
virtual bool isArray ()
 Determine whether the item is an XDM array or some other type of item.
 
virtual int64_t getUnderlyingValue ()
 Get the underlying Java XdmValue object - internal use only.
 
virtual const char * getStringValue (const char *encoding=nullptr)
 Get the string value of the item.
 
const char * toString (const char *encoding=nullptr)
 Create a string representation of the item.
 
virtual XdmItemgetHead ()
 Get the first item in the sequence consisting of just this item.
 
XdmItemitemAt (int n)
 Get the n'th item in the sequence consisting of just this item, counting from zero.
 
int size ()
 Get the number of items in the sequence.
 
virtual XDM_TYPE getType ()
 Get the type of this XDM value.
 
- Public Member Functions inherited from XdmValue
 XdmValue ()
 Default constructor.
 
 XdmValue (const XdmValue &other)
 XdmValue copy constructor.
 
void addXdmItem (XdmItem *val)
 Add an XdmItem to the sequence.
 
virtual bool operator== (const XdmValue &other) const
 
void addXdmItemFromUnderlyingValue (XdmItem *val)
 Add an XdmItem to the sequence, when the sequence was returned from SaxonC - internal use only.
 
void addUnderlyingValue (int64_t val)
 Add Java XdmValue object to the sequence.
 
 XdmValue (int64_t val, bool arrFlag)
 A Constructor for handling XdmArray - internal use only.
 
 XdmValue (int64_t val)
 XdmValue constructor to create an object which is a wrapper for a Java XdmValue object - internal use only.
 
virtual ~XdmValue ()
 Destructor method for XdmValue.
 
void releaseXdmValue ()
 Deprecated: this is deprecated and a no-op, the C++ destructor handles this case.
 
int getRefCount ()
 Get the number of references on this XdmValue - internal use only This method is used for internal memory management.
 
void resetRelinquishedItems ()
 Reset associated reference counts on XdmItems that have been relinquished - internal use only.
 
void incrementRefCountForRelinquishedValue (int i)
 Increment the ref count for a relinquished item only once - internal use only.
 

Protected Attributes

const char * stringValue
 
const char * itemToString
 
- Protected Attributes inherited from XdmValue
char * valueType
 
XdmItem ** values
 
char * relinquished_values
 
int values_cap
 
int xdmSize
 
int refCount
 
int64_t value
 

Additional Inherited Members

- Protected Member Functions inherited from XdmValue
void initialize ()
 Initialize this XdmValue with default values.
 

Detailed Description

The class XdmItem represents an item in a sequence, as defined by the XDM data model.

An item is either an atomic value, a node, or a function item.

An item is a member of a sequence, but it can also be considered as a sequence (of length one) in its own right. XdmItem is a subtype of XdmValue because every item in the XDM data model is also a value.

It cannot be assumed that every sequence of length one will be represented by an XdmItem. It is quite possible for an XdmValue that is not an XdmItem to hold a singleton sequence.

Saxon provides a number of concrete subclasses of XdmItem, namely XdmNode, XdmAtomicValue and XdmFunctionItem. Users must not attempt to create additional subclasses.

Constructor & Destructor Documentation

◆ XdmItem() [1/3]

XdmItem::XdmItem ( )

Default constructor.

Creates an empty XdmItem.

◆ XdmItem() [2/3]

XdmItem::XdmItem ( int64_t objRef)
explicit

XdmItem constructor to create an object which is a wrapper for a Java XdmItem object - internal use only.

Parameters
objRef- internal Java XdmItem object to be wrapped

◆ XdmItem() [3/3]

XdmItem::XdmItem ( const XdmItem & item)

XdmItem copy constructor.

Parameters
item- XdmItem

Member Function Documentation

◆ decrementRefCount()

void XdmItem::decrementRefCount ( )
virtual

Decrement reference count of this XdmItem - internal use only.

This method is used for internal memory management.

Reimplemented from XdmValue.

◆ getHead()

XdmItem * XdmItem::getHead ( )
virtual

Get the first item in the sequence consisting of just this item.

Returns
This XdmItem

Reimplemented from XdmValue.

Reimplemented in XdmAtomicValue, and XdmNode.

◆ getStringValue()

const char * XdmItem::getStringValue ( const char * encoding = nullptr)
virtual

Get the string value of the item.

For a node, this gets the string value of the node. For an atomic value, it has the same effect as casting the value to a string. For a function item, there is no string value, so an exception is thrown. In all cases the result is the same as applying the XPath string() function.

For atomic values, the result is the same as the result of calling toString. This is not the case for nodes, where toString returns an XML serialization of the node. The caller is responsible for memory deallocation using operator delete.

Parameters
encoding- the encoding of the string returned. If NULL or omitted it defaults to the JVM encoding, which in most cases is UTF-8.
Returns
The result of converting the item to a string.
Exceptions
SaxonApiExceptionif the item is a function

Reimplemented in XdmArray, XdmAtomicValue, XdmFunctionItem, and XdmNode.

◆ getType()

XDM_TYPE XdmItem::getType ( )
virtual

Get the type of this XDM value.

Returns
The type of the XdmValue as an XDM_TYPE

Reimplemented from XdmValue.

Reimplemented in XdmArray, XdmAtomicValue, XdmFunctionItem, XdmMap, and XdmNode.

◆ getUnderlyingValue()

int64_t XdmItem::getUnderlyingValue ( )
virtual

Get the underlying Java XdmValue object - internal use only.

Returns
The Java object of the XdmValue in its JNI representation

Reimplemented from XdmValue.

Reimplemented in XdmNode.

◆ incrementRefCount()

void XdmItem::incrementRefCount ( )
virtual

Increment reference count of this XdmItem - internal use only.

This method is used for internal memory management.

Reimplemented from XdmValue.

◆ isArray()

bool XdmItem::isArray ( )
virtual

Determine whether the item is an XDM array or some other type of item.

Returns
True if the item is an XDM Array item, false if it is some other item

Reimplemented in XdmArray.

◆ isAtomic()

bool XdmItem::isAtomic ( )
virtual

Determine whether the item is an atomic value or some other type of item.

Returns
True if the item is an atomic value, false if it is a node or a function (including maps and arrays)

Reimplemented in XdmAtomicValue, XdmFunctionItem, and XdmNode.

◆ isFunction()

bool XdmItem::isFunction ( )
virtual

Determine whether the item is an XDM function or some other type of item.

Returns
True if the item is an XDM function item (including maps and arrays), false if it is an atomic value or a node

Reimplemented in XdmArray, XdmFunctionItem, and XdmMap.

◆ isMap()

bool XdmItem::isMap ( )
virtual

Determine whether the item is an XDM map or some other type of item.

Returns
True if the item is an XDM map item, false if it is some other item

Reimplemented in XdmMap.

◆ isNode()

bool XdmItem::isNode ( )
virtual

Determine whether the item is a node or some other type of item.

Returns
True if the item is a node, false if it is an atomic value or a function (including maps and arrays)

Reimplemented in XdmNode.

◆ itemAt()

XdmItem * XdmItem::itemAt ( int n)
virtual

Get the n'th item in the sequence consisting of just this item, counting from zero.

Parameters
n- the item that is required, counting the first item in the sequence as item zero
Returns
If n is zero, then return this XdmItem. Otherwise return nullptr if n is not zero, or if the value is lazily evaluated and the delayed evaluation fails with a dynamic error. The caller is responsible for memory deallocation.

Reimplemented from XdmValue.

◆ size()

int XdmItem::size ( )
virtual

Get the number of items in the sequence.

Returns
The number of items in the XdmValue. For an XdmItem this is always 1 (one).

Reimplemented from XdmValue.

◆ toString()

const char * XdmItem::toString ( const char * encoding = nullptr)
virtual

Create a string representation of the item.

This is the result of serializing the item using the adaptive serialization method.

Parameters
encoding- the encoding of the string returned. If NULL or omitted it defaults to the JVM encoding, which in most cases is UTF-8.
Returns
A string representation of the XdmItem. The caller is responsible for memory deallocation using operator delete.

Reimplemented from XdmValue.

Reimplemented in XdmMap, and XdmNode.

Member Data Documentation

◆ itemToString

const char* XdmItem::itemToString
protected

Cached. String representation of the XdmValue, if available

◆ stringValue

const char* XdmItem::stringValue
protected

Cached. String representation of the XdmValue, if available


The documentation for this class was generated from the following files: