📄 bca.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>BCA</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>BCA</h1>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><img src="functors.gif" width="194" height="38"></td>
<td align="right"><img src="concept.gif" width="194"
height="39"></td>
</tr>
<tr>
<td valign="top"><b>Category</b>: functors</td>
<td align="right" valign="top"><b>Component type</b>:
concept</td>
</tr>
</table>
<h3>Description</h3>
<p>A <font size="2" face="Courier New">BCA</font> is a function object
(this can be a wrapped function pointer if you use
<a href="cb_ptr_fun.htm"> <font size="2" face="Courier New">cb_ptr_fun()</font></a>)
that is called to create an association between the columns in a SQL view
<a href="#foot1">[1]</a> and the fields in a user defined data object that is used to
represent individual rows from the view.</p>
<h3>Refinement of</h3>
<p>None.</p>
<h3>Associated types</h3>
<p><a href="BoundIO.htm"><font size="2" face="Courier New">BoundIOs</font></a><font
size="2" face="Courier New">.</font></p>
<h3>Example 1:</h3>
<pre><code><span class="codeComment">Functor to bind SQL columns to a data object</span>
class Example
{
public: <span class="codeComment">// tablename.columnname:</span>
int exampleInt; <span class="codeComment">// DB_EXAMPLE.INT_VALUE</span>
string exampleStr; <span class="codeComment">// DB_EXAMPLE.STRING_VALUE</span>
double exampleDouble; <span class="codeComment">// DB_EXAMPLE.DOUBLE_VALUE</span>
long exampleLong; <span class="codeComment">// DB_EXAMPLE.EXAMPLE_LONG</span>
TIMESTAMP_STRUCT exampleDate; <span class="codeComment">// DB_EXAMPLE.EXAMPLE_DATE</span>
};</pre>
<pre>class BCAExampleObj
{
public:
void operator()(BoundIOs &boundIOs, Example &rowbuf)
{
boundIOs["INT_VALUE"] == rowbuf.exampleInt;
boundIOs["STRING_VALUE"] == rowbuf.exampleStr;
boundIOs["DOUBLE_VALUE"] == rowbuf.exampleDouble;
boundIOs["EXAMPLE_LONG"] == rowbuf.exampleLong;
boundIOs["EXAMPLE_DATE"] == rowbuf.exampleDate;
}
};
</code></pre>
<p> </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 <font size="2"
face="Courier New">BCA</font></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>
<td valign="top"><pre>X a()</pre>
</td>
<td valign="top"> </td>
<td valign="top">Construct the function object.</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">Copy constructor </td>
<td valign="top"><pre>X a(constX &b)</pre>
</td>
<td valign="top"> </td>
<td valign="top">Copy construct the <font size="2"
face="Courier New">BCA</font>.</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">Assignment operator</td>
<td valign="top"><pre>X& operator=(const X&b)</pre>
</td>
<td valign="top"> </td>
<td valign="top">Assignment copy</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">Bind columns operator</td>
<td valign="top"><pre>void operator()(BoundIOs &boundIOs, DataObj &rowbuf)</pre>
</td>
<td valign="top"> </td>
<td valign="top">This operator takes a<font size="2"
face="Courier New"> BoundIOs</font> object and a
reference to a <font size="2" face="Courier New">rowbuf</font>
holding a user defined data object of type <font size="2"
face="Courier New">DataObj</font>. The job of the bind
columns operator is to create an association between
fields in a SQL view and fields in a user defined data
object to hold rows from the view. This association is
usually created by invoking the following cantrip:<p><font
size="2" face="Courier New">boundIOs["SQL Field Name"]
== rowbuf.FieldName </font></p>
<p>for each field to be included in the SQL query. For
details on this syntax see <a href="BoundIO.htm"><font
size="2" face="Courier New">BoundIOs</font></a><font
size="2" face="Courier New">. </font>The fields to be
bound must be statically allocated members of the <font
size="2" face="Courier New">DataObj </font>(there are
some exceptions - see <a href="BoundIO.htm"><font
size="2" face="Courier New">BoundIOs</font></a><font
size="2" face="Courier New"> </font>for details). At the
end of the operation, all fields to be bound in the SQL
query must be in the <a href="BoundIO.htm"><font size="2"
face="Courier New">BoundIOs</font></a><font size="2"
face="Courier New"> </font><font size="3">container. When
</font><font size="2" face="Courier New">operator()</font><font
size="2"> </font>is called, the <font size="2"
face="Courier New">BoundIOs </font>container starts out
empty.</p>
</td>
<td valign="top"><a href="BoundIO.htm"><font size="2"
face="Courier New">BoundIOs</font></a><font size="2"
face="Courier New"> </font>contains a complete list of
fields to be bound to the <font size="2"
face="Courier New">DataObj</font>.</td>
</tr>
</table>
<p> </p>
<h3>Notes</h3>
<p><a name="foot1">[1]</a> We use the term 'view' here to
indicate two common cases. The first case is when we are
referring to fields from a single table. In this case, we can
usually either select, insert, update or delete records. The
second case is when we are selecting multiple fields from
multiple tables as joined together with a <font size="2"
face="Courier New">WHERE</font> clause. In the second case, we
can usually only select records.</p>
<h3>See also</h3>
<p><a href="BoundIO.htm"><font size="2" face="Courier New">BoundIOs</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="IndexedDBView.htm"><font size="2"
face="Courier New">IndexedDBView</font><font size="2"><!--start footer--></font></a></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 + -