📄 otl3_value.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<T></title>
</head>
<body>
<center>
<h1>
OTL 4.0, Template otl_value<T></h1></center>
<h1>
<a NAME="otl_value"></a>Template otl_value<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&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<int>
container, and, it is a NULL. Then, the same value gets written into an
INSERT statement. The otl_value<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<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>
<br>
<pre><font size=+2>template<class TData>
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> TData v;
bool ind;</pre>
<ul>
<li>
Constructors, operators, and functions</li>
</ul>
<pre> otl_value(); // default constructor
otl_value(const otl_value<TData>& var); // copy constructor
otl_value(const TData& var); // copy constructor
otl_value(const otl_null& var); // copy constructor
otl_value<TData>& operator=(const otl_value<TData>& var); //assignment operator
otl_value<TData>& operator=(const TData& var); // assignment operator
otl_value<TData>& operator=(const otl_null& var); // assignment operator
bool is_null(void) const; // function which returns true if the otl_value is NULL
void set_null(void); // function which sets the otl_value to NULL.
// This function duplicates the assignment
// operator=(const otl_null&), and used only
// when <b>.v</b> and/or <b>.ind </b>fields
// are used directly
void set_non_null(void); // function which sets the otl_value to "non-NULL",
// and should be used only when <b>.v</b> and/or <b>.ind </b>fields
// 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<T>
and otl_stream's:
<pre><a NAME="otl_value_rr"></a>template <class TData>
otl_stream& operator<<(otl_stream& s, const otl_value<TData>& var);
<a NAME="otl_value_ll"></a>template <class TData>
otl_stream& operator>>(otl_stream& s, otl_value<TData>& var);</pre>
These two template overloaded operators can be used in a combination with
the otl_value<T> container. The operators carry over NULL values, if
there are any.
<p>Here's one more overloaded operator<< for writing otl_value<T>'s
to std::ostream:
<pre><a NAME="otl_value_ostream"></a>template <class TData> std::ostream&
operator<<(std::ostream& s, const otl_value<TData>& 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 © 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 + -