SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
XdmValue.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_XDMVALUE_H
9 #define SAXON_XDMVALUE_H
10 
11 
12 #include <string.h>
13 #include "SaxonProcessor.h"
14 #include <typeinfo> //used for testing only
15 #include <vector>
16 #include <deque>
17 #include <list>
18 #include "SaxonCGlue.h"
19 #include "SaxonCXPath.h"
20 
21 
22 
23 
24 
25 class SaxonProcessor;
26 class XdmItem;
27 class XdmAtomicValue;
28 class XdmNode;
29 
30 
31 
32 typedef enum eXdmType { XDM_VALUE = 1, XDM_ITEM = 2, XDM_NODE = 3, XDM_ATOMIC_VALUE = 4, XDM_FUNCTION_ITEM = 5, XDM_MAP=6, XDM_ARRAY=7 } XDM_TYPE;
33 
34 typedef enum saxonTypeEnum
35 {
36  enumNode,
37  enumString,
38  enumInteger,
39  enumDouble,
40  enumFloat,
41  enumBool,
42  enumArrXdmValue
43 } PRIMITIVE_TYPE;
44 
45 
50 class XdmValue {
51 
52 
53 public:
54 
56 
60  initialize();
61  }
62 
63 
65 
69  XdmValue(const XdmValue &other);
70 
71 
73 
78  XdmValue * addXdmValueWithType(const char * tStr, const char * val);//TODO check and document
79 
85  void addXdmItem(XdmItem *val);
86 
92  void addUnderlyingValue(jobject val);
93 
94 
95 
96 
98 
103  XdmValue(jobject val, bool arrFlag);
104 
106 
110  XdmValue(jobject val);
111 
113 
116  virtual ~XdmValue();
117 
119  /*
120  *
121  */
122  void releaseXdmValue();
123 
125 
129  virtual XdmItem * getHead();
130 
132 
140  virtual XdmItem * itemAt(int n);
141 
146  virtual int size();
147 
148 
150 
155  virtual const char * toString();
156 
158 
161  int getRefCount() {
162  return refCount;
163  }
164 
165 
166 
168 
171  virtual void incrementRefCount();
172 
174 
177  virtual void decrementRefCount();
178 
183  virtual jobject getUnderlyingValue();
184 
188  virtual XDM_TYPE getType();
189 
190 protected:
191 
193  inline void initialize() {
194  jValues = nullptr;
195  refCount = 0;
196  valueType = nullptr;
197  xdmSize = 0;
198  toStringValue ="";
199  }
200 
201  char* valueType;
204  std::vector<XdmItem*> values;
205  int xdmSize;
206  int refCount;
207 private:
208  std::string toStringValue;
209  jobjectArray jValues;
210 };
211 
212 #endif
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition: SaxonProcessor.h:119
Definition: XdmAtomicValue.h:26
Definition: XdmItem.h:29
Definition: XdmNode.h:31
Definition: XdmValue.h:50
int refCount
Definition: XdmValue.h:206
void addUnderlyingValue(jobject val)
Definition: XdmValue.cpp:195
int xdmSize
Definition: XdmValue.h:205
XdmValue * addXdmValueWithType(const char *tStr, const char *val)
Add an XdmItem to the sequence.
void addXdmItem(XdmItem *val)
Definition: XdmValue.cpp:181
virtual XDM_TYPE getType()
Definition: XdmValue.cpp:272
int getRefCount()
Get the number of references on this XdmValue.
Definition: XdmValue.h:161
virtual ~XdmValue()
Destructor.
Definition: XdmValue.cpp:156
virtual const char * toString()
Create a string representation of the value.
Definition: XdmValue.cpp:30
virtual jobject getUnderlyingValue()
Definition: XdmValue.cpp:227
virtual XdmItem * itemAt(int n)
Get the n'th item in the value, counting from zero.
Definition: XdmValue.cpp:262
virtual void incrementRefCount()
Increment reference count of this XdmValue - Memory management - Internal use only.
Definition: XdmValue.cpp:204
virtual void decrementRefCount()
Decrement reference count of this XdmValue - Memory management - Internal use only.
Definition: XdmValue.cpp:209
virtual XdmItem * getHead()
Get the first item in the sequence.
Definition: XdmValue.cpp:218
char * valueType
Definition: XdmValue.h:201
void initialize()
initialize this XdmValue with default values
Definition: XdmValue.h:193
XdmValue()
A default Constructor.
Definition: XdmValue.h:59
std::vector< XdmItem * > values
Definition: XdmValue.h:204
void releaseXdmValue()
Delete the XdmValue object and clean up all items in the sequence. Release the underlying JNI object.
Definition: XdmValue.cpp:248
virtual int size()
Definition: XdmValue.cpp:76