SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
XQueryProcessor.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_XQUERY_H
9 #define SAXON_XQUERY_H
10 
11 
12 
13 #include "SaxonProcessor.h"
14 #include <string>
15 
16 
17 
18 class SaxonProcessor;
19 class SaxonApiException;
20 class XdmValue;
21 class XdmItem;
22 
27 public:
28 
31 
33 
37  XQueryProcessor(SaxonProcessor *p, std::string cwd="");
38 
43  XQueryProcessor(const XQueryProcessor &other);
44 
49 
50  ~XQueryProcessor();
51 
53 
56  void setContextItem(XdmItem * value);
57 
61  void setOutputFile(const char* outfile);
62 
66  void setContextItemFromFile(const char * filename);
67 
74  void setParameter(const char * name, XdmValue*value);
75 
76 
78 
83  bool removeParameter(const char * name);
84 
86 
94  void setProperty(const char * name, const char * value);
95 
97 
102  void clearParameters(bool deleteValues=false);
103 
105  void clearProperties();
106 
107 
109 
116  void setUpdating(bool updating);
117 
118 
120 
127  void executeQueryToFile(const char * infilename, const char * ofilename, const char * query);
128 
130 
135  XdmValue * executeQueryToValue(const char * infilename, const char * query);
136 
137 
139 
144  const char * executeQueryToString(const char * infilename, const char * query);
145 
147 
153 
160  const char * runQueryToString();
161 
162 
164 
170  void runQueryToFile();
171 
173 
187  void declareNamespace(const char *prefix, const char * uri);
188 
189 
191 
194  std::map<std::string,XdmValue*>& getParameters();
195 
197 
200  std::map<std::string,std::string>& getProperties();
201 
203 
206  void setQueryFile(const char* filename);
207 
209 
212  void setQueryContent(const char* content);
213 
215 
218  void setQueryBaseURI(const char * baseURI);
219 
223  void setcwd(const char* cwd);
224 
225 
227 
230  const char* checkException();
231 
236  bool exceptionOccurred();
237 
239  void exceptionClear();
240 
241 
243 
247  const char * getErrorMessage();
248 
249 
251 
255  const char * getErrorCode();
256 
258 
264 
265 
266 private:
267 
268  void createException(const char * message=nullptr);
269 
270  std::string cwdXQ;
271  SaxonProcessor * proc;
272  jclass cppClass;
273  jobject cppXQ;
274  std::map<std::string,XdmValue*> parameters;
275  std::map<std::string,std::string> properties;
276  SaxonApiException * exception;
277 };
278 
279 #endif /* SAXON_XQUERY_H */
Definition: SaxonApiException.h:19
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition: SaxonProcessor.h:119
Definition: XQueryProcessor.h:26
void setOutputFile(const char *outfile)
Definition: XQueryProcessor.cpp:153
void setcwd(const char *cwd)
Definition: XQueryProcessor.cpp:222
void setQueryBaseURI(const char *baseURI)
Set the static base URI for the query.
Definition: XQueryProcessor.cpp:226
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition: XQueryProcessor.cpp:200
void setQueryFile(const char *filename)
Compile a query supplied as a file name.
Definition: XQueryProcessor.cpp:509
const char * checkException()
Check for exception thrown.
Definition: XQueryProcessor.cpp:550
bool exceptionOccurred()
Definition: XQueryProcessor.cpp:535
void setParameter(const char *name, XdmValue *value)
Definition: XQueryProcessor.cpp:161
void runQueryToFile()
Execute the Query cached to file.
Definition: XQueryProcessor.cpp:505
const char * getErrorCode()
Get the i'th error code if there are any error.
Definition: XQueryProcessor.cpp:540
void executeQueryToFile(const char *infilename, const char *ofilename, const char *query)
Perform the Query to file.
Definition: XQueryProcessor.cpp:248
void declareNamespace(const char *prefix, const char *uri)
Declare a namespace binding.
Definition: XQueryProcessor.cpp:121
void setContextItem(XdmItem *value)
Set the initial context item for the query.
Definition: XQueryProcessor.cpp:113
XdmValue * runQueryToValue()
Execute the Query cached.
Definition: XQueryProcessor.cpp:501
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition: XQueryProcessor.cpp:104
void clearProperties()
Clear property values set.
Definition: XQueryProcessor.cpp:216
void exceptionClear()
Clear any exception thrown.
Definition: XQueryProcessor.cpp:521
void setProperty(const char *name, const char *value)
Set a property specific to the processor in use.
Definition: XQueryProcessor.cpp:186
void setUpdating(bool updating)
Say whether the query is allowed to be updating.
Definition: XQueryProcessor.cpp:231
const char * runQueryToString()
Definition: XQueryProcessor.cpp:495
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition: XQueryProcessor.cpp:99
XdmValue * executeQueryToValue(const char *infilename, const char *query)
Perform the Query to a XdmValue representation.
Definition: XQueryProcessor.cpp:312
void setContextItemFromFile(const char *filename)
Definition: XQueryProcessor.cpp:146
void setQueryContent(const char *content)
Compile a query supplied as a string.
Definition: XQueryProcessor.cpp:514
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition: XQueryProcessor.cpp:180
const char * getErrorMessage()
Get the ith error message if there are any error.
Definition: XQueryProcessor.cpp:545
SaxonApiException * getException()
Get the SaxonApiException object created when we have an error.
Definition: XQueryProcessor.cpp:560
XQueryProcessor()
Default constructor.
Definition: XQueryProcessor.cpp:15
XQueryProcessor * clone()
Definition: XQueryProcessor.cpp:91
const char * executeQueryToString(const char *infilename, const char *query)
Perform the Query to a string representation.
Definition: XQueryProcessor.cpp:415
Definition: XdmItem.h:29
Definition: XdmValue.h:50