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

📄 otl3_value.htm

📁 ISO_C++:C++_OTL开发文档
💻 HTM
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Sergei Kuchin">
   <meta name="GENERATOR" content="Mozilla/4.75 [en] (Win98; U) [Netscape]">
   <meta name="KeyWords" content="OTL, Oracle, ODBC, DB2, CLI, database API, C++, Template Library">
   <title>OTL 4.0, Template otl_value&lt;T></title>
</head>
<body>

<center>
<h1>
OTL 4.0, Template otl_value&lt;T></h1></center>

<h1>
<a NAME="otl_value"></a>Template otl_value&lt;T></h1>
This is an OTL template class which allows the user to create a derivative
data container based upon the following scalar data types: int, unsigned,
long, short, float, double, <a href="otl3_stream_class.htm#otl_datetime">otl_datetime</a>
(OTL date&amp;time container), std::string (STL string class).
<p>The derivative container has built-in NULL indicator functionality,
that is, the containter has a NULL indicator field in it and can carry
over the NULL value from one operation to another.
<p>For example, a value gets read from a SELECT statement into a otl_value&lt;int>
container, and, it is a NULL. Then, the same value gets written into an
INSERT statement. The otl_value&lt;int> container retains the NULL in its
NULL indicator field, and the NULL gets carried over from the SELECT into
the INSERT.
<p>The otl_value&lt;T> class can be activated with #define <a href="otl3_compile.htm#OTL_STL">OTL_STL</a>,
or #define <a href="otl3_compile.htm#OTL_VALUE_TEMPLATE_ON">OTL_VALUE_TEMPLATE_ON</a>.
<br>&nbsp;
<br>&nbsp;
<pre><font size=+2>template&lt;class TData>&nbsp;
class otl_value{
public:</font></pre>

<ul>
<li>
Data members of the class. <b>v </b>is a container for a scalar value of
the TData type. <b>ind</b> is a NULL indicator. These fields can be used
directly or indirectly, via copy constructors assignment operators (see
below)</li>
</ul>

<pre>&nbsp;&nbsp;&nbsp;&nbsp; TData v;
&nbsp;&nbsp;&nbsp;&nbsp; bool ind;</pre>

<ul>
<li>
Constructors, operators, and functions</li>
</ul>

<pre>&nbsp;&nbsp;&nbsp;&nbsp; otl_value(); // default constructor

&nbsp;&nbsp;&nbsp;&nbsp; otl_value(const otl_value&lt;TData>&amp; var); // copy constructor
&nbsp;&nbsp;&nbsp;&nbsp; otl_value(const TData&amp; var); // copy constructor
&nbsp;&nbsp;&nbsp;&nbsp; otl_value(const otl_null&amp; var); // copy constructor

&nbsp;&nbsp;&nbsp;&nbsp; otl_value&lt;TData>&amp; operator=(const otl_value&lt;TData>&amp; var); //assignment operator
&nbsp;&nbsp;&nbsp;&nbsp; otl_value&lt;TData>&amp; operator=(const TData&amp; var); // assignment operator
&nbsp;&nbsp;&nbsp;&nbsp; otl_value&lt;TData>&amp; operator=(const otl_null&amp; var); // assignment operator

&nbsp;&nbsp;&nbsp;&nbsp; bool is_null(void) const; // function which returns true if the otl_value is NULL

&nbsp;&nbsp;&nbsp;&nbsp; void set_null(void); // function which sets the otl_value to NULL.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // This function duplicates the assignment&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // operator=(const otl_null&amp;), and used only&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // when <b>.v</b> and/or <b>.ind </b>fields
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // are used directly

&nbsp;&nbsp;&nbsp;&nbsp; void set_non_null(void); // function which sets the otl_value to "non-NULL",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // and should be used only when <b>.v</b> and/or <b>.ind </b>fields
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // are used directly.</pre>

<pre><font size=+2>}; // end of otl_value</font>

</pre>
Also, two global global template stream operators were overloaded for otl_value&lt;T>
and otl_stream's:
<pre><a NAME="otl_value_rr"></a>template &lt;class TData>
otl_stream&amp; operator&lt;&lt;(otl_stream&amp; s, const otl_value&lt;TData>&amp; var);

<a NAME="otl_value_ll"></a>template &lt;class TData>
otl_stream&amp; operator>>(otl_stream&amp; s, otl_value&lt;TData>&amp; var);</pre>
These two template overloaded operators can be used in a combination with
the otl_value&lt;T> container. The operators carry over NULL values, if
there are any.
<p>Here's one more overloaded operator&lt;&lt; for writing otl_value&lt;T>'s
to std::ostream:
<pre><a NAME="otl_value_ostream"></a>template &lt;class TData> std::ostream&amp;
operator&lt;&lt;(std::ostream&amp; s, const otl_value&lt;TData>&amp; var);

</pre>

<hr WIDTH="100%">
<center>
<p><a href="otl3_iterators.htm">Prev</a> <a href="otl3_const_sql.htm">Next</a><a href="otl3.htm">Contents</a><a href="home.htm">Go
Home</a></center>

<p>Copyright &copy; 1996, 2008, Sergei Kuchin, email: <a href="mailto:skuchin@aceweb.com">skuchin@aceweb.com</a>,
<a href="mailto:skuchin@gmail.com">skuchin@gmail.com<script Language="JavaScript"><!-- hide from oldgmailsers
 var modDate = new Date(document.lastModified)
 document.write("<i> Last Updated:</i> " + (modDate.getMonth()+1) + "/" + 
                modDate.getDate() + "/" + "0"+(modDate.getYear())%100+".");
 //-->
 </script>
</a>.
<p><i>Permission to use, copy, modify and redistribute this document for
any purpose is hereby granted without fee, provided that the above copyright
notice appear in all copies.</i>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5456201-1");
pageTracker._trackPageview();
</script>
</body>
</html>

⌨️ 快捷键说明

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