<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qxmlresultitems.cpp --> <head> <title>Qt 4.6: QXmlResultItems Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <a name="//apple_ref/cpp/cl//QXmlResultItems"></a> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QXmlResultItems Class Reference<br /><span class="small-subtitle">[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</span> </h1> <p>The QXmlResultItems class iterates through the results of evaluating an XQuery in <a href="qxmlquery.html">QXmlQuery</a>. <a href="#details">More...</a></p> <pre> #include <QXmlResultItems></pre><p><b>This class is not part of the Qt GUI Framework Edition.</b></p> <p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p> <p>This class was introduced in Qt 4.4.</p> <ul> <li><a href="qxmlresultitems-members.html">List of all members, including inherited members</a></li> </ul> <hr /> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qxmlresultitems.html#QXmlResultItems">QXmlResultItems</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><b><a href="qxmlresultitems.html#dtor.QXmlResultItems">~QXmlResultItems</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QXmlItem </td><td class="memItemRight" valign="bottom"><b><a href="qxmlresultitems.html#current">current</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qxmlresultitems.html#hasError">hasError</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QXmlItem </td><td class="memItemRight" valign="bottom"><b><a href="qxmlresultitems.html#next">next</a></b> ()</td></tr> </table> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QXmlResultItems class iterates through the results of evaluating an XQuery in <a href="qxmlquery.html">QXmlQuery</a>.</p> <p>QXmlResultItems presents the evaluation of an associated query as a sequence of <a href="qxmlitem.html">QXmlItems</a>. The sequence is traversed by repeatedly calling <a href="qxmlresultitems.html#next">next</a>(), which actually produces the sequence by lazy evaluation of the query.</p> <pre> QXmlQuery query; query.setQuery("<e/>, 1, 'two'"); QXmlResultItems result; if (query.isValid()) { query.evaluateTo(&result); QXmlItem item(result.next()); while (!item.isNull()) { <span class="comment">// use item</span> item = result.next(); } if (result.hasError()) <span class="comment">/* Runtime error! */</span>; }</pre> <p>An effect of letting <a href="qxmlresultitems.html#next">next</a>() produce the sequence by lazy evaluation is that a query error can occur on any call to <a href="qxmlresultitems.html#next">next</a>(). If an error occurs, both <a href="qxmlresultitems.html#next">next</a>() and <a href="qxmlresultitems.html#current">current</a>() will return the null <a href="qxmlitem.html">QXmlItem</a>, and <a href="qxmlresultitems.html#hasError">hasError</a>() will return true.</p> <p>QXmlResultItems can be thought of as an "iterator" that traverses the sequence of query results once, in the forward direction. Each call to <a href="qxmlresultitems.html#next">next</a>() advances the iterator to the next <a href="qxmlitem.html">QXmlItem</a> in the sequence and returns it, and <a href="qxmlresultitems.html#current">current</a>() always returns the <a href="qxmlitem.html">QXmlItem</a> that <a href="qxmlresultitems.html#next">next</a>() returned the last time it was called.</p> <p><b>Note:</b> When using the QXmlResultItems overload of <a href="qxmlquery.html#evaluateTo">QXmlQuery::evaluateTo</a>() to execute a query, it is advisable to create a new instance of this class for each new set of results rather than reusing an old instance.</p> <p>See also <a href="qxmlitem.html#isNode">QXmlItem::isNode</a>(), <a href="qxmlitem.html#isAtomicValue">QXmlItem::isAtomicValue</a>(), and <a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a>.</p> <hr /> <h2>Member Function Documentation</h2> <a name="//apple_ref/cpp/instm/QXmlResultItems/QXmlResultItems"></a> <h3 class="fn"><a name="QXmlResultItems"></a>QXmlResultItems::QXmlResultItems ()</h3> <p>Constructs an instance of <a href="qxmlresultitems.html">QXmlResultItems</a>.</p> <a name="//apple_ref/cpp/instm/QXmlResultItems/~QXmlResultItems"></a> <h3 class="fn"><a name="dtor.QXmlResultItems"></a>QXmlResultItems::~QXmlResultItems () <tt> [virtual]</tt></h3> <p>Destroys this instance of <a href="qxmlresultitems.html">QXmlResultItems</a>.</p> <a name="//apple_ref/cpp/instm/QXmlResultItems/current"></a> <h3 class="fn"><a name="current"></a><a href="qxmlitem.html">QXmlItem</a> QXmlResultItems::current () const</h3> <p>Returns the current item. The current item is the last item that was produced and returned by <a href="qxmlresultitems.html#next">next</a>().</p> <p>Returns a null <a href="qxmlitem.html">QXmlItem</a> if there is no associated <a href="qxmlquery.html">QXmlQuery</a>.</p> <a name="//apple_ref/cpp/instm/QXmlResultItems/hasError"></a> <h3 class="fn"><a name="hasError"></a>bool QXmlResultItems::hasError () const</h3> <p>If an error occurred during evaluation of the query, true is returned.</p> <p>Returns false if query evaluation has been done.</p> <a name="//apple_ref/cpp/instm/QXmlResultItems/next"></a> <h3 class="fn"><a name="next"></a><a href="qxmlitem.html">QXmlItem</a> QXmlResultItems::next ()</h3> <p>Returns the next result in the sequence produced by lazy evaluation of the associated query. When the returned <a href="qxmlitem.html">QXmlItem</a> is null, either the evaluation terminated normally without producing another result, or an error occurred. Call <a href="qxmlresultitems.html#hasError">hasError</a>() to determine whether the null item was caused by normal termination or by an error.</p> <p>Returns a null <a href="qxmlitem.html">QXmlItem</a> if there is no associated <a href="qxmlquery.html">QXmlQuery</a>.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>