OTL 4.0, Template otl_value<T>

Template otl_value<T>

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, otl_datetime (OTL date&time container), std::string (STL string class).

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.

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.

The otl_value<T> class can be activated with #define OTL_STL, or #define OTL_VALUE_TEMPLATE_ON.
 
 

template<class TData> 
class otl_value{
public:
Function / Data member
Description
TData v;
Container for a scalar value of the TData type.
bool ind;
NULL indicator.
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; 
returns true if the otl_value is NULL
void set_null(void); 
sets the otl_value to NULL. This function duplicates the assignment  operator=(const otl_null&), and used only  when .v and/or .ind fields are used directly
void set_non_null(void); 
sets the otl_value to "non-NULL", and should be used only when .v and/or .ind fields are used directly.


}; // end of otl_value

Also, two global global template stream operators were overloaded for otl_value<T> and otl_stream's:
template <class TData>
otl_stream& operator<<(otl_stream& s, const otl_value<TData>& var);

template <class TData>
otl_stream& operator>>(otl_stream& s, otl_value<TData>& var);
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.

Here's one more overloaded operator<< for writing otl_value<T>'s to std::ostream:

template <class TData> std::ostream&
operator<<(std::ostream& s, const otl_value<TData>& var);


Prev NextContentsGo Home

Copyright © 1996-2009, Sergei Kuchin, email: skuchin@aceweb.com, skuchin@gmail.com .

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. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.