Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

cxx_int.h

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: cxx_int.h,v 12.1 2005/06/16 20:21:43 bostic Exp $
00008  */
00009 
00010 #ifndef _CXX_INT_H_
00011 #define _CXX_INT_H_
00012 
00013 // private data structures known to the implementation only
00014 
00015 //
00016 // Using FooImp classes will allow the implementation to change in the
00017 // future without any modification to user code or even to header files
00018 // that the user includes. FooImp * is just like void * except that it
00019 // provides a little extra protection, since you cannot randomly assign
00020 // any old pointer to a FooImp* as you can with void *.  Currently, a
00021 // pointer to such an opaque class is always just a pointer to the
00022 // appropriate underlying implementation struct.  These are converted
00023 // back and forth using the various overloaded wrap()/unwrap() methods.
00024 // This is essentially a use of the "Bridge" Design Pattern.
00025 //
00026 // WRAPPED_CLASS implements the appropriate wrap() and unwrap() methods
00027 // for a wrapper class that has an underlying pointer representation.
00028 //
00029 #define WRAPPED_CLASS(_WRAPPER_CLASS, _IMP_CLASS, _WRAPPED_TYPE)           \
00030                                                                            \
00031         class _IMP_CLASS {};                                               \
00032                                                                            \
00033         inline _WRAPPED_TYPE *unwrap(_WRAPPER_CLASS *val)                  \
00034         {                                                                  \
00035                 if (!val) return (0);                                      \
00036                 return (val->get_##_WRAPPED_TYPE());                       \
00037         }                                                                  \
00038                                                                            \
00039         inline const _WRAPPED_TYPE *unwrapConst(const _WRAPPER_CLASS *val) \
00040         {                                                                  \
00041                 if (!val) return (0);                                      \
00042                 return (val->get_const_##_WRAPPED_TYPE());                 \
00043         }
00044 
00045 WRAPPED_CLASS(Db, DbImp, DB)
00046 WRAPPED_CLASS(DbEnv, DbEnvImp, DB_ENV)
00047 WRAPPED_CLASS(DbMpoolFile, DbMpoolFileImp, DB_MPOOLFILE)
00048 WRAPPED_CLASS(DbSequence, DbSequenceImp, DB_SEQUENCE)
00049 WRAPPED_CLASS(DbTxn, DbTxnImp, DB_TXN)
00050 
00051 // A tristate integer value used by the DB_ERROR macro below.
00052 // We chose not to make this an enumerated type so it can
00053 // be kept private, even though methods that return the
00054 // tristate int can be declared in db_cxx.h .
00055 //
00056 #define ON_ERROR_THROW     1
00057 #define ON_ERROR_RETURN    0
00058 #define ON_ERROR_UNKNOWN   (-1)
00059 
00060 // Macros that handle detected errors, in case we want to
00061 // change the default behavior.  The 'policy' is one of
00062 // the tristate values given above.  If UNKNOWN is specified,
00063 // the behavior is taken from the last initialized DbEnv.
00064 //
00065 #define DB_ERROR(env, caller, ecode, policy) \
00066     DbEnv::runtime_error(env, caller, ecode, policy)
00067 
00068 #define DB_ERROR_DBT(env, caller, dbt, policy) \
00069     DbEnv::runtime_error_dbt(env, caller, dbt, policy)
00070 
00071 #define DB_OVERFLOWED_DBT(dbt) \
00072         (F_ISSET(dbt, DB_DBT_USERMEM) && dbt->size > dbt->ulen)
00073 
00074 /* values for Db::flags_ */
00075 #define DB_CXX_PRIVATE_ENV      0x00000001
00076 
00077 #endif /* !_CXX_INT_H_ */

Generated on Sun Dec 25 12:14:22 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2