SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
XdmMap.h
1 // Copyright (c) 2022 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
7 
8 #ifndef SAXON_XDM_MAP_h
9 #define SAXON_XDM_MAP_h
10 
11 
12 #include "XdmFunctionItem.h"
13 #include "XdmArray.h"
14 #include <string>
15 
16 #include <stdlib.h>
17 #include <string.h>
18 #include <map>
19 #include <set>
20 
21 
29 class XdmMap : public XdmFunctionItem {
30 
31 public:
32 
34 
37  XdmMap();
38 
40 
43  XdmMap(const XdmMap &d);
44 
46 
49  virtual ~XdmMap(){
50 
51  }
52 
54 
57  XdmMap(jobject obj);
58 
60 
64  XdmMap(std::map<XdmAtomicValue *, XdmValue*> map);
65 
66 
68 
74  int mapSize();
75 
77 
85  XdmValue * get(XdmAtomicValue* key);
86 
88 
96  XdmValue * get(const char * key);
97 
99 
107  XdmValue * get(int key);
108 
112 
120  XdmValue * get(double key);
121 
125 
133  XdmValue * get(long key);
134 
136 
141  XdmMap * put(XdmAtomicValue * key, XdmValue * value);
142 
144 
151  XdmMap * remove(XdmAtomicValue* key);
152 
154 
158  std::set<XdmAtomicValue*> keySet();
159 
161 
165  XdmAtomicValue ** keys();
166 
167  //std::map<XdmAtomicValue*, XdmValue*> asMap();
168 
170 
173  bool isEmpty();
174 
176 
185  bool containsKey(XdmAtomicValue* key);
186 
188 
194  std::list<XdmValue*> valuesAsList();
195 
197 
203  XdmValue** values();
204 
206 
210  bool isFunction(){
211  return true;
212  }
213 
215 
219  bool isMap(){
220  return true;
221  }
222 
224  XDM_TYPE getType() {
225  return XDM_MAP;
226  }
227 
228 
230 
252  const char * toString();
253 
254 
255 
256 private:
257 
258 
259  std::string fname;
260  std::map<XdmAtomicValue *, XdmValue*> data;
261  int arity;
262  int map_size;
264 };
265 
266 
267 
268 
269 #endif
Definition: XdmAtomicValue.h:26
Definition: XdmFunctionItem.h:23
jobject value
Definition: XdmItem.h:163
Definition: XdmMap.h:29
const char * toString()
The toString() method returns a simple XML serialization of the node with defaulted serialization par...
Definition: XdmMap.cpp:25
virtual ~XdmMap()
Destructor.
Definition: XdmMap.h:49
XdmMap * put(XdmAtomicValue *key, XdmValue *value)
Create a new map containing an additional (key, value) pair.
Definition: XdmMap.cpp:422
std::set< XdmAtomicValue * > keySet()
Get the keys present in the map in the form of an unordered std::set.
Definition: XdmMap.cpp:476
XdmValue * get(XdmAtomicValue *key)
Returns the value to which the specified key is mapped, or NULL if this map contains no mapping for t...
Definition: XdmMap.cpp:71
bool isFunction()
Determine whether the item is a function or some other type of item.
Definition: XdmMap.h:210
bool isEmpty()
Returns true if this map contains no key-value mappings.
Definition: XdmMap.cpp:550
int mapSize()
Get the number of entries in the map.
Definition: XdmMap.cpp:48
XdmMap * remove(XdmAtomicValue *key)
Create a new map in which the entry for a given key has been removed.
Definition: XdmMap.cpp:450
std::list< XdmValue * > valuesAsList()
Returns a std::list containing the values found in this map, that is, the value parts of the key-valu...
Definition: XdmMap.cpp:591
XdmValue ** values()
Returns a pointer array containing the values found in this map, that is, the value parts of the key-...
Definition: XdmMap.cpp:626
bool isMap()
Determine whether the item is a map or some other type of item.
Definition: XdmMap.h:219
XdmMap()
Default constructor.
Definition: XdmMap.cpp:10
XDM_TYPE getType()
Get the type of the object.
Definition: XdmMap.h:224
bool containsKey(XdmAtomicValue *key)
Returns true if this map contains a mapping for the specified key.
Definition: XdmMap.cpp:569
XdmAtomicValue ** keys()
Get the keys present in the map in the form of an unordered pointer array of XdmAtomicValue.
Definition: XdmMap.cpp:513
XdmMap(std::map< XdmAtomicValue *, XdmValue * > map)
Create an XdmMap supplying the entries in the form of a std::map, where the keys and values in the st...
Definition: XdmValue.h:50