Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

6.4 The Internal Storage Layer

The internal storage layer and class RWDBValue can be entirely invisible to your application if you want them to be. As noted earlier, it is easy to write DBTools.h++ applications that use only the native C++ types, and the few concrete classes for storage of structured data. Nevertheless, we have included RWDBValue in the public class hierarchy for three reasons:

Your applications may not need to use RWDBValue; if they don't, you can skip most of this chapter. However, we do recommend that you review the material about RWDBValue::ValueType and rwdbNull, since these components are used elsewhere in the DBTools.h++ API.

6.4.1 Class RWDBValue

Class RWDBValue is the DBTools.h++ means of achieving normalization of datatypes. Class RWDBValue converts database-dependent types to C++ types, and vice-versa. It provides storage for any native C++ type and for any of the structured types used by DBTools.h++. It also adds NULL/not NULL semantics to the primitive types.


NOTE: Unlike most DBTools.h++ classes, RWDBValue obeys value semantics.

Class RWDBValue offers a compromise between type safety, functionality, and efficiency. For example, although this class is relatively efficient in both time and space, we do not sacrifice type safety entirely; for example, we reject the notion of storing only a pointer and a length. Also, RWDBValue supports the concept of early binding of data discussed earlier.

You will find a complete entry for RWDBValue in the DBTools.h++ Class Reference, but its main components are listed here:

Whenever data arrives from a database, routines in the database layer interrogate the database API for its type, and store the data as the best suited ValueType. For most types, this is simply a matter of copying some bytes, but for types that arrive in a database-dependent format, like date or money, type conversion is done on the spot.

Whenever the application layer requests data from the internal storage layer, the canConvert() routine is consulted to determine whether or not the conversion can be made. If not, an error condition arises. Otherwise, the appropriate asType()routine is invoked to convert to the requested type.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.