Click here to Skip to main content
12,883,272 members (44,685 online)
Click here to Skip to main content
Articles » Database » Database » General » Downloads


56 bookmarked
Posted 30 Nov 2003

DarkSide SQL Mini Version 1, The embedded database

, 23 Mar 2006 BSD
An embedded database library in C++.
 * See the file LICENSE for redistribution information.
 * Copyright (c) 1997-2002
 *	Sleepycat Software.  All rights reserved.
 * $Id: cxx_int.h,v 11.20 2002/01/11 15:52:23 bostic Exp $

#ifndef _CXX_INT_H_
#define	_CXX_INT_H_

// private data structures known to the implementation only

// Using FooImp classes will allow the implementation to change in the
// future without any modification to user code or even to header files
// that the user includes. FooImp * is just like void * except that it
// provides a little extra protection, since you cannot randomly assign
// any old pointer to a FooImp* as you can with void *.  Currently, a
// pointer to such an opaque class is always just a pointer to the
// appropriate underlying implementation struct.  These are converted
// back and forth using the various overloaded wrap()/unwrap() methods.
// This is essentially a use of the "Bridge" Design Pattern.
// WRAPPED_CLASS implements the appropriate wrap() and unwrap() methods
// for a wrapper class that has an underlying pointer representation.
	class _IMP_CLASS {};                                               \
	inline _WRAPPED_TYPE unwrap(_WRAPPER_CLASS *val)                   \
	{                                                                  \
		if (!val) return (0);                                      \
		return ((_WRAPPED_TYPE)((void *)(val->imp())));            \
	}                                                                  \
	inline const _WRAPPED_TYPE unwrapConst(const _WRAPPER_CLASS *val)  \
	{                                                                  \
		if (!val) return (0);                                      \
		return ((const _WRAPPED_TYPE)((void *)(val->constimp()))); \
	}                                                                  \
	inline _IMP_CLASS *wrap(_WRAPPED_TYPE val)                         \
	{                                                                  \
		return ((_IMP_CLASS*)((void *)val));                       \


// A tristate integer value used by the DB_ERROR macro below.
// We chose not to make this an enumerated type so it can
// be kept private, even though methods that return the
// tristate int can be declared in db_cxx.h .
#define	ON_ERROR_THROW     1
#define	ON_ERROR_RETURN    0
#define	ON_ERROR_UNKNOWN   (-1)

// Macros that handle detected errors, in case we want to
// change the default behavior.  The 'policy' is one of
// the tristate values given above.  If UNKNOWN is specified,
// the behavior is taken from the last initialized DbEnv.
#define	DB_ERROR(caller, ecode, policy) \
    DbEnv::runtime_error(caller, ecode, policy)

#define	DB_ERROR_DBT(caller, dbt, policy) \
    DbEnv::runtime_error_dbt(caller, dbt, policy)

#define	DB_OVERFLOWED_DBT(dbt) \
	(F_ISSET(dbt, DB_DBT_USERMEM) && dbt->size > dbt->ulen)

/* values for Db::flags_ */
#define	DB_CXX_PRIVATE_ENV      0x00000001

#endif /* !_CXX_INT_H_ */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The BSD License


About the Author

No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170422.1 | Last Updated 23 Mar 2006
Article Copyright 2003 by AnOldGreenHorn
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid