SourceForge.net Logo
Public Member Functions | List of all members
XQQuery Class Reference

Encapsulates a query expression. More...

#include <XQQuery.hpp>

Inheritance diagram for XQQuery:
Inheritance graph
[legend]

Public Member Functions

 ~XQQuery ()
 Destructor. More...
 
Runtime Methods
DynamicContextcreateDynamicContext (xercesc::MemoryManager *memMgr=xercesc::XMLPlatformUtils::fgMemoryManager) const
 Creates a DynamicContext based on the static context used to parse this query. More...
 
Result execute (DynamicContext *context) const
 Executes the query using the given DynamicContext, returning a lazy iterator over the results. More...
 
Result execute (const Item::Ptr &contextItem, DynamicContext *context) const
 Executes the query or stylesheet using the given context item and DynamicContext, returning a lazy iterator over the results. More...
 
Result execute (const XMLCh *templateQName, DynamicContext *context) const
 Executes the stylesheet starting at the named template using the given DynamicContext, returning a lazy iterator over the results. More...
 
void execute (EventHandler *events, DynamicContext *context) const
 Executes the query using the given DynamicContext, sending the output of the query to the given EventHandler. More...
 
void execute (EventHandler *events, const Item::Ptr &contextItem, DynamicContext *context) const
 Executes the query or stylesheet using the given context item and DynamicContext, sending the output of the query to the given EventHandler. More...
 
void execute (EventHandler *events, const XMLCh *templateQName, DynamicContext *context) const
 Executes the stylesheet starting at the named template using the given DynamicContext, sending the output of the query to the given EventHandler. More...
 
void staticResolution ()
 Perform static resolution on the query. More...
 
void staticTyping (StaticTyper *styper=0)
 Perform type calculation and related optimizations. More...
 
bool staticTypingOnce (StaticTyper *styper=0)
 
Query Information
const XMLCh * getQueryText () const
 Returns the expression that was parsed to create this XQQuery object. More...
 
void setQueryText (const XMLCh *v)
 
std::string getQueryPlan () const
 Returns the query plan as XML. This is designed for debug and informative purposes only. More...
 
Getters and Setters
ASTNode * getQueryBody () const
 Get the query body as an ASTNode. More...
 
void setQueryBody (ASTNode *query)
 Set the query body to an ASTNode. More...
 
void addFunction (XQUserFunction *fnDef)
 Adds an XQUserFunction to the query (also adds it as a template if necessary) More...
 
const UserFunctionsgetFunctions () const
 Returns a vector of all XQUserFunction objects from the query. More...
 
void addDelayedFunction (const XMLCh *uri, const XMLCh *name, size_t numArgs, const XMLCh *functionDeclaration, bool isPrivate=false, int line=1, int column=1)
 Adds a function defined in XQuery syntax. More...
 
void addDelayedFunction (const XMLCh *uri, const XMLCh *name, size_t numArgs, const char *functionDeclaration, bool isPrivate=false, int line=1, int column=1)
 
const DelayedFunctionsgetDelayedFunctions () const
 Returns a vector of all XQUserFunction objects from the query. More...
 
void addVariable (XQGlobalVariable *varDef)
 Adds a XQGlobalVariable to the query. More...
 
const GlobalVariablesgetVariables () const
 Returns a vector of all XQGlobalVariable objects from the query. More...
 
const ImportedModulesgetImportedModules () const
 Returns a vector of all XQGlobalVariable objects from the query. More...
 
ModuleCachegetModuleCache () const
 
bool isModuleCacheOwned () const
 
const XMLCh * getFile () const
 Returns the name of the file that this query was parsed from. More...
 
void setFile (const XMLCh *file)
 Sets the name of the file that this query was parsed from. More...
 
bool getVersion3 () const
 
void setVersion3 (bool v)
 
const DynamicContextgetStaticContext () const
 
XQQuerygetNext () const
 
void setNext (XQQuery *n)
 
Module Methods
void setIsLibraryModule (bool bIsModule=true)
 Sets whether this query is a module or not. More...
 
bool getIsLibraryModule () const
 Returns whether this query is a module or not. More...
 
void setModuleTargetNamespace (const XMLCh *uri)
 Sets the module target namespace for this query. More...
 
const XMLCh * getModuleTargetNamespace () const
 Gets the module taget namespace for this query. More...
 
void importModule (const XMLCh *szUri, VectorOfStrings *locations, const LocationInfo *location)
 Performs a module import from the given target namespace and locations. More...
 
void importModule (XQQuery *module)
 
XQQueryfindModuleForVariable (const XMLCh *uri, const XMLCh *name)
 
XQQueryfindModuleForFunction (const XMLCh *uri, const XMLCh *name, int numArgs)
 
- Public Member Functions inherited from xercesc::XMemory
void * operator new (size_t size)
 This method overrides operator new. More...
 
void * operator new (size_t size, MemoryManager *memMgr)
 This method defines a custom operator new, that will use the provided memory manager to perform the allocation. More...
 
void * operator new (size_t size, void *ptr)
 This method overrides placement operator new. More...
 
void operator delete (void *p)
 This method overrides operator delete. More...
 
void operator delete (void *p, MemoryManager *memMgr)
 This method provides a matching delete for the custom operator new. More...
 
void operator delete (void *p, void *ptr)
 This method provides a matching delete for the placement new. More...
 

Additional Inherited Members

- Protected Member Functions inherited from xercesc::XMemory
 XMemory ()
 Protected default constructor. More...
 

Detailed Description

Encapsulates a query expression.

XQQuery objects are thread safe, and can be executed from multiple threads at the same time - provided a DynamicContext is used per thread.

Instances of this class can be created by using the parsing methods on the XQilla object.

This class is dependant on the DynamicContext that was used to create it. This context must not be deleted before the XQQuery object. Normally this is acheived by the XQQuery adopting the DynamicContext and deleting it when it is deleted. However, this behaviour can be disabled by using the XQilla::NO_ADOPT_CONTEXT flag when creating the XQQuery.

Constructor & Destructor Documentation

XQQuery::~XQQuery ( )

Destructor.

Member Function Documentation

void XQQuery::addDelayedFunction ( const XMLCh *  uri,
const XMLCh *  name,
size_t  numArgs,
const XMLCh *  functionDeclaration,
bool  isPrivate = false,
int  line = 1,
int  column = 1 
)

Adds a function defined in XQuery syntax.

Parsing is delayed until the function is actually needed.

void XQQuery::addDelayedFunction ( const XMLCh *  uri,
const XMLCh *  name,
size_t  numArgs,
const char *  functionDeclaration,
bool  isPrivate = false,
int  line = 1,
int  column = 1 
)
void XQQuery::addFunction ( XQUserFunction *  fnDef)

Adds an XQUserFunction to the query (also adds it as a template if necessary)

void XQQuery::addVariable ( XQGlobalVariable *  varDef)

Adds a XQGlobalVariable to the query.

DynamicContext* XQQuery::createDynamicContext ( xercesc::MemoryManager memMgr = xercesc::XMLPlatformUtils::fgMemoryManager) const

Creates a DynamicContext based on the static context used to parse this query.

This DynamicContext will be suitable for using to call execute().

Parameters
memMgrThe memory manager used to create the DynamicContext.
Returns
An implementation of DynamicContext
Result XQQuery::execute ( DynamicContext context) const

Executes the query using the given DynamicContext, returning a lazy iterator over the results.

Parameters
contextThe DynamicContext to use to execute the query. This contains runtime values for variables, the value of the context item, and other relevent information.
Returns
The Result object - a lazy iterator over the query results.
Exceptions
XQExceptionIf a runtime error occurs
Result XQQuery::execute ( const Item::Ptr contextItem,
DynamicContext context 
) const

Executes the query or stylesheet using the given context item and DynamicContext, returning a lazy iterator over the results.

Parameters
contextItemThe context item to use to execute the query.
contextThe DynamicContext to use to execute the query. This contains runtime values for variables, the value of the context item, and other relevent information.
Returns
The Result object - a lazy iterator over the query results.
Exceptions
XQExceptionIf a runtime error occurs
Result XQQuery::execute ( const XMLCh *  templateQName,
DynamicContext context 
) const

Executes the stylesheet starting at the named template using the given DynamicContext, returning a lazy iterator over the results.

Parameters
templateQNameThe name of the template to start executing. If the QName includes a prefix, it is resolved using the in-scope namespaces for the stylesheet.
contextThe DynamicContext to use to execute the query. This contains runtime values for variables, the value of the context item, and other relevent information.
Returns
The Result object - a lazy iterator over the query results.
Exceptions
XQExceptionIf a runtime error occurs
void XQQuery::execute ( EventHandler events,
DynamicContext context 
) const

Executes the query using the given DynamicContext, sending the output of the query to the given EventHandler.

Parameters
contextThe DynamicContext to use to execute the query. This contains runtime values for variables, the value of the context item, and other relevent information.
Exceptions
XQExceptionIf a runtime error occurs
void XQQuery::execute ( EventHandler events,
const Item::Ptr contextItem,
DynamicContext context 
) const

Executes the query or stylesheet using the given context item and DynamicContext, sending the output of the query to the given EventHandler.

Parameters
contextItemThe context item to use to execute the query.
contextThe DynamicContext to use to execute the query. This contains runtime values for variables, the value of the context item, and other relevent information.
Exceptions
XQExceptionIf a runtime error occurs
void XQQuery::execute ( EventHandler events,
const XMLCh *  templateQName,
DynamicContext context 
) const

Executes the stylesheet starting at the named template using the given DynamicContext, sending the output of the query to the given EventHandler.

Parameters
templateQNameThe name of the template to start executing. If the QName includes a prefix, it is resolved using the in-scope namespaces for the stylesheet.
contextThe DynamicContext to use to execute the query. This contains runtime values for variables, the value of the context item, and other relevent information.
Exceptions
XQExceptionIf a runtime error occurs
XQQuery* XQQuery::findModuleForFunction ( const XMLCh *  uri,
const XMLCh *  name,
int  numArgs 
)
XQQuery* XQQuery::findModuleForVariable ( const XMLCh *  uri,
const XMLCh *  name 
)
const DelayedFunctions& XQQuery::getDelayedFunctions ( ) const
inline

Returns a vector of all XQUserFunction objects from the query.

const XMLCh* XQQuery::getFile ( ) const
inline

Returns the name of the file that this query was parsed from.

const UserFunctions& XQQuery::getFunctions ( ) const
inline

Returns a vector of all XQUserFunction objects from the query.

const ImportedModules& XQQuery::getImportedModules ( ) const
inline

Returns a vector of all XQGlobalVariable objects from the query.

bool XQQuery::getIsLibraryModule ( ) const

Returns whether this query is a module or not.

ModuleCache* XQQuery::getModuleCache ( ) const
inline
const XMLCh* XQQuery::getModuleTargetNamespace ( ) const

Gets the module taget namespace for this query.

XQQuery* XQQuery::getNext ( ) const
inline
ASTNode* XQQuery::getQueryBody ( ) const

Get the query body as an ASTNode.

std::string XQQuery::getQueryPlan ( ) const

Returns the query plan as XML. This is designed for debug and informative purposes only.

const XMLCh* XQQuery::getQueryText ( ) const
inline

Returns the expression that was parsed to create this XQQuery object.

const DynamicContext* XQQuery::getStaticContext ( ) const
inline
const GlobalVariables& XQQuery::getVariables ( ) const
inline

Returns a vector of all XQGlobalVariable objects from the query.

bool XQQuery::getVersion3 ( ) const
inline
void XQQuery::importModule ( const XMLCh *  szUri,
VectorOfStrings locations,
const LocationInfo location 
)

Performs a module import from the given target namespace and locations.

void XQQuery::importModule ( XQQuery module)
bool XQQuery::isModuleCacheOwned ( ) const
inline
void XQQuery::setFile ( const XMLCh *  file)

Sets the name of the file that this query was parsed from.

void XQQuery::setIsLibraryModule ( bool  bIsModule = true)

Sets whether this query is a module or not.

void XQQuery::setModuleTargetNamespace ( const XMLCh *  uri)

Sets the module target namespace for this query.

void XQQuery::setNext ( XQQuery n)
inline
void XQQuery::setQueryBody ( ASTNode *  query)

Set the query body to an ASTNode.

void XQQuery::setQueryText ( const XMLCh *  v)
void XQQuery::setVersion3 ( bool  v)
inline
void XQQuery::staticResolution ( )

Perform static resolution on the query.

This operation is not thread safe, and should only be performed once.

Static resolution resolves prefixes to namespace URIs, variable names to variables, function names to functions, and performs some basic query optimisation.

Normally this is done as part of parsing the query expression. However, if the XQilla::NO_STATIC_RESOLUTION flag was specified when the query was parsed, this method will have to be called to perform this step manually.

Parameters
contextIf specified, the StaticContext to use to statically resolve this object. By default, the context used to parse the query is used. This should not need to be changed under normal usage.
Exceptions
XQExceptionIf a static resolution time error occurs
void XQQuery::staticTyping ( StaticTyper *  styper = 0)

Perform type calculation and related optimizations.

This operation is safe to call multiple times.

Normally this step is done as part of static resolution.

Parameters
contextIf specified, the StaticContext to use to statically resolve this object. By default, the context used to parse the query is used. This should not need to be changed under normal usage.
Exceptions
XQExceptionIf a static resolution time error occurs
bool XQQuery::staticTypingOnce ( StaticTyper *  styper = 0)

The documentation for this class was generated from the following file: