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:
TData v; bool ind;
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 .v and/or .ind fields // are used directly void set_non_null(void); // function which sets the otl_value to "non-NULL", // and should be used only when .v and/or .ind fields // are used directly.
}; // end of otl_valueAlso, 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);
Copyright © 1996, 2001, Sergei Kuchin, email: skuchin@sprynet.com, kuchin@hotmail.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.