SourceForge.net Logo

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 475 2008-01-08 18:47:44Z 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 XQQuery;
00038 
00039 typedef std::vector<XQUserFunction*, XQillaAllocator<XQUserFunction*> > UserFunctions;
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 
00102   void execute(EventHandler *events, DynamicContext* context) const;
00103 
00123   void staticResolution(StaticContext *context = 0);
00124 
00137   void staticTyping(StaticContext *context = 0);
00138 
00140 
00142   // @{
00143 
00145   const XMLCh* getQueryText() const;
00146 
00148   std::string getQueryPlan() const;
00149 
00151 
00153   // @{
00154 
00156   ASTNode* getQueryBody() const;
00158   void setQueryBody(ASTNode* query);
00159 
00161   void addFunction(XQUserFunction* fnDef);
00163   const UserFunctions &getFunctions() const { return m_userDefFns; }
00164 
00166   void addVariable(XQGlobalVariable* varDef);
00168   const GlobalVariables &getVariables() const { return m_userDefVars; }
00169 
00171   const ImportedModules &getImportedModules() const { return m_importedModules; }
00172 
00174   const XMLCh* getFile() const;
00176   void setFile(const XMLCh* file);
00177 
00178   const DynamicContext *getStaticContext() const { return m_context; }
00179 
00181 
00183   // @{
00184 
00186   void setIsLibraryModule(bool bIsModule=true);
00188   bool getIsLibraryModule() const;
00190   void setModuleTargetNamespace(const XMLCh* uri);
00192   const XMLCh* getModuleTargetNamespace() const;
00194   void importModule(const XMLCh* szUri, VectorOfStrings* locations, StaticContext* context, const LocationInfo *location);
00195 
00197 
00198 private:
00200   class QueryResult : public ResultImpl
00201   {
00202   public:
00203     QueryResult(const XQQuery *query);
00204 
00205     Item::Ptr next(DynamicContext *context);
00206     std::string asString(DynamicContext *context, int indent) const;
00207 
00208   private:
00209     const XQQuery *_query;
00210     Result _parent;
00211     bool _toDo;
00212   };
00213 
00214 private:
00216   XQQuery(const XMLCh* queryText, DynamicContext *context, bool contextOwned = false,
00217           XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00218           XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
00219 
00220   XQQuery(const XQQuery &);
00221   XQQuery &operator=(const XQQuery &);
00222 
00223   void executeProlog(DynamicContext *context) const;
00224 
00225 private:
00227   XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* m_memMgr;
00228 
00230   DynamicContext *m_context;
00231   bool m_contextOwned;
00232 
00233   ASTNode* m_query;
00234 
00235   bool m_bIsLibraryModule;
00236   const XMLCh* m_szTargetNamespace;
00237   const XMLCh* m_szQueryText;
00238   const XMLCh* m_szCurrentFile;
00239 
00240   UserFunctions m_userDefFns;
00241   GlobalVariables m_userDefVars;
00242   ImportedModules m_importedModules;
00243 
00244   friend class QueryResult;
00245   friend class XQilla;
00246 };
00247 
00248 #endif

Generated on Mon Apr 28 16:40:48 2008 for XQilla Simple API by  doxygen 1.5.1