db_iterator.htm

来自「The goal of this library is to make ODBC」· HTM 代码 · 共 623 行 · 第 1/2 页

HTM
623
字号
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">string
        GetQuery() const</font></td>
        <td valign="top"><font size="2" face="Courier New">DB_iterator</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">long
        GetCount() const</font></td>
        <td valign="top"><font size="2" face="Courier New">DB_iterator</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">long
        GetLastCount() const</font></td>
        <td valign="top"><font size="2" face="Courier New">DB_iterator</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        set_io_handler(IOHandler&lt;DataObj, ParamObj&gt;)</font></td>
        <td valign="top"><font size="2" face="Courier New">DB_iterator</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">template&lt;class
        UserHandler&gt; const UserHandler &amp; get_io_handler(UserHandler
        *dummy) const</font></td>
        <td valign="top"><font size="2" face="Courier New">DB_iterator</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">IOHandler&lt;DataObj,
        ParamObj&gt; &amp;get_io_handler() const</font></td>
        <td valign="top"><font size="2" face="Courier New">DB_iterator</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">dtl_iostate
        rdstate() const</font></td>
        <td valign="top"><font size="2" face="Courier New">dtl_ios_base</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        setstate(dtl_iostate state)</font></td>
        <td valign="top"><font size="2" face="Courier New">dtl_ios_base</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        clear(dtl_iostate state = goodbit)</font></td>
        <td valign="top"><font size="2" face="Courier New">dtl_ios_base</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">bool
        good() const</font></td>
        <td valign="top"><font size="2" face="Courier New">dtl_ios_base</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">bool
        bad() const</font></td>
        <td valign="top"><font size="2" face="Courier New">dtl_ios_base</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">bool
        fail() const</font></td>
        <td valign="top"><font size="2" face="Courier New">dtl_ios_base</font></td>
        <td valign="top">See below.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        swap(DB_iterator&lt;DataObj, ParamObj&gt; &amp;other)</font></td>
        <td valign="top"><font size="2" face="Courier New">DB_iterator</font></td>
        <td valign="top">See below.</td>
    </tr>
</table>

<h3>New members</h3>

<p>These members are not defined in the <a
href="http://www.sgi.com/tech/stl/trivial.html">Trivial Iterator</a>
requirements, but are specific to <tt>DB_iterator</tt>. </p>

<table border="1">
    <tr>
        <th>Function </th>
        <th>Description </th>
    </tr>
    <tr>
        <td valign="top"><tt>DB_iterator(DBView&lt;DataObj,
        ParamObj&gt; &amp;view)</tt> </td>
        <td valign="top">Creates a <font size="2"
        face="Courier New">DB_iterator </font><font size="3">which
        refers to</font><font size="2" face="Courier New"> view</font><font
        size="1" face="Courier New">.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">ParamObj
        &amp;Params()</font> </td>
        <td valign="top">Returns a reference to the <font
        size="2" face="Courier New">ParamObj </font><font
        size="3">which is bound to the postfix parameters used in
        the query to the database based on the </font><font
        size="2" face="Courier New">BPA</font><font size="3">.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        Params(const ParamObj &amp;params)</font></td>
        <td valign="top">Sets the <font size="2"
        face="Courier New">ParamObj</font><font size="3">, which
        is bound to the postfix parameters used in the query to
        the database based on the </font><font size="2"
        face="Courier New">BPA</font><font size="3">, to value </font><font
        size="2" face="Courier New">params.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">const
        DBView&lt;DataObj, ParamObj&gt; &amp;GetView()</font> </td>
        <td valign="top">Returns a reference to the <font
        size="2" face="Courier New">DBView </font><font size="3">referred
        to by this </font><font size="2" face="Courier New">DB_iterator.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">string
        GetQuery() const</font></td>
        <td valign="top">Returns the SQL query string associated
        with this <font size="2" face="Courier New">DB_iterator.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">long
        GetCount() const</font></td>
        <td valign="top">Returns the number of <font size="2"
        face="Courier New">DataObj's </font><font size="3">processed
        from the database since this </font><font size="2"
        face="Courier New">select_iterator</font><font size="3">
        or the one it was copied or assigned from was first
        opened. Think of this result as the <strong>total</strong>
        number of </font><font size="2" face="Courier New">DataObj's
        </font><font size="3">processed in this conceptual
        iterator's lifetime.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">long
        GetLastCount() const</font></td>
        <td valign="top">Returns the number of <font size="2"
        face="Courier New">DataObj's </font><font size="3">processed
        from the database in last operation. Same as </font><font
        size="2" face="Courier New">GetCount()</font><font
        size="3"> for </font><font size="2" face="Courier New">select_iterator's
        </font><font size="3">and </font><font size="2"
        face="Courier New">insert_iterator's. </font><font
        size="3">For </font><font size="2" face="Courier New">delete_iterator's
        and update_iterator's, </font><font size="3">number of </font><font
        size="2" face="Courier New">DataObj's </font><font
        size="3">processed on last invocation of either version
        of</font><font size="2" face="Courier New"> operator++().</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        set_io_handler(IOHandler&lt;DataObj, ParamObj&gt;)</font></td>
        <td valign="top">Sets the <font size="2"
        face="Courier New">IOHandler</font> for this iterator.
        The <font size="2" face="Courier New">IOHandler </font>will
        try to handle exceptions thrown by the iterator and tell
        the code which caught the exception whether to suppress
        the error or still throw.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">template&lt;class
        UserHandler&gt; const UserHandler &amp; get_io_handler(UserHandler
        *dummy)</font></td>
        <td valign="top">Returns the current<font size="2"
        face="Courier New"> IOHandler</font> for this object cast
        to the actual type of the handler based on the dummy
        pointer passed in. If the dynamic cast of the <font
        size="2" face="Courier New">IOHandler</font> object
        fails, an exception will be thrown.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">IOHandler&lt;DataObj,
        ParamObj&gt; &amp;get_io_handler() const</font></td>
        <td valign="top">Returns the current<font size="2"
        face="Courier New"> IOHandler</font> for this object as a
        raw <font size="2" face="Courier New">IOHandler</font>
        object. You must cast to the actual type of the handler
        to be able to access any of your handler's public members.</td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">dtl_iostate
        rdstate() const</font></td>
        <td valign="top">Returns the state of the iterator as a
        bit field (as in the facilities for iostreams): <font
        size="2" face="Courier New">goodbit == 0, failbit = 0x01,
        badbit = 0x02, bad_and_fail_bit = 0x03.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        setstate(dtl_iostate state)</font></td>
        <td valign="top">Sets the state of the iterator to <font
        size="2" face="Courier New">rdstate() | state </font><font
        size="3">using a bit field.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        clear(dtl_iostate state = goodbit)</font></td>
        <td valign="top">Sets the state of the iterator to <font
        size="2" face="Courier New">state </font><font size="3">using
        a bit field.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">bool
        good() const</font></td>
        <td valign="top"><font size="3">Is the iterator in an OK
        state? Equivalent to </font><font size="2"
        face="Courier New">rdstate() == goodbit.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">bool
        bad() const</font></td>
        <td valign="top"><font size="3">Is the iterator in a
        completely irreconcilable (such as a lost database
        connection or bad underlying SQL query)? Equivalent to </font><font
        size="2" face="Courier New">(rdstate() &amp; badbit) != 0.</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">bool
        fail() const</font></td>
        <td valign="top"><font size="3">Is the iterator in a
        temporary failure state? This means the iterator is still
        usable, but the last operation on it failed (such as a
        validation on an element just read or written).
        Equivalent to </font><font size="2" face="Courier New">((rdstate()
        &amp; failbit) != 0) || bad().</font></td>
    </tr>
    <tr>
        <td valign="top"><font size="2" face="Courier New">void
        swap(DB_iterator&lt;DataObj, ParamObj&gt; &amp;other)</font></td>
        <td valign="top">Swaps <font size="2" face="Courier New">*this
        </font><font size="3">with </font><font size="2"
        face="Courier New">other.</font></td>
    </tr>
</table>

<h3>Notes</h3>

<p><a name="1"></a>[1] This is the operation that actually
processes the <font size="2" face="Courier New">DataObj </font><font
size="3">with the database via the </font><font size="2"
face="Courier New">DBView</font><font size="3">. Each </font><font
size="2" face="Courier New">DB_iterator</font><font size="1"
face="Courier New"> </font><font size="3">internally owns a </font><font
size="2" face="Courier New">DBStmt</font><font size="3"> object
which is allocated and prepared when the underlying ODBC
statement handle is first needed and not before. The handle is
not opened until absolutely needed in order to make copying and
assigning these iterators an inexpensive operation. The </font><font
size="2" face="Courier New">DBStmt </font><font size="3">is
executed on each call to </font><font size="2" face="Courier New">operator++()</font><font
size="3">, whether the prefix or postfix version. The iterator
implicitly commits all updates upon destruction unless an
exception is thrown.</font></p>

<p><a name="2"></a>[2] This is not an operation actually declared
in <font
size="2" face="Courier New"> DB_iterator</font><font size="3" face="Times New Roman">due
to the fact that </font><font
size="2" face="Courier New"> operator*() </font><font size="3"
face="Times New Roman">returns a reference to the iterator itself for </font><font
size="2" face="Courier New">insert_iterator, update_iterator,</font><font
size="3" face="Times New Roman"> </font><font size="3"
face="Times New Roman">and</font><font size="3"
face="Times New Roman"> </font><font size="2"
face="Courier New">delete_iterator, </font><font
size="3" face="Times New Roman">but it returns a const reference to the value for</font><font
size="2" face="Courier New"> select_iterator's.</font><font
size="3" face="Times New Roman"> This operator is listed here
for completeness.</font></p>

<p>&nbsp;</p>

<h3>See also</h3>

<p><a href="BCA.htm"><font size="2" face="Courier New">BCA</font></a><font
size="2" face="Courier New">, </font><a href="BPA.htm"><font
size="2" face="Courier New">BPA</font></a><font size="2"
face="Courier New">, </font><a href="DBView.htm"><font size="2"
face="Courier New">DBView</font></a><font size="2"
face="Courier New">, </font><a
href="http://www.sgi.com/tech/stl/OutputIterator.html"><font
size="3">Output Iterator</font></a><font size="3">, </font><a
href="http://www.sgi.com/tech/stl/InputIterator.html"><font
size="3">Input Iterator</font></a><font size="3">, </font><a
href="http://www.sgi.com/tech/stl/trivial.html"><font size="3">Trivial
Iterator</font></a><br>
<br>
</p>

<p>
<hr>

<p><a href="index.htm"><img src="dtl_home.gif" alt="[DTL Home]"
width="54" height="54"></a> <br>
</p>

<p>Copyright 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?