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.2.1 2007/01/03 19:19:51 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 #include <xqilla/simple-api/XQilla.hpp>
00030 
00031 class DynamicContext;
00032 class XQUserFunction;
00033 class XQGlobalVariable;
00034 class XQQuery;
00035 
00036 typedef std::vector<XQUserFunction*, XQillaAllocator<XQUserFunction*> > UserFunctions;
00037 typedef std::vector<XQGlobalVariable*, XQillaAllocator<XQGlobalVariable*> > GlobalVariables;
00038 typedef std::vector<XQQuery*, XQillaAllocator<XQQuery*> > ImportedModules;
00039 
00054 class XQILLA_API XQQuery : public XERCES_CPP_NAMESPACE_QUALIFIER XMemory
00055 {
00056 public:
00058   ~XQQuery();
00059 
00061         // @{
00062 
00071   DynamicContext *createDynamicContext(XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *memMgr =
00072                                        XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager) const;
00073 
00086   Result execute(DynamicContext* context) const;
00087 
00107   void staticResolution(StaticContext *context = 0);
00108 
00121   void staticTyping(StaticContext *context = 0);
00122 
00124 
00126         // @{
00127 
00129   const XMLCh* getQueryText() const;
00130 
00132   std::string getQueryPlan() const;
00133 
00135 
00137         // @{
00138 
00140   ASTNode* getQueryBody() const;
00142   void setQueryBody(ASTNode* query);
00143 
00145   void addFunction(XQUserFunction* fnDef);
00147   const UserFunctions &getFunctions() const { return m_userDefFns; }
00148 
00150   void addVariable(XQGlobalVariable* varDef);
00152   const GlobalVariables &getVariables() const { return m_userDefVars; }
00153 
00155   const ImportedModules &getImportedModules() const { return m_importedModules; }
00156 
00158   const XMLCh* getFile() const;
00160   void setFile(const XMLCh* file);
00161 
00162   const DynamicContext *getStaticContext() const { return m_context; }
00163 
00165 
00167         // @{
00168 
00170   void setIsLibraryModule(bool bIsModule=true);
00172   bool getIsLibraryModule() const;
00174   void setModuleTargetNamespace(const XMLCh* uri);
00176   const XMLCh* getModuleTargetNamespace() const;
00178   void importModule(XQilla::Language language, const XMLCh* szUri,
00179                     VectorOfStrings* locations, StaticContext* context);
00180 
00182 
00183 private:
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 Fri Jan 19 15:30:53 2007 for XQilla Simple API by  doxygen 1.4.6