SourceForge.net Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Examples

XQQuery.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2008
00003  *     DecisionSoft Limited. All rights reserved.
00004  * Copyright (c) 2004-2008
00005  *     Oracle. 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  * $Id: XQQuery.hpp 690 2008-11-28 17:42:43Z jpcs $
00020  */
00021 
00022 #ifndef XQQUERY_HPP
00023 #define XQQUERY_HPP
00024 
00025 #include <xqilla/framework/XQillaExport.hpp>
00026 #include <vector>
00027 #include <string>
00028 #include <xercesc/util/XMemory.hpp>
00029 #include <xercesc/sax/InputSource.hpp>
00030 #include <xqilla/runtime/ResultImpl.hpp>
00031 #include <xqilla/runtime/LazySequenceResult.hpp>
00032 #include <xqilla/context/StaticContext.hpp>
00033 
00034 class DynamicContext;
00035 class XQUserFunction;
00036 class XQGlobalVariable;
00037 class XQUserFunctionInstance;
00038 class XQQuery;
00039 
00040 typedef std::vector<XQGlobalVariable*, XQillaAllocator<XQGlobalVariable*> > GlobalVariables;
00041 typedef std::vector<XQQuery*, XQillaAllocator<XQQuery*> > ImportedModules;
00042 
00057 class XQILLA_API XQQuery : public XERCES_CPP_NAMESPACE_QUALIFIER XMemory
00058 {
00059 public:
00061   ~XQQuery();
00062 
00064         // @{
00065 
00074   DynamicContext *createDynamicContext(XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00075                                        XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager) const;
00076 
00090   Result execute(DynamicContext* context) const;
00091 
00106   Result execute(const Item::Ptr &contextItem, DynamicContext *context) const;
00107 
00123   Result execute(const XMLCh *templateQName, DynamicContext *context) const;
00124 
00135   void execute(EventHandler *events, DynamicContext* context) const;
00136 
00148   void execute(EventHandler *events, const Item::Ptr &contextItem, DynamicContext *context) const;
00149 
00162   void execute(EventHandler *events, const XMLCh *templateQName, DynamicContext *context) const;
00163 
00183   void staticResolution(StaticContext *context = 0);
00184 
00197   void staticTyping(StaticContext *context = 0, StaticTyper *styper = 0);
00198 
00200 
00202   // @{
00203 
00205   const XMLCh* getQueryText() const;
00206 
00208   std::string getQueryPlan() const;
00209 
00211 
00213   // @{
00214 
00216   ASTNode* getQueryBody() const;
00218   void setQueryBody(ASTNode* query);
00219 
00221   void addFunction(XQUserFunction* fnDef);
00223   const UserFunctions &getFunctions() const { return m_userDefFns; }
00224 
00226   void addVariable(XQGlobalVariable* varDef);
00228   const GlobalVariables &getVariables() const { return m_userDefVars; }
00229 
00231   const ImportedModules &getImportedModules() const { return m_importedModules; }
00232 
00234   const XMLCh* getFile() const;
00236   void setFile(const XMLCh* file);
00237 
00238   const DynamicContext *getStaticContext() const { return m_context; }
00239 
00241 
00243   // @{
00244 
00246   void setIsLibraryModule(bool bIsModule=true);
00248   bool getIsLibraryModule() const;
00250   void setModuleTargetNamespace(const XMLCh* uri);
00252   const XMLCh* getModuleTargetNamespace() const;
00254   void importModule(const XMLCh* szUri, VectorOfStrings* locations, StaticContext* context, const LocationInfo *location);
00255 
00257 
00258 private:
00260   class QueryResult : public ResultImpl
00261   {
00262   public:
00263     QueryResult(const XQQuery *query);
00264 
00265     Item::Ptr nextOrTail(Result &tail, DynamicContext *context);
00266 
00267   private:
00268     const XQQuery *_query;
00269   };
00270 
00271 private:
00273   XQQuery(const XMLCh* queryText, DynamicContext *context, bool contextOwned = false,
00274           XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00275           XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
00276 
00277   XQQuery(const XQQuery &);
00278   XQQuery &operator=(const XQQuery &);
00279 
00280   void executeProlog(DynamicContext *context) const;
00281 
00282 private:
00284   XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* m_memMgr;
00285 
00287   DynamicContext *m_context;
00288   bool m_contextOwned;
00289 
00290   ASTNode* m_query;
00291 
00292   bool m_bIsLibraryModule;
00293   const XMLCh* m_szTargetNamespace;
00294   const XMLCh* m_szQueryText;
00295   const XMLCh* m_szCurrentFile;
00296 
00297   UserFunctions m_userDefFns;
00298   GlobalVariables m_userDefVars;
00299   ImportedModules m_importedModules;
00300 
00301   friend class QueryResult;
00302   friend class XQilla;
00303 };
00304 
00305 #endif

Generated on Fri Sep 25 06:55:26 2009 for XQilla Simple API by  doxygen 1.3.9.1