Saxon/C  1.1.2
Saxon Processor library for C/C++/PHP
 All Classes Functions Variables
XQueryProcessor.h
1 // Copyright (c) 2013 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 "XdmValue.h"
15 #include <string>
16 
17 
18 
19 class SaxonProcessor;
20 class XdmValue;
21 class XdmItem;
22 
27 public:
28 
31 
33 
37  XQueryProcessor(SaxonProcessor *p, std::string cwd="");
38 
39  ~XQueryProcessor(){
42  }
43 
45 
48  void setContextItem(XdmItem * value);
49 
53  void setOutputFile(const char* outfile);
54 
58  void setContextItemFromFile(const char * filename);
59 
66  void setParameter(const char * name, XdmValue*value);
67 
68 
76  bool removeParameter(const char * name);
77 
86  void setProperty(const char * name, const char * value);
87 
94  void clearParameters(bool deleteValues=false);
95 
99  void clearProperties();
100 
101 
103 
110  void executeQueryToFile(const char * infilename, const char * ofilename, const char * query);
111 
113 
119  XdmValue * executeQueryToValue(const char * infilename, const char * query);
120 
121 
123 
128  const char * executeQueryToString(const char * infilename, const char * query);
129 
131 
137 
144  const char * runQueryToString();
145 
146 
148 
154  void runQueryToFile();
155 
157 
171  void declareNamespace(const char *prefix, const char * uri);
172 
173 
175 
178  std::map<std::string,XdmValue*>& getParameters();
179 
181 
184  std::map<std::string,std::string>& getProperties();
185 
187 
190  void setQueryFile(const char* filename);
191 
193 
196  void setQueryContent(const char* content);
197 
199 
202  void setQueryBaseURI(const char * baseURI);
203 
207  void setcwd(const char* cwd);
208 
209 
211 
214  const char* checkException();
215 
220  bool exceptionOccurred();
221 
223  void exceptionClear();
224 
226 
230  int exceptionCount();
231 
232 
234 
238  const char * getErrorMessage(int i);
239 
240 
242 
246  const char * getErrorCode(int i);
247 
248 
249 private:
250  std::string cwdXQ;
251  SaxonProcessor * proc;
252  jclass cppClass;
253  jobject cppXQ;
254  //std::string outputfile1; /*!< output file where result will be saved */
255  bool queryFileExists;
256  std::string failure; //for testing
257  std::map<std::string,XdmValue*> parameters;
258  std::map<std::string,std::string> properties;
259 };
260 
261 #endif /* SAXON_XQUERY_H */
void setParameter(const char *name, XdmValue *value)
Definition: XQueryProcessor.cpp:101
void declareNamespace(const char *prefix, const char *uri)
Declare a namespace binding.
Definition: XQueryProcessor.cpp:59
Definition: XQueryProcessor.h:26
void setContextItemFromFile(const char *filename)
Definition: XQueryProcessor.cpp:83
const char * getErrorMessage(int i)
Get the ith error message if there are any error.
Definition: XQueryProcessor.cpp:416
void setQueryFile(const char *filename)
Compile a query supplied as by file name.
Definition: XQueryProcessor.cpp:380
const char * executeQueryToString(const char *infilename, const char *query)
Perform the Query to a string representation.
Definition: XQueryProcessor.cpp:304
void setQueryContent(const char *content)
Compile a query supplied as a string.
Definition: XQueryProcessor.cpp:386
const char * getErrorCode(int i)
Get the i'th error code if there are any error.
Definition: XQueryProcessor.cpp:411
int exceptionCount()
Get number of errors reported during execution of the query.
Definition: XQueryProcessor.cpp:431
XQueryProcessor()
Default constructor.
Definition: XQueryProcessor.cpp:7
XdmValue * executeQueryToValue(const char *infilename, const char *query)
Perform the Query to a XdmValue representation.
Definition: XQueryProcessor.cpp:229
Definition: XdmValue.h:44
void clearProperties()
Definition: XQueryProcessor.cpp:159
bool removeParameter(const char *name)
Definition: XQueryProcessor.cpp:116
void exceptionClear()
Clear any exception thrown.
Definition: XQueryProcessor.cpp:394
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition: XQueryProcessor.cpp:37
const char * runQueryToString()
Definition: XQueryProcessor.cpp:366
void setQueryBaseURI(const char *baseURI)
Set the static base URI for the query.
Definition: XQueryProcessor.cpp:169
Definition: SaxonProcessor.h:290
Definition: XdmItem.h:15
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition: XQueryProcessor.cpp:42
void setcwd(const char *cwd)
Definition: XQueryProcessor.cpp:165
XdmValue * runQueryToValue()
Execute the Query cached.
Definition: XQueryProcessor.cpp:372
void setOutputFile(const char *outfile)
Definition: XQueryProcessor.cpp:90
void clearParameters(bool deleteValues=false)
Definition: XQueryProcessor.cpp:134
void setContextItem(XdmItem *value)
Set the initial context item for the query.
Definition: XQueryProcessor.cpp:51
void runQueryToFile()
Execute the Query cached to file.
Definition: XQueryProcessor.cpp:376
bool exceptionOccurred()
Definition: XQueryProcessor.cpp:405
const char * checkException()
Check for exception thrown.
Definition: XQueryProcessor.cpp:421
void setProperty(const char *name, const char *value)
Definition: XQueryProcessor.cpp:125
void executeQueryToFile(const char *infilename, const char *ofilename, const char *query)
Perform the Query to file.
Definition: XQueryProcessor.cpp:173