📄 variant_field.htm
字号:
<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<TypeTranslation> types;
vector<string> 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("int");
types.push_back(vt1);
names.push_back("string");
variant_row r(types, names);
r["int"] = (int)r["int"] + 5;
i = (int)r["int"];
s = (string) r["int"];
r["int"] = test_date;
s = (string) r["int"];
<span class="codeComment">// Print out the column names</span>
vector<string> colNames = r.GetNames();
for (vector<string>::iterator name_it = colNames.begin(); name_it != colNames.end(); name_it++)
{
cout << (*name_it) << " ";
}
cout << endl;
<span class="codeComment">// Print out all column values</span>
for (i = 0; i < r.size(); i++)
cout << r[i] << " ";
cout << 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 + -