SourceForge.net Logo

XQQuery.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2006
00003  *     DecisionSoft Limited. All rights reserved.
00004  * Copyright (c) 2004-2006
00005  *     Progress Software Corporation. All rights reserved.
00006  * Copyright (c) 2004-2006
00007  *     Oracle. All rights reserved.
00008  *
00009  * See the file LICENSE for redistribution information.
00010  *
00011  * $Id: XQQuery.hpp,v 1.18 2007/07/10 16:28:59 jpcs Exp $
00012  */
00013 
00014 #ifndef XQQUERY_HPP
00015 #define XQQUERY_HPP
00016 
00017 #include <xqilla/framework/XQillaExport.hpp>
00018 #include <vector>
00019 #include <string>
00020 #include <xercesc/util/XMemory.hpp>
00021 #include <xercesc/sax/InputSource.hpp>
00022 #include <xqilla/runtime/ResultImpl.hpp>
00023 #include <xqilla/runtime/LazySequenceResult.hpp>
00024 #include <xqilla/context/StaticContext.hpp>
00025 
00026 class DynamicContext;
00027 class XQUserFunction;
00028 class XQGlobalVariable;
00029 class XQQuery;
00030 
00031 typedef std::vector<XQUserFunction*, XQillaAllocator<XQUserFunction*> > UserFunctions;
00032 typedef std::vector<XQGlobalVariable*, XQillaAllocator<XQGlobalVariable*> > GlobalVariables;
00033 typedef std::vector<XQQuery*, XQillaAllocator<XQQuery*> > ImportedModules;
00034 
00049 class XQILLA_API XQQuery : public XERCES_CPP_NAMESPACE_QUALIFIER XMemory
00050 {
00051 public:
00053   ~XQQuery();
00054 
00056         // @{
00057 
00066   DynamicContext *createDynamicContext(XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00067                                        XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager) const;
00068 
00082   Result execute(DynamicContext* context) const;
00083 
00094   void execute(EventHandler *events, DynamicContext* context) const;
00095 
00115   void staticResolution(StaticContext *context = 0);
00116 
00129   void staticTyping(StaticContext *context = 0);
00130 
00132 
00134   // @{
00135 
00137   const XMLCh* getQueryText() const;
00138 
00140   std::string getQueryPlan() const;
00141 
00143 
00145   // @{
00146 
00148   ASTNode* getQueryBody() const;
00150   void setQueryBody(ASTNode* query);
00151 
00153   void addFunction(XQUserFunction* fnDef);
00155   const UserFunctions &getFunctions() const { return m_userDefFns; }
00156 
00158   void addVariable(XQGlobalVariable* varDef);
00160   const GlobalVariables &getVariables() const { return m_userDefVars; }
00161 
00163   const ImportedModules &getImportedModules() const { return m_importedModules; }
00164 
00166   const XMLCh* getFile() const;
00168   void setFile(const XMLCh* file);
00169 
00170   const DynamicContext *getStaticContext() const { return m_context; }
00171 
00173 
00175   // @{
00176 
00178   void setIsLibraryModule(bool bIsModule=true);
00180   bool getIsLibraryModule() const;
00182   void setModuleTargetNamespace(const XMLCh* uri);
00184   const XMLCh* getModuleTargetNamespace() const;
00186   void importModule(const XMLCh* szUri, VectorOfStrings* locations, StaticContext* context, const LocationInfo *location);
00187 
00189 
00190 private:
00192   class QueryResult : public ResultImpl
00193   {
00194   public:
00195     QueryResult(const XQQuery *query);
00196 
00197     Item::Ptr next(DynamicContext *context);
00198     std::string asString(DynamicContext *context, int indent) const;
00199 
00200   private:
00201     const XQQuery *_query;
00202     Result _parent;
00203     bool _toDo;
00204   };
00205 
00206 private:
00208   XQQuery(const XMLCh* queryText, DynamicContext *context, bool contextOwned = false,
00209           XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00210           XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
00211 
00212   XQQuery(const XQQuery &);
00213   XQQuery &operator=(const XQQuery &);
00214 
00215   void executeProlog(DynamicContext *context) const;
00216 
00217 private:
00219   XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* m_memMgr;
00220 
00222   DynamicContext *m_context;
00223   bool m_contextOwned;
00224 
00225   ASTNode* m_query;
00226 
00227   bool m_bIsLibraryModule;
00228   const XMLCh* m_szTargetNamespace;
00229   const XMLCh* m_szQueryText;
00230   const XMLCh* m_szCurrentFile;
00231 
00232   UserFunctions m_userDefFns;
00233   GlobalVariables m_userDefVars;
00234   ImportedModules m_importedModules;
00235 
00236   friend class QueryResult;
00237   friend class XQilla;
00238 };
00239 
00240 #endif

Generated on Fri Aug 31 14:37:35 2007 for XQilla Simple API by  doxygen 1.5.1