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

A map in the XDM data model. More...

#include <XdmMap.h>

Inheritance diagram for XdmMap:
XdmFunctionItem XdmItem XdmValue

Public Member Functions

 XdmMap ()
 Default constructor.
 
 XdmMap (const XdmMap &d)
 XdmItem copy constructor.
 
virtual ~XdmMap ()
 Destructor method for XdmMap.
 
 XdmMap (int64_t obj)
 XdmMap constructor to create an object which is a wrapper for a Java XdmMap object - internal use only.
 
 XdmMap (std::map< XdmAtomicValue *, XdmValue * > map)
 Create an XdmMap supplying the entries in the form of a std::map.
 
int mapSize ()
 Get the number of entries in the map.
 
XdmValueget (XdmAtomicValue *key)
 Returns the value to which the specified key is mapped, or NULL if this map contains no mapping for the key.
 
XdmValueget (const char *key)
 Returns the value to which the specified string-valued key is mapped, or NULL if this map contains no mapping for the key.
 
XdmValueget (int key)
 Returns the value to which the specified integer-valued key is mapped or NULL if this map contains no mapping for the key.
 
XdmValueget (double key)
 Returns the value to which the specified double-valued key is mapped, or NULL if this map contains no mapping for the key.
 
XdmValueget (long key)
 Returns the value to which the specified integer-valued key is mapped or NULL if this map contains no mapping for the key.
 
XdmMapput (XdmAtomicValue *key, XdmValue *value)
 Create a new map containing an additional (key, value) pair.
 
XdmMapremove (XdmAtomicValue *key)
 Create a new map in which the entry for a given key has been removed.
 
std::set< XdmAtomicValue * > keySet ()
 Get the keys present in the map in the form of an unordered std::set.
 
XdmAtomicValue ** keys ()
 Get the keys present in the map in the form of an unordered pointer array of XdmAtomicValues.
 
bool isEmpty ()
 Check if this map is empty.
 
bool containsKey (XdmAtomicValue *key)
 Returns true if this map contains a mapping for the specified key.
 
std::list< XdmValue * > valuesAsList ()
 Returns a std::list containing the values found in this map, that is, the value parts of the key-value pairs.
 
XdmValue ** values ()
 Returns a pointer array containing the values found in this map, that is, the value parts of the key-value pairs.
 
bool isFunction ()
 Determine whether the item is a function or some other type of item.
 
bool isMap ()
 Determine whether the item is an XDM map or some other type of item.
 
XDM_TYPE getType ()
 Get the type of this XDM value.
 
const char * toString (const char *encoding=nullptr)
 Create a string representation of the XDM map.
 
- Public Member Functions inherited from XdmFunctionItem
 XdmFunctionItem ()
 Default constructor.
 
 XdmFunctionItem (int64_t obj)
 XdmFunctionItem constructor to create an object which is a wrapper for a Java XdmFunctionItem object - internal use only.
 
 XdmFunctionItem (const XdmFunctionItem &d)
 XdmFunctionItem copy constructor.
 
virtual ~XdmFunctionItem ()
 Destructor method for XdmFunctionItem.
 
const char * getName ()
 Get the name of the function as an EQName.
 
virtual int getArity ()
 Get the arity of the function.
 
const char * getStringValue (const char *encoding=nullptr)
 Get the string value of the XdmFunctionItem.
 
XdmValuecall (SaxonProcessor *processor, XdmValue **arguments, int argument_length)
 Call the function.
 
bool isAtomic ()
 Determine whether the item is an atomic value or some other type of item.
 
- Public Member Functions inherited from XdmItem
 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 isNode ()
 Determine whether the item is a node 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 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.
 
- 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from XdmFunctionItem
static XdmFunctionItemgetSystemFunction (SaxonProcessor *processor, const char *name, int arity)
 Get a system function.
 
- Protected Member Functions inherited from XdmFunctionItem
XdmValuegetXdmValueSubClass (int64_t value)
 
- Protected Member Functions inherited from XdmValue
void initialize ()
 Initialize this XdmValue with default values.
 
- Protected Attributes inherited from XdmFunctionItem
char * fname
 
- Protected Attributes inherited from XdmItem
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
 

Detailed Description

A map in the XDM data model.

A map is a list of zero or more entries, each of which is a pair comprising a key (which is an atomic value) and a value (which is an arbitrary value). The map itself is an XDM item.

An XdmMap is immutable.

Since
11

Constructor & Destructor Documentation

◆ XdmMap() [1/4]

XdmMap::XdmMap ( )

Default constructor.

Creates an empty XdmMap

◆ XdmMap() [2/4]

XdmMap::XdmMap ( const XdmMap & d)

XdmItem copy constructor.

Parameters
d- XdmArray

◆ XdmMap() [3/4]

XdmMap::XdmMap ( int64_t obj)

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

Parameters
obj- internal Java XdmMap object to be wrapped

◆ XdmMap() [4/4]

XdmMap::XdmMap ( std::map< XdmAtomicValue *, XdmValue * > map)

Create an XdmMap supplying the entries in the form of a std::map.

The keys and values in the std::map are XDM values

Parameters
map- a std::map whose entries are the (key, value) pairs

Member Function Documentation

◆ containsKey()

bool XdmMap::containsKey ( XdmAtomicValue * key)

Returns true if this map contains a mapping for the specified key.

More formally, returns true if and only if this map contains a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)

Parameters
key- the key whose presence in this map is to be tested
Returns
True if this map contains a mapping for the specified key

◆ get() [1/5]

XdmValue * XdmMap::get ( const char * key)

Returns the value to which the specified string-valued key is mapped, or NULL if this map contains no mapping for the key.

This is a convenience method to save the trouble of converting the String to an XdmAtomicValue.

Parameters
key- the key whose associated value is to be returned. This is treated as an instance of xs:string (which will also match entries whose key is xs:untypedAtomic or xs:anyURI)
Returns
The value to which the specified key is mapped, or NULL if this map contains no mapping for the key. The caller is responsible for memory deallocation using delete.

◆ get() [2/5]

XdmValue * XdmMap::get ( double key)

Returns the value to which the specified double-valued key is mapped, or NULL if this map contains no mapping for the key.

This is a convenience method to save the trouble of converting the double to an XdmAtomicValue.

Parameters
key- the key whose associated value is to be returned. This is treated as an instance of xs:double (which will also match entries whose key belongs to another numeric type)
Returns
The value to which the specified key is mapped, or NULL if this map contains no mapping for the key. The caller is responsible for memory deallocation using delete.

◆ get() [3/5]

XdmValue * XdmMap::get ( int key)

Returns the value to which the specified integer-valued key is mapped or NULL if this map contains no mapping for the key.

This is a convenience method to save the trouble of converting the integer to an XdmAtomicValue.

Parameters
key- the key whose associated value is to be returned. This is treated as an instance of xs:integer (which will also match entries whose key belongs to another numeric type)
Returns
The value to which the specified key is mapped, or NULL if this map contains no mapping for the key. The caller is responsible for memory deallocation using delete.

◆ get() [4/5]

XdmValue * XdmMap::get ( long key)

Returns the value to which the specified integer-valued key is mapped or NULL if this map contains no mapping for the key.

This is a convenience method to save the trouble of converting the integer to an XdmAtomicValue.

Parameters
key- the key whose associated value is to be returned. This is treated as an instance of xs:integer (which will also match entries whose key belongs to another numeric type)
Returns
The value to which the specified key is mapped, or NULL if this map contains no mapping for the key. The caller is responsible for memory deallocation using delete.

◆ get() [5/5]

XdmValue * XdmMap::get ( XdmAtomicValue * key)

Returns the value to which the specified key is mapped, or NULL if this map contains no mapping for the key.

Parameters
key- the key whose associated value is to be returned.
Returns
The value to which the specified key is mapped, or NULL if this map contains no mapping for the key. The caller is responsible for memory deallocation using delete.

◆ getType()

XDM_TYPE XdmMap::getType ( )
inlinevirtual

Get the type of this XDM value.

Returns
The type of the XdmValue as an XDM_TYPE

Reimplemented from XdmFunctionItem.

◆ isEmpty()

bool XdmMap::isEmpty ( )

Check if this map is empty.

Returns
True if this map contains no key-value mappings

◆ isFunction()

bool XdmMap::isFunction ( )
inlinevirtual

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

Returns
True; an XDM map is a function item

Reimplemented from XdmFunctionItem.

◆ isMap()

bool XdmMap::isMap ( )
inlinevirtual

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

Returns
True

Reimplemented from XdmItem.

◆ keys()

XdmAtomicValue ** XdmMap::keys ( )

Get the keys present in the map in the form of an unordered pointer array of XdmAtomicValues.

Returns
An unordered pointer array of the keys present in this map, in arbitrary order. The caller is responsible for memory deallocation.

◆ keySet()

std::set< XdmAtomicValue * > XdmMap::keySet ( )

Get the keys present in the map in the form of an unordered std::set.

Returns
An unordered std::set of the keys present in this map, in arbitrary order. The caller is responsible for memory deallocation.

◆ mapSize()

int XdmMap::mapSize ( )

Get the number of entries in the map.

Returns
the number of entries in the map. (Note that the size() method returns 1 (one), because an XDM map is an item.)

◆ put()

XdmMap * XdmMap::put ( XdmAtomicValue * key,
XdmValue * value )

Create a new map containing an additional (key, value) pair.

If there is an existing entry with the same key, it is removed.

Parameters
key- the key for the new entry
value- the value for the new entry
Returns
A new map containing the additional entry. The original map is unchanged. The caller is responsible for memory deallocation using delete.

◆ remove()

XdmMap * XdmMap::remove ( XdmAtomicValue * key)

Create a new map in which the entry for a given key has been removed.

If there is no entry with the same key, the new map has the same content as the old (it may or may not be the same object)

Parameters
key- the key to be removed given as an XdmAtomicValue
Returns
A map without the specified entry. The caller is responsible for memory deallocation using delete. The original map is unchanged.

◆ toString()

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

Create a string representation of the XDM map.

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

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

Reimplemented from XdmItem.

◆ values()

XdmValue ** XdmMap::values ( )

Returns a pointer array containing the values found in this map, that is, the value parts of the key-value pairs.

Returns
A pointer array containing the values found in this map. The result may contain duplicates, and the ordering of the collection is unpredictable. The caller is responsible for memory deallocation using delete.

◆ valuesAsList()

std::list< XdmValue * > XdmMap::valuesAsList ( )

Returns a std::list containing the values found in this map, that is, the value parts of the key-value pairs.

Returns
A std::list containing the values found in this map. The result may contain duplicates, and the ordering of the collection is unpredictable. The caller is responsible for memory deallocation.

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