Saxon/C  1.1.2
Saxon Processor library for C/C++/PHP
 All Classes Functions Variables
XdmValue.h
1 // Copyright (c) 2014 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 
27 class SaxonProcessor;
28 class XdmItem;
29 
30 
31 typedef enum eXdmType { XDM_VALUE=1, XDM_ITEM=2, XDM_NODE=3, XDM_ATOMIC_VALUE=4, XDM_FUNCTION_ITEM=5 } XDM_TYPE;
32 
33 typedef enum saxonTypeEnum
34 {
35  enumNode,
36  enumString,
37  enumInteger,
38  enumDouble,
39  enumFloat,
40  enumBool,
41  enumArrXdmValue
42 } PRIMITIVE_TYPE;
43 
44 class XdmValue {
45 
46 
47 public:
52  xdmSize = 0;
53  refCount = 1;
54  jValues = NULL;
55  valueType = NULL;
56  }
57 
59  proc = p;
60  jValues = NULL;
61  refCount = 1;
62  valueType = NULL;
63  }
64 
65 
70  XdmValue(const XdmValue &other);
71 
76  //XdmValue(XdmValue * items, int length);
77 
78 
79 
84  //XdmValue(XdmItem *items, int length);
85 
91  XdmValue * addXdmValueWithType(const char * tStr, const char * val);//TODO check and document
92 
98  void addXdmItem(XdmItem *val);
99 
105  void addUnderlyingValue(jobject val);
106 
107 
108 
109  //TODO XdmValue with constructor of sequence of values
110 
115  XdmValue(jobject val);
116 
117 
118  virtual ~XdmValue();
119 
120  void releaseXdmValue();
121 
122 
127  virtual XdmItem * getHead();
128 
139  virtual XdmItem * itemAt(int n);
140 
145  virtual int size();
146 
147  int getRefCount(){
148  return refCount;
149  }
150 
151 
152 
153  void incrementRefCount(){
154  refCount++;
155  //std::cerr<<"refCount-inc-xdmVal="<<refCount<<" ob ref="<<(this)<<std::endl;
156  }
157 
158  void decrementRefCount(){
159  if(refCount >0)
160  refCount--;
161  //std::cerr<<"refCount-dec-xdmVal="<<refCount<<" ob ref="<<(this)<<std::endl;
162  }
163 
164  void setProcessor(SaxonProcessor *p){proc = p;}
165 
166  /*const char * getErrorMessage(int i);
167  const char * getErrorCode(int i);
168  int exceptionCount();*/
169  const char * checkFailures(){return failure;}
170 
175  virtual jobject getUnderlyingValue();
176 
180  virtual XDM_TYPE getType();
181 
182 protected:
183  SaxonProcessor *proc;
184  char* valueType;
185  //string valueStr; /*!< Cached. String representation of the XdmValue, if available */
186 
187  std::vector<XdmItem*> values;
188  int xdmSize;
189  int refCount;
190 private:
191 
192  jobjectArray jValues;
193 };
194 
195 #endif
char * valueType
Definition: XdmValue.h:184
void addUnderlyingValue(jobject val)
Definition: XdmValue.cpp:56
virtual XdmItem * itemAt(int n)
Definition: XdmValue.cpp:102
void addXdmItem(XdmItem *val)
Definition: XdmValue.cpp:47
Definition: XdmValue.h:44
virtual XDM_TYPE getType()
Definition: XdmValue.cpp:112
virtual jobject getUnderlyingValue()
Definition: XdmValue.cpp:76
Definition: SaxonProcessor.h:290
Definition: XdmItem.h:15
XdmValue()
Definition: XdmValue.h:51
int xdmSize
Definition: XdmValue.h:188
virtual int size()
Definition: XdmValue.cpp:18
XdmValue * addXdmValueWithType(const char *tStr, const char *val)
virtual XdmItem * getHead()
Definition: XdmValue.cpp:68