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.16 2006/11/01 16:37:17 jpcs Exp $
00012  */
00013 
00015 // XQQuery.h: interface for the XQQuery class.
00017 
00018 #if !defined(AFXQ_XQUERY_H__FAA9933A_2F10_49A4_93A2_857E2A8C48E3__INCLUDED_)
00019 #define AFXQ_XQUERY_H__FAA9933A_2F10_49A4_93A2_857E2A8C48E3__INCLUDED_
00020 
00021 #include <xqilla/framework/XQillaExport.hpp>
00022 #include <vector>
00023 #include <string>
00024 #include <xercesc/util/XMemory.hpp>
00025 #include <xercesc/sax/InputSource.hpp>
00026 #include <xqilla/runtime/ResultImpl.hpp>
00027 #include <xqilla/runtime/LazySequenceResult.hpp>
00028 #include <xqilla/context/StaticContext.hpp>
00029 
00030 class DynamicContext;
00031 class XQUserFunction;
00032 class XQGlobalVariable;
00033 class XQQuery;
00034 
00035 typedef std::vector<XQUserFunction*, XQillaAllocator<XQUserFunction*> > UserFunctions;
00036 typedef std::vector<XQGlobalVariable*, XQillaAllocator<XQGlobalVariable*> > GlobalVariables;
00037 typedef std::vector<XQQuery*, XQillaAllocator<XQQuery*> > ImportedModules;
00038 
00053 class XQILLA_API XQQuery : public XERCES_CPP_NAMESPACE_QUALIFIER XMemory
00054 {
00055 public:
00057   ~XQQuery();
00058 
00060         // @{
00061 
00070   DynamicContext *createDynamicContext(XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00071                                        XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager) const;
00072 
00085   Result execute(DynamicContext* context) const;
00086 
00106   void staticResolution(StaticContext *context = 0);
00107 
00120   void staticTyping(StaticContext *context = 0);
00121 
00123 
00125         // @{
00126 
00128   const XMLCh* getQueryText() const;
00129 
00131   std::string getQueryPlan() const;
00132 
00134 
00136         // @{
00137 
00139   ASTNode* getQueryBody() const;
00141   void setQueryBody(ASTNode* query);
00142 
00144   void addFunction(XQUserFunction* fnDef);
00146   const UserFunctions &getFunctions() const { return m_userDefFns; }
00147 
00149   void addVariable(XQGlobalVariable* varDef);
00151   const GlobalVariables &getVariables() const { return m_userDefVars; }
00152 
00154   const ImportedModules &getImportedModules() const { return m_importedModules; }
00155 
00157   const XMLCh* getFile() const;
00159   void setFile(const XMLCh* file);
00160 
00161   const DynamicContext *getStaticContext() const { return m_context; }
00162 
00164 
00166         // @{
00167 
00169   void setIsLibraryModule(bool bIsModule=true);
00171   bool getIsLibraryModule() const;
00173   void setModuleTargetNamespace(const XMLCh* uri);
00175   const XMLCh* getModuleTargetNamespace() const;
00177   void importModule(const XMLCh* szUri, VectorOfStrings* locations, StaticContext* context);
00178 
00180 
00181 private:
00182   void importModuleImpl(const XMLCh* szUri, XERCES_CPP_NAMESPACE_QUALIFIER InputSource* location, StaticContext* context);
00183 
00185   class QueryResult : public ResultImpl
00186   {
00187   public:
00188     QueryResult(const XQQuery *query);
00189 
00190     Item::Ptr next(DynamicContext *context);
00191     std::string asString(DynamicContext *context, int indent) const;
00192 
00193   private:
00194     const XQQuery *_query;
00195     Result _parent;
00196     bool _toDo;
00197   };
00198 
00200   class DebugResult : public LazySequenceResult
00201   {
00202   public:
00203     DebugResult(const XQQuery *query, DynamicContext *context);
00204 
00205     void getResult(Sequence &toFill, DynamicContext *context) const;
00206     std::string asString(DynamicContext *context, int indent) const;
00207 
00208   private:
00209     const XQQuery *_query;
00210   };
00211 
00212 private:
00214   XQQuery(const XMLCh* queryText, DynamicContext *context, bool contextOwned = false,
00215           XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00216           XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
00217 
00218   XQQuery(const XQQuery &);
00219   XQQuery &operator=(const XQQuery &);
00220 
00221 private:
00223   XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* m_memMgr;
00224 
00226   DynamicContext *m_context;
00227   bool m_contextOwned;
00228 
00229   ASTNode* m_query;
00230 
00231   bool m_bIsLibraryModule;
00232   const XMLCh* m_szTargetNamespace;
00233   const XMLCh* m_szQueryText;
00234   const XMLCh* m_szCurrentFile;
00235 
00236   UserFunctions m_userDefFns;
00237   GlobalVariables m_userDefVars;
00238   ImportedModules m_importedModules;
00239 
00240   friend class QueryResult;
00241   friend class DebugResult;
00242   friend class XQilla;
00243 };
00244 
00245 #endif // !defined(AFXQ_XQUERY_H__FAA9933A_2F10_49A4_93A2_857E2A8C48E3__INCLUDED_)

Generated on Tue Dec 12 00:18:56 2006 for XQilla Simple API by  doxygen 1.4.6