SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XdmMap.h
1
2// Copyright (c) 2022 - 2023 Saxonica Limited.
3// This Source Code Form is subject to the terms of the Mozilla Public License,
4// v. 2.0. If a copy of the MPL was not distributed with this file, You can
5// obtain one at http://mozilla.org/MPL/2.0/. This Source Code Form is
6// "Incompatible With Secondary Licenses", as defined by the Mozilla Public
7// License, v. 2.0.
9
10#ifndef SAXON_XDM_MAP_h
11#define SAXON_XDM_MAP_h
12
13#include "XdmArray.h"
14#include "XdmFunctionItem.h"
15#include <string>
16
17#include <map>
18#include <set>
19#include <stdlib.h>
20#include <string.h>
21
29class XdmMap : public XdmFunctionItem {
30
31public:
33
36 XdmMap();
37
39
42 XdmMap(const XdmMap &d);
43
45
48 virtual ~XdmMap() {}
49
52
56 XdmMap(int64_t obj);
57
60
64 XdmMap(std::map<XdmAtomicValue *, XdmValue *> map);
65
67
73 int mapSize();
74
77
87
90
100 XdmValue *get(const char *key);
101
104
114 XdmValue *get(int key);
115
120
128 XdmValue *get(double key);
129
134
142 XdmValue *get(long key);
143
145
152
154
162
164
169 std::set<XdmAtomicValue *> keySet();
170
173
179
180 // std::map<XdmAtomicValue*, XdmValue*> asMap();
181
183
186 bool isEmpty();
187
190
199 bool containsKey(XdmAtomicValue *key);
200
203
210 std::list<XdmValue *> valuesAsList();
211
214
221 XdmValue **values();
222
224
229 bool isFunction() { return true; }
230
232
236 bool isMap() { return true; }
237
239 XDM_TYPE getType() { return XDM_MAP; }
240
243
267 const char *toString();
268
269private:
270 std::map<XdmAtomicValue *, XdmValue *>
271 data;
273 int arity;
274 int map_size;
275};
276
277#endif
Definition XdmAtomicValue.h:26
Definition XdmFunctionItem.h:25
int64_t value
Definition XdmItem.h:170
Definition XdmMap.h:29
const char * toString()
Definition XdmMap.cpp:19
virtual ~XdmMap()
Destructor.
Definition XdmMap.h:48
XdmMap * put(XdmAtomicValue *key, XdmValue *value)
Create a new map containing an additional (key, value) pair.
Definition XdmMap.cpp:79
std::set< XdmAtomicValue * > keySet()
Get the keys present in the map in the form of an unordered std::set.
Definition XdmMap.cpp:105
XdmValue * get(XdmAtomicValue *key)
Definition XdmMap.cpp:34
bool isFunction()
Determine whether the item is a function or some other type of item.
Definition XdmMap.h:229
bool isEmpty()
Returns true if this map contains no key-value mappings.
Definition XdmMap.cpp:149
int mapSize()
Get the number of entries in the map.
Definition XdmMap.cpp:27
XdmMap * remove(XdmAtomicValue *key)
Create a new map in which the entry for a given key has been removed.
Definition XdmMap.cpp:92
std::list< XdmValue * > valuesAsList()
Definition XdmMap.cpp:162
XdmValue ** values()
Definition XdmMap.cpp:182
bool isMap()
Determine whether the item is a map or some other type of item.
Definition XdmMap.h:236
XdmMap()
Default constructor.
Definition XdmMap.cpp:9
XDM_TYPE getType()
Get the type of the object.
Definition XdmMap.h:239
bool containsKey(XdmAtomicValue *key)
Definition XdmMap.cpp:155
XdmAtomicValue ** keys()
Definition XdmMap.cpp:125
XdmMap(std::map< XdmAtomicValue *, XdmValue * > map)
Definition XdmValue.h:42