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

📄 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 页
字号:
<html>


<head>
<style>
CODE {COLOR: #990000;}
.code{COLOR: #990000}
.codeComment{COLOR: #008000}
.codeHighlight{BACKGROUND-COLOR: #FFFF00}
.codeFileName{FONT-WEIGHT: bold;}
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Gradman">
<meta name="KeyWords"
content="DTL, Oracle, ODBC, database API, C++, Template Library">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<!--
  -- Copyright 2000
  -- Michael Gradman & Corwin Joy
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Corwin Joy & Michael Gradman make no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  --
  -- Copyright (c) 1996-1999
  -- Silicon Graphics Computer Systems, Inc.
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Silicon Graphics makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -- Copyright (c) 1994
  -- Hewlett-Packard Company
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Hewlett-Packard Company makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -->
<!-- Generated by htmldoc -->
<title>variant_field</title>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#0000EE"
vlink="#551A8B" alink="#FF0000">

<p><font size="6" face="Bookman Old Style"><em><strong><u>dtl</u></strong></em></font></p>

<p><img src="stat.gif" width="6" height="6"> <!--end header--> <br>
</p>
<h1>variant_field</h1>



















<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td><img src="utilities.gif" width="194" height="38"></td>
        <td align="right"><img src="type.gif" width="194"
        height="39"></td>
    </tr>
    <tr>
        <td valign="top"><b>Category</b>: utilities</td>
        <td align="right" valign="top"><b>Component type</b>:
        type</td>
    </tr>
</table>
<h3>Description</h3>

<p>The <font size="2" face="Courier New">variant_field</font>
class provides a mechanism to access data fields within a <font
size="2" face="Courier New">variant_row</font>. <font size="2"
face="Courier New">variant_field</font> is designed to hold
values of arbitrary types. In addition<font size="2"
face="Courier New"> variant_field </font>provides the ability for
users to cast values between types and assign values back to the <font
size="2" face="Courier New">variant_row</font> that created a
given variant object. This class is used primarily by dynamic
queries where the number and the types of the fields returned by
a query are unknown.</p>

<h3>Definition</h3>

<p>Defined in the <font size="2" face="Courier New">variant_row.h
</font><font size="3">header file.</font></p>

<h3>Refinement of</h3>

<p>None.</p>

<h3>Associated types</h3>

<p><a href="variant_row.htm"><font size="2" face="Courier New">variant_row</font></a><font
size="2" face="Courier New">, TypeTranslation</font>.</p>

<h3>Example:</h3>
<pre><code><span class="codeComment">// Manipulating fields in a variant_row</span>

void variant_row_example(void) {

	TIMESTAMP_STRUCT test_date = {1999, 9, 29, 0, 0, 0, 0};

	vector&lt;TypeTranslation&gt; types;
	vector&lt;string&gt; names;
	int i;
	string s;
	TypeTranslation vt0=TypeTranslation(typeid(int).name(), C_INT, SQL_INTEGER, SQL_C_SLONG,
				TypeTranslation::TYPE_PRIMITIVE, sizeof(int)), 
			vt1=TypeTranslation(typeid(string).name(), C_STRING, SQL_VARCHAR, SQL_C_CHAR,
				TypeTranslation::TYPE_COMPLEX, sizeof(string));

	types.push_back(vt0);
	names.push_back(&quot;int&quot;);

	types.push_back(vt1);
	names.push_back(&quot;string&quot;);

	variant_row r(types, names);
	
	
	r[&quot;int&quot;] = (int)r[&quot;int&quot;] + 5;
	i = (int)r[&quot;int&quot;];
	
	s = (string) r[&quot;int&quot;];

	r[&quot;int&quot;] = test_date;
	s = (string) r[&quot;int&quot;];

	<span class="codeComment">// Print out the column names</span>
	vector&lt;string&gt; colNames = r.GetNames();
	for (vector&lt;string&gt;::iterator name_it = colNames.begin(); name_it != colNames.end(); name_it++)
	{
		cout &lt;&lt; (*name_it) &lt;&lt; &quot; &quot;;
	}
	cout &lt;&lt; endl;

	<span class="codeComment">// Print out all column values</span>
	for (i = 0; i &lt; r.size(); i++)
		cout &lt;&lt; r[i] &lt;&lt; &quot; &quot;;
	cout &lt;&lt; endl;


};
</code></pre>
<h3>Public base classes</h3>

<p>None.</p>

<h3>Notation</h3>

<table border="0">
    <tr>
        <td valign="top"><tt>X</tt> </td>
        <td valign="top">A type that is a model of variant_field </td>
    </tr>
    <tr>
        <td valign="top"><tt>a</tt> </td>
        <td valign="top">Object of type <tt>X</tt> </td>
    </tr>
</table>

<h3>Expression semantics</h3>

<table border="1">
    <tr>
        <th>Name </th>
        <th>Expression </th>
        <th>Precondition </th>
        <th>Semantics </th>
        <th>Postcondition </th>
    </tr>
    <tr>
        <td valign="top">Default constructor </td>

⌨️ 快捷键说明

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