⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variant_field.htm

📁 The goal of this library is to make ODBC recordsets look just like an STL container. As a user, you
💻 HTM
📖 第 1 页 / 共 2 页
字号:
        <td valign="top"><pre>X a()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Creates an empty <font size="2"
        face="Courier New">variant_field</font>. The type and <a
        href="variant_row.htm"><font size="2" face="Courier New">variant_row</font></a>
        parent pointer is not set so an empty <font size="2"
        face="Courier New">variant_field</font> cannot be used
        until is has been copy or assignment constructed from a <font
        size="2" face="Courier New">variant_row </font>class.</td>
        <td valign="top">The row is empty.</td>
    </tr>
    <tr>
        <td valign="top">Copy constructor </td>
        <td valign="top"><pre>X a(const X &amp;b)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Creates a <font size="2"
        face="Courier New">variant_field</font> to hold an
        arbitrary type with the given <a href="variant_row.htm"><font
        size="2" face="Courier New">variant_row</font></a> parent
        specified in<font size="3"> </font><font size="2"
        face="Courier New">b</font>. The types, and values stored
        in <font size="2" face="Courier New">b</font> are copied
        into <font size="2" face="Courier New">a</font>.</td>
        <td valign="top">The row is initialized to be able to
        hold the types and values given in <font size="2"
        face="Courier New">b</font>. The data held in <font
        size="2" face="Courier New">b</font> is copied to <font
        size="2" face="Courier New">a</font>.</td>
    </tr>
    <tr>
        <td valign="top">Assignment operator</td>
        <td valign="top"><pre>const variant_field &amp; 
operator=(const variant_field &amp;b)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Assigns a <font size="2"
        face="Courier New">variant_field</font> to hold an
        arbitrary type with the given <a href="variant_row.htm"><font
        size="2" face="Courier New">variant_row</font></a><font
        size="2" face="Courier New"> </font>parent specified in <font
        size="2" face="Courier New">b</font>. The types, and
        values stored in <font size="2" face="Courier New">b</font>
        are copied into <font size="2" face="Courier New">a</font>.</td>
        <td valign="top">The row is initialized to be able to
        hold the types and values given in <font size="2"
        face="Courier New">b</font>. The data held in<font
        size="2" face="Courier New"> b</font> is copied to<font
        size="2" face="Courier New"> a</font>.</td>
    </tr>
    <tr>
        <td valign="top">Assign data to a variant_field</td>
        <td valign="top"><pre>template&lt;typename T&gt; const variant_field &amp; 
operator=(const T &amp;other)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Assigns a value to a <font size="2"
        face="Courier New">variant_field</font>. The field's type
        information is updated to reflect the type of the object
        passed in and the value of the object is copied to the
        field's internal data. <strong>IN ADDITION, THE NEW VALUE
        HELD BY THE FIELD IS COPIED BACK TO THE PARENT </strong><a
        href="variant_row.htm"><font size="2" face="Courier New">variant_row</font></a><strong>.</strong>
        So, if the parent <a href="variant_row.htm"><font
        size="2" face="Courier New">variant_row</font></a>
        requires a <font size="2" face="Courier New">string </font>for
        the given field, when a copy operation to the <a
        href="variant_row.htm"><font size="2" face="Courier New">variant_row</font></a>
        is attempted, first the data will be cast to a <font
        size="2" face="Courier New">string</font>, then that <font
        size="2" face="Courier New">string </font>data will be
        copied into the <a href="variant_row.htm"><font size="2"
        face="Courier New">variant_row</font></a> data. This
        allows for transparent and type-safe assignment into the <a
        href="variant_row.htm"><font size="2" face="Courier New">variant_row</font></a>
        object. This copy process is internal to the <a
        href="variant_row.htm"><font size="2" face="Courier New">variant_row</font></a>
        object. For example, if the source <font size="2"
        face="Courier New">variant_field</font> object contains a
        <font size="2" face="Courier New">double </font>but the
        target <a href="variant_row.htm"><font size="2"
        face="Courier New">variant_row</font></a><font size="2"
        face="Courier New"> </font>field requires a <font
        size="2" face="Courier New">string</font> any casts done
        to obtain a <font size="2" face="Courier New">string</font>
        will be internal to <a href="variant_row.htm"><font
        size="2" face="Courier New">variant_row</font></a> and
        will not affect the data or type held by the <font
        size="2" face="Courier New">variant_field</font> object.
        There are some restrictions, see <a href="#1">[1]</a>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Cast operator</td>
        <td valign="top"><pre>template &lt;class T&gt; operator T()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Casts the variant data held in the class
        to a desired target type. Thus, the class might hold a <font
        size="2" face="Courier New">string</font> as its variant
        data, but we want to cast it to a <font size="2"
        face="Courier New">double</font>. Suppose <font size="2"
        face="Courier New">a </font>is a <font size="2"
        face="Courier New">variant_field</font> that holds a <font
        size="2" face="Courier New">string</font> as its internal
        data. The expresssion <font size="2" face="Courier New">(double)
        a </font>will try to convert the <font size="2"
        face="Courier New">string</font> held internally into a
        number to return. There are some restrictions, see <a
        href="#1">[1]</a>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Determine if field holds a NULL value</td>
        <td valign="top"><pre>bool IsNull()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Returns true if the data held by the
        field represents a <font size="2" face="Courier New">NULL</font>
        value.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Get an enumerated value listing the type
        of data held by the field</td>
        <td valign="top"><pre>char type()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Returns an enumeration listing the type
        of the data held by the <font size="2" face="Courier New">variant_field.</font>
        This enumeration is listed in <font size="2"
        face="Courier New">bind_basics.h </font>as follows, but
        is subject to change so check this file for the latest
        version:<p><font size="2" face="Courier New">// short,
        unsigned short, int, unsigned int, long, unsigned long<br>
        // double, float, struct TIMESTAMP_STRUCT, char *, string<br>
        <br>
        enum {C_UNKNOWN=0, C_SHORT='n', C_USHORT='N', C_INT='i',
        C_UINT='I', C_LONG='l', <br>
        C_ULONG='L', C_DOUBLE='d', C_FLOAT='f',<br>
        C_TIMESTAMP='t', C_CHAR_STAR='C'-'A'+1, C_STRING='s'};</font></p>
        </td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Test if the value held by the field
        matches a particular type</td>
        <td valign="top"><pre>template&lt;typename T&gt; bool is_type()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">This method can be used to test if this<font
        size="2" face="Courier New"> variant_field</font><br>
        holds a value of type <font size="2" face="Courier New">T</font>.
        It takes no arguments,<br>
        so it can only be used with explicit template<br>
        instantiation, e.g.:<br>
        <font size="2" face="Courier New">if ( a.is_type&lt;int&gt;()
        )</font></td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Steam operator</td>
        <td valign="top"><pre>ostream &amp;operator&lt;&lt;(ostream &amp;o, const variant_field &amp;vf)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Stream the value held by the <font
        size="2" face="Courier New">variant_field </font>to a
        standard <font size="2" face="Courier New">ostream</font>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
</table>

<h3>Notes</h3>

<p><a name="1">[1] </a>The allowable types that can be assigned
into and cast from <font size="2" face="Courier New">variant_field</font>
is currently a limited set of types covering the common data
types seen in SQL data fields. See <font size="2"
face="Courier New">variant.h</font> and<font size="2"
face="Courier New"> bind_basics.h </font>for the current list of
types supported by this class.</p>

<h3>See also</h3>

<p><a href="variant_row.htm"><font size="2" face="Courier New">variant_row</font></a><font
size="2" face="Courier New">, </font><a
href="DynamicDBView.htm"><font size="2"
face="Courier New">DynamicDBView</font></a><font size="2"
face="Courier New">, </font><a
href="DynamicIndexedDBView.htm"><font size="2"
face="Courier New">DynamicIndexedDBView</font></a> <!--start footer--></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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -