8 #ifndef SAXON_PROCESSOR_H
9 #define SAXON_PROCESSOR_H
11 #if defined __linux__ || defined __APPLE__
17 #define LoadLibrary(x) dlopen(x, RTLD_LAZY)
18 #define GetProcAddress(x,y) dlsym(x,y)
24 #define CVERSION "1.1.2"
32 #include "SaxonCGlue.h"
33 #include "SaxonCXPath.h"
34 #include "XsltProcessor.h"
35 #include "XQueryProcessor.h"
36 #include "XPathProcessor.h"
37 #include "SchemaValidator.h"
59 std::string errorCode;
60 std::string errorMessage;
81 exceptions = std::vector<MyException>(0);
89 exceptions = ex.exceptions;
98 exceptions = std::vector<MyException>(0);
101 newEx.errorCode = std::string(ec);
103 newEx.errorCode =
"Unknown";
106 newEx.errorMessage = std::string(exM);
108 newEx.errorMessage=
"Unkown";
110 newEx.isType =
false;
111 newEx.isStatic =
false;
112 newEx.isGlobal =
false;
113 newEx.linenumber = 0;
114 exceptions.push_back(newEx);
126 SaxonApiException(
const char * ec,
const char * exM,
bool typeErr,
bool stat,
bool glob,
int l){
127 exceptions = std::vector<MyException>(20);
130 newEx.errorCode = std::string(ec);
132 newEx.errorCode =
"ERROR1";
135 newEx.errorMessage = std::string(exM);
137 newEx.errorMessage=
"ERROR2";
139 newEx.isType = typeErr;
140 newEx.isStatic = stat;
141 newEx.isGlobal = glob;
142 newEx.linenumber = l;
143 exceptions.push_back(newEx);
155 void add(
const char * ec,
const char * exM,
bool typeErr,
bool stat,
bool glob,
int l){
158 newEx.errorCode = std::string(ec);
160 newEx.errorCode =
"ERROR1";
163 newEx.errorMessage = std::string(exM);
165 newEx.errorMessage=
"ERROR2";
167 newEx.isType = typeErr;
168 newEx.isStatic = stat;
169 newEx.isGlobal = glob;
170 newEx.linenumber = l;
171 exceptions.push_back(newEx);
188 if((
size_t)i <= exceptions.size()){
189 return exceptions[i].errorCode.c_str();
195 int getLineNumber(
int i){
196 if((
size_t)i <= exceptions.size()){
197 return exceptions[i].linenumber;
202 bool isGlobalError(
int i){
203 if((
size_t)i <= exceptions.size()){
204 return exceptions[i].isGlobal;
209 bool isStaticError(
int i){
210 if((
size_t)i <= exceptions.size()){
211 return exceptions[i].isStatic;
216 bool isTypeError(
int i){
217 if((
size_t) i <= exceptions.size()){
218 return exceptions[i].isType;
224 for(
size_t i =0; i< exceptions.size();i++) {
225 exceptions[i].errorCode.clear();
226 exceptions[i].errorMessage.clear();
232 return (
int)exceptions.size();
242 if((
size_t)i <= exceptions.size()){
243 return exceptions[i].errorMessage.c_str();
248 const char * getErrorMessages(){
250 for(
size_t i = 0;i<exceptions.size();i++) {
253 if(result.empty()) {
return NULL;}
254 return result.c_str();
263 if((
size_t)i <= exceptions.size()){
264 return exceptions[i];
272 std::vector<MyException> exceptions;
457 int getNodeKind(jobject);
459 bool isSchemaAware();
488 static void release();
534 void addNativeMethod(
char *name,
char* signature,
void * fnPtr){
536 JNINativeMethod method;
538 method.signature = signature;
539 method.fnPtr = fnPtr;
553 bool registerCPPFunction(
char * libName, JNINativeMethod * gMethods=NULL){
554 if(libName != NULL) {
562 if(gMethods == NULL) {
566 return registerNativeMethods(sxn_environ->env,
"com/saxonica/functions/extfn/CppCall$PhpFunctionCall",
567 gMethods,
sizeof(gMethods) /
sizeof(gMethods[0]));
578 static bool registerNativeMethods(JNIEnv* env,
const char* className,
579 JNINativeMethod* gMethods,
int numMethods)
582 clazz = env->FindClass(className);
587 if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
595 const char* checkException(jobject cpp);
598 void checkAndCreateException(jclass cppClass);
607 static int jvmCreatedCPP;
616 jclass xdmAtomicClass;
619 jclass saxonCAPIClass;
629 JNINativeMethod * nativeMethods;
634 void applyConfigurationProperties();
XdmAtomicValue * makeFloatValue(float)
Definition: SaxonProcessor.cpp:564
void exceptionClear(bool clearCPPException=true)
Definition: SaxonProcessor.cpp:71
XdmAtomicValue * makeBooleanValue(bool b)
Definition: SaxonProcessor.cpp:582
MyException getException(int i)
Definition: SaxonProcessor.h:262
std::vector< JNINativeMethod > nativeMethodVect
Definition: SaxonProcessor.h:630
Definition: XQueryProcessor.h:26
void setcwd(const char *cwd)
Definition: SaxonProcessor.cpp:376
std::map< std::string, XdmValue * > parameters
Definition: SaxonProcessor.h:623
XdmAtomicValue * makeDoubleValue(double d)
Definition: SaxonProcessor.cpp:555
SaxonApiException * checkForExceptionCPP(JNIEnv *env, jclass callingClass, jobject callingObject)
Definition: SaxonProcessor.cpp:88
std::string cwd
Definition: SaxonProcessor.h:610
SaxonApiException(const char *ec, const char *exM, bool typeErr, bool stat, bool glob, int l)
Definition: SaxonProcessor.h:126
Definition: XdmAtomicValue.h:21
Definition: SaxonCGlue.h:80
std::map< std::string, std::string > configProperties
Definition: SaxonProcessor.h:624
const char * getStringValue(XdmItem *item)
Definition: SaxonProcessor.cpp:605
void clearConfigurationProperties()
Definition: SaxonProcessor.cpp:499
SaxonApiException()
Definition: SaxonProcessor.h:80
~SaxonProcessor()
Definition: SaxonProcessor.cpp:273
SaxonApiException(const SaxonApiException &ex)
Definition: SaxonProcessor.h:88
jobject proc
Definition: SaxonProcessor.h:611
XdmAtomicValue * makeLongValue(long l)
Definition: SaxonProcessor.cpp:573
Definition: SaxonProcessor.h:73
Definition: SchemaValidator.h:26
XPathProcessor * newXPathProcessor()
Definition: SaxonProcessor.cpp:340
const char * getErrorMessage(int i)
Definition: SaxonProcessor.h:241
Definition: XdmValue.h:44
const char * getResourcesDirectory()
Definition: SaxonProcessor.cpp:385
XdmNode * parseXmlFromUri(const char *source)
Definition: SaxonProcessor.cpp:468
SaxonApiException(const char *ec, const char *exM)
Definition: SaxonProcessor.h:97
Definition: XsltProcessor.h:24
XdmNode * parseXmlFromFile(const char *source)
Definition: SaxonProcessor.cpp:446
SchemaValidator * newSchemaValidator()
Definition: SaxonProcessor.cpp:345
Definition: SaxonProcessor.h:290
XdmAtomicValue * makeIntegerValue(int i)
Definition: SaxonProcessor.cpp:544
const char * version()
Definition: SaxonProcessor.cpp:357
XdmAtomicValue * makeAtomicValue(std::string type, std::string value)
Definition: SaxonProcessor.cpp:598
void setConfigurationProperty(const char *name, const char *value)
Definition: SaxonProcessor.cpp:493
XdmAtomicValue * makeStringValue(std::string str)
Definition: SaxonProcessor.cpp:526
Definition: SaxonProcessor.h:58
XdmNode * parseXmlFromString(const char *source)
Definition: SaxonProcessor.cpp:390
const char * getErrorCode(int i)
Definition: SaxonProcessor.h:187
void setResourcesDirectory(const char *dir)
Definition: SaxonProcessor.cpp:380
SaxonApiException * exception
Definition: SaxonProcessor.h:627
Definition: XPathProcessor.h:26
bool licensei
Definition: SaxonProcessor.h:625
bool exceptionOccurred()
Definition: SaxonProcessor.cpp:35
XsltProcessor * newXsltProcessor()
Definition: SaxonProcessor.cpp:330
~SaxonApiException()
Definition: SaxonProcessor.h:178
SaxonProcessor()
A default constructor.
Definition: SaxonProcessor.cpp:82
XQueryProcessor * newXQueryProcessor()
Definition: SaxonProcessor.cpp:335
XdmAtomicValue * makeQNameValue(std::string str)
Definition: SaxonProcessor.cpp:591
std::string cwdV
Definition: SaxonProcessor.h:620
void add(const char *ec, const char *exM, bool typeErr, bool stat, bool glob, int l)
Definition: SaxonProcessor.h:155