SourceForge.net Logo

XQilla.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001, 2008,
00003  *     DecisionSoft Limited. All rights reserved.
00004  * Copyright (c) 2004, 2011,
00005  *     Oracle and/or its affiliates. All rights reserved.
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *     http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 
00020 #ifndef _XQILLA_07637_HPP
00021 #define _XQILLA_07637_HPP
00022 
00023 #include <xqilla/framework/XQillaExport.hpp>
00024 
00025 #include <xercesc/framework/MemoryManager.hpp>
00026 #include <xercesc/util/PlatformUtils.hpp>
00027 #include <xercesc/util/XMemory.hpp>
00028 
00029 class DynamicContext;
00030 class XPath2MemoryManager;
00031 class XQillaConfiguration;
00032 class Optimizer;
00033 class DelayedFuncFactory;
00034 class XQQuery;
00035 
00036 XERCES_CPP_NAMESPACE_BEGIN
00037 class InputSource;
00038 class XMLBuffer;
00039 XERCES_CPP_NAMESPACE_END
00040 
00041 namespace CompileDelayedModule {
00042 void compile(const XMLCh *queryFile);
00043 }
00044 
00052 class XQILLA_API XQilla : public XERCES_CPP_NAMESPACE_QUALIFIER XMemory
00053 {
00054 public:
00056   enum Flags {
00057     NO_STATIC_RESOLUTION = 0x1, 
00058     NO_ADOPT_CONTEXT     = 0x2, 
00059     DEBUG_QUERY          = 0x4, 
00060     NO_OPTIMIZATION      = 0x8, 
00061     NO_DEFAULT_MODULES   = 0x10 
00062   };
00063 
00065   enum Language {
00066     XQUERY     = 0x00,
00067     XPATH2     = 0x01,
00068     FULLTEXT   = 0x02,
00069     UPDATE     = 0x04,
00070     EXTENSIONS = 0x08,
00071     XSLT2      = 0x10,
00072     VERSION3   = 0x20,
00073 
00074     XQUERY_FULLTEXT          = (XQUERY | FULLTEXT),
00075     XQUERY_UPDATE            = (XQUERY | UPDATE),
00076     XQUERY_FULLTEXT_UPDATE   = (XQUERY | FULLTEXT | UPDATE),
00077     XPATH2_FULLTEXT          = (XPATH2 | FULLTEXT),
00078     XSLT2_FULLTEXT           = (XSLT2 | FULLTEXT),
00079 
00080     XQUERY3                  = (XQUERY | VERSION3),
00081     XQUERY3_FULLTEXT         = (XQUERY | VERSION3 | FULLTEXT),
00082     XQUERY3_UPDATE           = (XQUERY | VERSION3 | UPDATE),
00083     XQUERY3_FULLTEXT_UPDATE  = (XQUERY | VERSION3 | FULLTEXT | UPDATE),
00084     XPATH3                   = (XPATH2 | VERSION3),
00085     XPATH3_FULLTEXT          = (XPATH2 | VERSION3 | FULLTEXT),
00086     XSLT3                    = (XSLT2 | VERSION3),
00087     XSLT3_FULLTEXT           = (XSLT2 | VERSION3 | FULLTEXT),
00088   };
00089                                                                                                                                                               
00096   XQilla(XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr = 0);
00097 
00102   ~XQilla();
00103 
00105         // @{
00106 
00123   static XQQuery* parse(const XMLCh* query,
00124                         DynamicContext* context = 0,
00125                         const XMLCh* queryFile = NULL,
00126                         unsigned int flags = 0,
00127                         XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00128                         XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager,
00129                         XQQuery *result = 0);
00130 
00145   static XQQuery* parse(const XERCES_CPP_NAMESPACE_QUALIFIER InputSource& querySrc,
00146                         DynamicContext* context = 0,
00147                         unsigned int flags = 0,
00148                         XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00149                         XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager,
00150                         XQQuery *result = 0);
00151 
00166   static XQQuery* parseFromURI(const XMLCh* queryFile,
00167                                DynamicContext* context = 0,
00168                                unsigned int flags = 0,
00169                                XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00170                                XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager,
00171                                XQQuery *result = 0);
00172 
00174 
00176   // @{
00177 
00183   static DynamicContext *createContext(Language language = XQUERY,
00184                                        XQillaConfiguration *conf = 0,
00185                                        XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00186                                        XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
00187 
00189 
00190 private:
00191   static bool readQuery(const XMLCh* queryFile, 
00192                         XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr, 
00193                         XERCES_CPP_NAMESPACE_QUALIFIER XMLBuffer& queryText);
00194   static bool readQuery(const XERCES_CPP_NAMESPACE_QUALIFIER InputSource& querySrc, 
00195                         XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr, 
00196                         XERCES_CPP_NAMESPACE_QUALIFIER XMLBuffer& queryText);
00197   static Optimizer *createOptimizer(DynamicContext *context, unsigned int flags);
00198 
00199   static void compileDelayedModule(const XMLCh* queryFile, XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00200                                    XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
00201 
00202   friend void CompileDelayedModule::compile(const XMLCh *queryFile);
00203   friend class DelayedFuncFactory;
00204 };
00205 
00206 #endif