SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XQueryProcessor.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_XQUERY_H
11#define SAXON_XQUERY_H
12
13#include "SaxonProcessor.h"
14#include <string>
15
16class SaxonProcessor;
18class XdmValue;
19class XdmItem;
20
25public:
28
30
34 XQueryProcessor(SaxonProcessor *p, std::string cwd = "");
35
40 XQueryProcessor(const XQueryProcessor &other);
41
47
49
51
55 void setContextItem(XdmItem *value);
56
60 void setOutputFile(const char *outfile);
61
65 void setContextItemFromFile(const char *filename);
66
76 void setParameter(const char *name, XdmValue *value, bool withParam=true);
77
79
84 void setLanguageVersion(const char *version);
85
87
97 void setStreaming(bool option);
98
100
107 bool isStreaming();
108
110
115 bool removeParameter(const char *name);
116
118
128 void setProperty(const char *name, const char *value);
129
131
137 void clearParameters(bool deleteValues = false);
138
140 void clearProperties();
141
142
144
153 void setUpdating(bool updating);
154
156
166 void executeQueryToFile(const char *infilename, const char *ofilename,
167 const char *query, const char *encoding = nullptr);
168
170
178 XdmValue *executeQueryToValue(const char *infilename, const char *query,
179 const char *encoding = nullptr);
180
182
190 const char *executeQueryToString(const char *infilename, const char *query,
191 const char *encoding = nullptr);
192
194
201
209 const char *runQueryToString();
210
212
218 void runQueryToFile();
219
221
238 void declareNamespace(const char *prefix, const char *uri);
239
246 XdmValue *getParameter(const char *name, bool withParam=true);
247
249
252 std::map<std::string, XdmValue *> &getParameters();
253
255
258 std::map<std::string, std::string> &getProperties();
259
261
264 void setQueryFile(const char *filename);
265
267
270 void setQueryContent(const char *content);
271
273
277 void setQueryBaseURI(const char *baseURI);
278
282 void setcwd(const char *cwd);
283
285
289 const char *checkException();
290
297 bool exceptionOccurred();
298
300 void exceptionClear();
301
303
307 const char *getErrorMessage();
308
310
315 const char *getErrorCode();
316
318
324
325private:
326 void createException(const char *message = nullptr);
327 bool streaming;
328 std::string cwdXQ;
329 SaxonProcessor *proc;
330
331 int64_t cppXQ;
332 std::map<std::string, XdmValue *>
333 parameters;
335 std::map<std::string, std::string>
336 properties;
338 SaxonApiException *exception;
339};
340
341#endif /* SAXON_XQUERY_H */
Definition SaxonApiException.h:23
Definition SaxonProcessor.h:117
Definition XQueryProcessor.h:24
void setOutputFile(const char *outfile)
Definition XQueryProcessor.cpp:165
void setcwd(const char *cwd)
Definition XQueryProcessor.cpp:241
void executeQueryToFile(const char *infilename, const char *ofilename, const char *query, const char *encoding=nullptr)
Perform the Query to file.
Definition XQueryProcessor.cpp:260
void setQueryBaseURI(const char *baseURI)
Set the static base URI for the query.
Definition XQueryProcessor.cpp:247
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition XQueryProcessor.cpp:218
void setQueryFile(const char *filename)
Compile a query supplied as a file name.
Definition XQueryProcessor.cpp:358
const char * checkException()
Check for exception thrown.
Definition XQueryProcessor.cpp:409
void setStreaming(bool option)
Say whether the query should be compiled and evaluated to use streaming.
Definition XQueryProcessor.cpp:363
bool exceptionOccurred()
Definition XQueryProcessor.cpp:391
XdmValue * getParameter(const char *name, bool withParam=true)
Definition XQueryProcessor.cpp:169
void runQueryToFile()
Execute the Query cached to file.
Definition XQueryProcessor.cpp:354
const char * getErrorCode()
Get the first error code if there are any errors.
Definition XQueryProcessor.cpp:395
void setParameter(const char *name, XdmValue *value, bool withParam=true)
Definition XQueryProcessor.cpp:181
void declareNamespace(const char *prefix, const char *uri)
Declare a namespace binding.
Definition XQueryProcessor.cpp:134
void setContextItem(XdmItem *value)
Set the initial context item for the query.
Definition XQueryProcessor.cpp:119
const char * executeQueryToString(const char *infilename, const char *query, const char *encoding=nullptr)
Perform the Query to a string representation.
Definition XQueryProcessor.cpp:318
XdmValue * runQueryToValue()
Execute the Query cached.
Definition XQueryProcessor.cpp:350
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition XQueryProcessor.cpp:111
void clearProperties()
Clear property values set.
Definition XQueryProcessor.cpp:236
void exceptionClear()
Clear any exception thrown.
Definition XQueryProcessor.cpp:383
void setLanguageVersion(const char *version)
Set XQuery language version.
Definition XQueryProcessor.cpp:374
XdmValue * executeQueryToValue(const char *infilename, const char *query, const char *encoding=nullptr)
Perform the Query to a XdmValue representation.
Definition XQueryProcessor.cpp:288
void setProperty(const char *name, const char *value)
Set a property specific to the processor in use.
Definition XQueryProcessor.cpp:204
void setUpdating(bool updating)
Say whether the query is allowed to be updating.
Definition XQueryProcessor.cpp:251
const char * runQueryToString()
Definition XQueryProcessor.cpp:346
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition XQueryProcessor.cpp:106
void setContextItemFromFile(const char *filename)
Definition XQueryProcessor.cpp:158
void setQueryContent(const char *content)
Compile a query supplied as a string.
Definition XQueryProcessor.cpp:378
bool isStreaming()
Ask whether the streaming option has been set.
Definition XQueryProcessor.cpp:372
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition XQueryProcessor.cpp:198
const char * getErrorMessage()
Get the first error message if there are any errors.
Definition XQueryProcessor.cpp:402
SaxonApiException * getException()
Get the SaxonApiException object created when we have an error.
Definition XQueryProcessor.cpp:418
XQueryProcessor()
Default constructor.
Definition XQueryProcessor.cpp:14
XQueryProcessor * clone()
Definition XQueryProcessor.cpp:101
Definition XdmItem.h:30
Definition XdmValue.h:42