WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
Classes | Signals | Public Member Functions | Static Public Member Functions | Protected Attributes | Properties | List of all members
Zbl::ZxQuery Class Reference

This class provides access to the QXMLQuery class from Javascript. More...

#include <ZxQuery.h>

Inheritance diagram for Zbl::ZxQuery:
Inheritance graph
[legend]
Collaboration diagram for Zbl::ZxQuery:
Collaboration graph
[legend]

Classes

class  ResourceUrlFile
 A class for opening XQuery resource files. More...
 

Signals

void focusUrlChanged (bool focusOK)
 
void queryUrlChanged (bool queryOK)
 

Public Member Functions

 ZxQuery (QObject *parent=0)
 
 ZxQuery (const ZxQuery &source, QObject *parent=0)
 
 ZxQuery (const QXmlNamePool &np, QObject *parent=0)
 
Q_INVOKABLE QObject * evaluateToItems ()
 Evaluates the current XQuery to a ZxResultItems object and returns that object. More...
 
Q_INVOKABLE QStringList evaluateToStringList ()
 Evaluates the current XQuery to a QStringList object and returns that object. More...
 
Q_INVOKABLE QString evaluateToXml ()
 Evaluates the current XQuery to an XML string. More...
 
Q_INVOKABLE QObject * getCopy ()
 Returns a ZxQuery object that is a copy of this object. More...
 
Q_INVOKABLE QObject * getNamePoolCopy ()
 Returns a ZxQuery object that uses the same QXmlNamePool as this object. More...
 
Q_INVOKABLE void bindVariable (const QString &localName, QObject *zXmlItem)
 Binds an XQuery variable with a value. More...
 
Q_INVOKABLE void loadQueryText (const QString &fileUri)
 Appends the contents of the specified file to the current contents of the query text buffer. More...
 
Q_INVOKABLE void concatQueryText (const QString &text)
 Appends the specified text to the current contents of the query text buffer. More...
 
Q_INVOKABLE void commitQueryText ()
 Sends the current query text buffer to the XQuery processor. More...
 
Q_INVOKABLE void bindSymbol (const QString &symbolName, const QString &symbolText)
 Binds the specified symbol name to the specified text. More...
 
Q_INVOKABLE QString getSymbolText (const QString &symbolName)
 obtain the text that will be substituted for the specified symbol when loading text into the query text buffer. More...
 
Q_INVOKABLE void removeSymbol (const QString &symbolName)
 Removes the specified symbol from the symbol substitution map. More...
 
void setQueryUrl (const QString &url)
 sets the XQuery query url and calls setQuery on the encapsulated QXmlQuery object. More...
 
const QString getQueryUrl ()
 returns the query URL of the XQuery object More...
 
void setFocusUrl (const QString &url)
 sets the XQuery focus url and calls setQuery on the encapsulated QXmlQuery object. More...
 
const QString getFocusUrl ()
 returns the focus item the XQuery object More...
 
void setFocusItem (QObject *item)
 sets the XQuery focus item More...
 
QObject * getFocusItem ()
 returns the focus URL of the XQuery object More...
 
void setFocusText (const QString &text)
 sets the XQuery focus url and calls setQuery on the encapsulated QXmlQuery object. More...
 
const QString getFocusText ()
 returns the focus text of the XQuery object More...
 
void setQueryText (const QString &text)
 Copies the specified text to the query text buffer and calls setQuery on the encapsulated QXmlQuery object. DO NOT call commitQuery(), query is committed immediately. More...
 
const QString getQueryText ()
 returns the text of the query More...
 
void setSymbolSubstitution (bool enabled)
 enables symbol substitution mechanism for query text buffer. More...
 
const bool getSymbolSubstitution ()
 returns the symbol substituion mode More...
 
QXmlNamePool getNamePool () const
 Obtains the XML name pool for the encapsulated QXmlQuery object. More...
 

Static Public Member Functions

static void registerType ()
 Registers ZxQuery as a QML type. More...
 

Protected Attributes

QXmlQuery m_query
 The encapsulated QXmlQuery object. More...
 
QUrl m_queryUrl
 The URL of the source query file;. More...
 
QString m_queryText
 The source text of the query. More...
 
QString m_focusText
 The focus URL. More...
 
QXmlItem m_xmlItem
 The focus item. More...
 
ResourceUrlFile m_focusFile
 Pointer to a QFile object that will be used as the XQuery focus document. More...
 
ResourceUrlFile m_queryFile
 Pointer to a QFile object that will be used as the XQuery query text. More...
 
bool m_enableSymbols
 Enables query text buffer symbol substitution when true, disables it when false. More...
 
QMap< QString, QString > m_symbols
 Query text symbol substitution map. More...
 

Properties

QString queryUrl
 set/get the query url More...
 
QObject focusItem
 set/get the focus url More...
 
QString focusUrl
 set/get the focus url TBD: READING DOESN'T WORK More...
 
QString focusText
 set/get the focus text More...
 
QString queryText
 set/get the query text More...
 
bool substituteSymbols
 Query text buffer symbol substitution is enabled when true, disabled when false. More...
 

Detailed Description

This class provides access to the QXMLQuery class from Javascript.

Definition at line 48 of file ZxQuery.h.

Constructor & Destructor Documentation

◆ ZxQuery() [1/3]

Zbl::ZxQuery::ZxQuery ( QObject *  parent = 0)
explicit

Definition at line 44 of file ZxQuery.cpp.

Referenced by getCopy(), and getNamePoolCopy().

◆ ZxQuery() [2/3]

Zbl::ZxQuery::ZxQuery ( const ZxQuery source,
QObject *  parent = 0 
)
explicit

Definition at line 49 of file ZxQuery.cpp.

◆ ZxQuery() [3/3]

Zbl::ZxQuery::ZxQuery ( const QXmlNamePool &  np,
QObject *  parent = 0 
)
explicit

Definition at line 62 of file ZxQuery.cpp.

Member Function Documentation

◆ bindSymbol()

void Zbl::ZxQuery::bindSymbol ( const QString &  symbolName,
const QString &  symbolText 
)

Binds the specified symbol name to the specified text.

The query text buffer supports an optional symbol substitution mechanism that allows the programmer to embed symbols in the query text that can later be substituted with dynamically generated text. Symbols are substituted at the time text is loaded into the text query buffer but only if symbol substitution mode is enabled.

To use this mechanism call this method to bind symbol names to the substituted text, ensure symbol substitution mode is enabled, and then load query text containing symbols. When the query text had been finalized by loading or concatenation call the commitQueryText() method to commit the query to the XQuery processor.

Parameters
symbolNamename of the symbol that will be replaced with the specified text
symbolTexttext that will be substituted for the named symbol when the query text buffer is loaded
See also
substituteSymbols
getSymbolText()
removeSymbol()

Definition at line 507 of file ZxQuery.cpp.

◆ bindVariable()

void Zbl::ZxQuery::bindVariable ( const QString &  localName,
QObject *  zXmlItem 
)

Binds an XQuery variable with a value.

Parameters
localNameName of the variable
zXmlItemA ZxItem object containing the value to bind to localName

Definition at line 419 of file ZxQuery.cpp.

◆ commitQueryText()

void Zbl::ZxQuery::commitQueryText ( )

Sends the current query text buffer to the XQuery processor.

When using loadQueryText() or concatQueryText() this method must be called to send the query text buffer to the XQuery processor.

Definition at line 494 of file ZxQuery.cpp.

◆ concatQueryText()

void Zbl::ZxQuery::concatQueryText ( const QString &  text)

Appends the specified text to the current contents of the query text buffer.

The query buffer IS NOT sent to the XQuery processor automatically. You must explicitly call commitQuery() to send query buffer to XQuery processor when using this method.

Parameters
textThe text to append to query buffer.

Definition at line 484 of file ZxQuery.cpp.

◆ evaluateToItems()

QObject * Zbl::ZxQuery::evaluateToItems ( )

Evaluates the current XQuery to a ZxResultItems object and returns that object.

Definition at line 259 of file ZxQuery.cpp.

◆ evaluateToStringList()

QStringList Zbl::ZxQuery::evaluateToStringList ( )

Evaluates the current XQuery to a QStringList object and returns that object.

Definition at line 307 of file ZxQuery.cpp.

Referenced by Zbl::ZSettings::realizeSettings().

◆ evaluateToXml()

QString Zbl::ZxQuery::evaluateToXml ( )

Evaluates the current XQuery to an XML string.

Definition at line 326 of file ZxQuery.cpp.

◆ focusUrlChanged

void Zbl::ZxQuery::focusUrlChanged ( bool  focusOK)
signal

Referenced by setFocusUrl().

◆ getCopy()

QObject * Zbl::ZxQuery::getCopy ( )

Returns a ZxQuery object that is a copy of this object.

Definition at line 348 of file ZxQuery.cpp.

◆ getFocusItem()

QObject * Zbl::ZxQuery::getFocusItem ( )

returns the focus URL of the XQuery object

Returns

Definition at line 208 of file ZxQuery.cpp.

◆ getFocusText()

const QString Zbl::ZxQuery::getFocusText ( )

returns the focus text of the XQuery object

Returns

Definition at line 180 of file ZxQuery.cpp.

◆ getFocusUrl()

const QString Zbl::ZxQuery::getFocusUrl ( )

returns the focus item the XQuery object

Returns

Definition at line 162 of file ZxQuery.cpp.

◆ getNamePool()

QXmlNamePool Zbl::ZxQuery::getNamePool ( ) const

Obtains the XML name pool for the encapsulated QXmlQuery object.

Returns

Definition at line 343 of file ZxQuery.cpp.

Referenced by Zbl::ZxItem::elementById(), and Zbl::ZxItem::getLocalName().

◆ getNamePoolCopy()

QObject * Zbl::ZxQuery::getNamePoolCopy ( )

Returns a ZxQuery object that uses the same QXmlNamePool as this object.

Definition at line 353 of file ZxQuery.cpp.

◆ getQueryText()

const QString Zbl::ZxQuery::getQueryText ( )

returns the text of the query

Returns

Definition at line 240 of file ZxQuery.cpp.

◆ getQueryUrl()

const QString Zbl::ZxQuery::getQueryUrl ( )

returns the query URL of the XQuery object

Returns

Definition at line 116 of file ZxQuery.cpp.

◆ getSymbolSubstitution()

const bool Zbl::ZxQuery::getSymbolSubstitution ( )

returns the symbol substituion mode

Returns
true if symbol substitution is enabled, false if disabled
See also
setSymbolSubstitution

Definition at line 442 of file ZxQuery.cpp.

◆ getSymbolText()

QString Zbl::ZxQuery::getSymbolText ( const QString &  symbolName)

obtain the text that will be substituted for the specified symbol when loading text into the query text buffer.

Definition at line 512 of file ZxQuery.cpp.

◆ loadQueryText()

void Zbl::ZxQuery::loadQueryText ( const QString &  fileUri)

Appends the contents of the specified file to the current contents of the query text buffer.

The query buffer IS NOT sent to the XQuery processor automatically. You must explicitly call commitQuery() to send query buffer to XQuery processor when using this method.

Parameters
fileUriThe file or resource url to load.

Definition at line 447 of file ZxQuery.cpp.

◆ queryUrlChanged

void Zbl::ZxQuery::queryUrlChanged ( bool  queryOK)
signal

Referenced by setQueryUrl().

◆ registerType()

void Zbl::ZxQuery::registerType ( )
static

Registers ZxQuery as a QML type.

Definition at line 252 of file ZxQuery.cpp.

Referenced by Zbl::Zblcore::registerTypes().

◆ removeSymbol()

void Zbl::ZxQuery::removeSymbol ( const QString &  symbolName)

Removes the specified symbol from the symbol substitution map.

The specified symbol will no longer be substituted when the query text buffer is loaded.

Definition at line 517 of file ZxQuery.cpp.

◆ setFocusItem()

void Zbl::ZxQuery::setFocusItem ( QObject *  item)

sets the XQuery focus item

Parameters
itema ZxItem object that will become the focus of the query

Definition at line 185 of file ZxQuery.cpp.

◆ setFocusText()

void Zbl::ZxQuery::setFocusText ( const QString &  text)

sets the XQuery focus url and calls setQuery on the encapsulated QXmlQuery object.

Parameters
theURL of the query file

Definition at line 167 of file ZxQuery.cpp.

Referenced by Zbl::ZSettings::realizeSettings().

◆ setFocusUrl()

void Zbl::ZxQuery::setFocusUrl ( const QString &  url)

sets the XQuery focus url and calls setQuery on the encapsulated QXmlQuery object.

Parameters
theURL of the query file

Definition at line 121 of file ZxQuery.cpp.

Referenced by Zbl::ZSettings::realizeSettings().

◆ setQueryText()

void Zbl::ZxQuery::setQueryText ( const QString &  text)

Copies the specified text to the query text buffer and calls setQuery on the encapsulated QXmlQuery object. DO NOT call commitQuery(), query is committed immediately.

Pass an empty string to clear the text buffer. QXmlQuery object state will not be affected.

Parameters
thetext of the query

Definition at line 219 of file ZxQuery.cpp.

Referenced by Zbl::ZSettings::realizeSettings().

◆ setQueryUrl()

void Zbl::ZxQuery::setQueryUrl ( const QString &  url)

sets the XQuery query url and calls setQuery on the encapsulated QXmlQuery object.

This method bypasses the query text buffer and as a side effect clears it.

Parameters
theURL of the query file

Definition at line 68 of file ZxQuery.cpp.

◆ setSymbolSubstitution()

void Zbl::ZxQuery::setSymbolSubstitution ( bool  enabled)

enables symbol substitution mechanism for query text buffer.

Parameters
enabledtrue to turn on symbol substitution, false to disable it;
See also
getSymbolSubstitution

Definition at line 437 of file ZxQuery.cpp.

Member Data Documentation

◆ m_enableSymbols

bool Zbl::ZxQuery::m_enableSymbols
protected

Enables query text buffer symbol substitution when true, disables it when false.

Definition at line 492 of file ZxQuery.h.

Referenced by getSymbolSubstitution(), and setSymbolSubstitution().

◆ m_focusFile

ResourceUrlFile Zbl::ZxQuery::m_focusFile
protected

Pointer to a QFile object that will be used as the XQuery focus document.

This is to work around the limitation that QXmlQuery can't open a Qt binary resource url ie: qrc:/some/resource/file.xml

Definition at line 476 of file ZxQuery.h.

Referenced by getFocusUrl(), setFocusText(), setFocusUrl(), and ZxQuery().

◆ m_focusText

QString Zbl::ZxQuery::m_focusText
protected

The focus URL.

The focus text;

Definition at line 458 of file ZxQuery.h.

Referenced by getFocusText(), and setFocusText().

◆ m_query

QXmlQuery Zbl::ZxQuery::m_query
protected

◆ m_queryFile

ResourceUrlFile Zbl::ZxQuery::m_queryFile
protected

Pointer to a QFile object that will be used as the XQuery query text.

This is to work around the limitation that QXmlQuery can't open a Qt binary resource url ie: qrc:/some/resource/file.xml

Definition at line 487 of file ZxQuery.h.

Referenced by setQueryUrl().

◆ m_queryText

QString Zbl::ZxQuery::m_queryText
protected

The source text of the query.

Definition at line 446 of file ZxQuery.h.

Referenced by commitQueryText(), concatQueryText(), getQueryText(), loadQueryText(), setQueryText(), and setQueryUrl().

◆ m_queryUrl

QUrl Zbl::ZxQuery::m_queryUrl
protected

The URL of the source query file;.

Definition at line 440 of file ZxQuery.h.

Referenced by evaluateToItems(), evaluateToStringList(), evaluateToXml(), getQueryUrl(), setQueryText(), and ZxQuery().

◆ m_symbols

QMap<QString, QString> Zbl::ZxQuery::m_symbols
protected

Query text symbol substitution map.

Definition at line 497 of file ZxQuery.h.

Referenced by bindSymbol(), getSymbolText(), and removeSymbol().

◆ m_xmlItem

QXmlItem Zbl::ZxQuery::m_xmlItem
protected

The focus item.

Definition at line 465 of file ZxQuery.h.

Referenced by getFocusItem().

Property Documentation

◆ focusItem

QObject Zbl::ZxQuery::focusItem
readwrite

set/get the focus url

Definition at line 68 of file ZxQuery.h.

◆ focusText

QString Zbl::ZxQuery::focusText
readwrite

set/get the focus text

Definition at line 80 of file ZxQuery.h.

◆ focusUrl

QString Zbl::ZxQuery::focusUrl
readwrite

set/get the focus url TBD: READING DOESN'T WORK

Definition at line 74 of file ZxQuery.h.

◆ queryText

QString Zbl::ZxQuery::queryText
readwrite

set/get the query text

Definition at line 86 of file ZxQuery.h.

◆ queryUrl

QString Zbl::ZxQuery::queryUrl
readwrite

set/get the query url

Definition at line 62 of file ZxQuery.h.

◆ substituteSymbols

bool Zbl::ZxQuery::substituteSymbols
readwrite

Query text buffer symbol substitution is enabled when true, disabled when false.

Definition at line 92 of file ZxQuery.h.


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