📄 db_cxx.h
字号:
/* DO NOT EDIT: automatically built by dist/s_win32. *//*- * See the file LICENSE for redistribution information. * * Copyright (c) 1997-2004 * Sleepycat Software. All rights reserved. * * $Id: db_cxx.in,v 11.147 2004/10/07 21:39:48 bostic Exp $ */#ifndef _DB_CXX_H_#define _DB_CXX_H_//// C++ assumptions://// To ensure portability to many platforms, both new and old, we make// few assumptions about the C++ compiler and library. For example,// we do not expect STL, templates or namespaces to be available. The// "newest" C++ feature used is exceptions, which are used liberally// to transmit error information. Even the use of exceptions can be// disabled at runtime, to do so, use the DB_CXX_NO_EXCEPTIONS flags// with the DbEnv or Db constructor.//// C++ naming conventions://// - All top level class names start with Db.// - All class members start with lower case letter.// - All private data members are suffixed with underscore.// - Use underscores to divide names into multiple words.// - Simple data accessors are named with get_ or set_ prefix.// - All method names are taken from names of functions in the C// layer of db (usually by dropping a prefix like "db_").// These methods have the same argument types and order,// other than dropping the explicit arg that acts as "this".//// As a rule, each DbFoo object has exactly one underlying DB_FOO struct// (defined in db.h) associated with it. In some cases, we inherit directly// from the DB_FOO structure to make this relationship explicit. Often,// the underlying C layer allocates and deallocates these structures, so// there is no easy way to add any data to the DbFoo class. When you see// a comment about whether data is permitted to be added, this is what// is going on. Of course, if we need to add data to such C++ classes// in the future, we will arrange to have an indirect pointer to the// DB_FOO struct (as some of the classes already have).////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Forward declarations//#include <stdarg.h>#define HAVE_CXX_STDHEADERS 1#ifdef HAVE_CXX_STDHEADERS#include <iostream>#include <exception>#define __DB_STD(x) std::x#else#include <iostream.h>#include <exception.h>#define __DB_STD(x) x#endif#include "db.h"class Db; // forwardclass Dbc; // forwardclass DbEnv; // forwardclass DbInfo; // forwardclass DbLock; // forwardclass DbLogc; // forwardclass DbLsn; // forwardclass DbMpoolFile; // forwardclass DbPreplist; // forwardclass Dbt; // forwardclass DbTxn; // forwardclass DbLock; // forwardclass DbSequence; // forwardclass Dbt; // forwardclass DbMultipleIterator; // forwardclass DbMultipleKeyDataIterator; // forwardclass DbMultipleRecnoDataIterator; // forwardclass DbMultipleDataIterator; // forwardclass DbException; // forwardclass DbDeadlockException; // forwardclass DbLockNotGrantedException; // forwardclass DbMemoryException; // forwardclass DbRunRecoveryException; // forward//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Turn off inappropriate compiler warnings//#ifdef _MSC_VER// These are level 4 warnings that are explicitly disabled.// With Visual C++, by default you do not see above level 3 unless// you use /W4. But we like to compile with the highest level// warnings to catch other errors.//// 4201: nameless struct/union// triggered by standard include file <winnt.h>//// 4514: unreferenced inline function has been removed// certain include files in MSVC define methods that are not called//#pragma warning(disable: 4201 4514)#endif//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Mechanisms for declaring classes////// Every class defined in this file has an _exported next to the class name.// This is needed for WinTel machines so that the class methods can// be exported or imported in a DLL as appropriate. Users of the DLL// use the define DB_USE_DLL. When the DLL is built, DB_CREATE_DLL// must be defined.//#if defined(_MSC_VER)# if defined(DB_CREATE_DLL)# define _exported __declspec(dllexport) // creator of dll# elif defined(DB_USE_DLL)# define _exported __declspec(dllimport) // user of dll# else# define _exported // static lib creator or user# endif#else /* _MSC_VER */# define _exported#endif /* _MSC_VER */// Some interfaces can be customized by allowing users to define// callback functions. For performance and logistical reasons, some// callback functions must be declared in extern "C" blocks. For others,// we allow you to declare the callbacks in C++ or C (or an extern "C"// block) as you wish. See the set methods for the callbacks for// the choices.//extern "C" { typedef void * (*db_malloc_fcn_type) (size_t); typedef void * (*db_realloc_fcn_type) (void *, size_t); typedef void (*db_free_fcn_type) (void *); typedef int (*bt_compare_fcn_type) /*C++ version available*/ (DB *, const DBT *, const DBT *); typedef size_t (*bt_prefix_fcn_type) /*C++ version available*/ (DB *, const DBT *, const DBT *); typedef int (*dup_compare_fcn_type) /*C++ version available*/ (DB *, const DBT *, const DBT *); typedef u_int32_t (*h_hash_fcn_type) /*C++ version available*/ (DB *, const void *, u_int32_t); typedef int (*pgin_fcn_type) (DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie); typedef int (*pgout_fcn_type) (DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie);}//// Represents a database table = a set of keys with associated values.//class _exported Db{ friend class DbEnv;public: Db(DbEnv*, u_int32_t); // create a Db object, then call open() virtual ~Db(); // does *not* call close. // These methods exactly match those in the C interface. // virtual int associate(DbTxn *txn, Db *secondary, int (*callback)(Db *, const Dbt *, const Dbt *, Dbt *), u_int32_t flags); virtual int close(u_int32_t flags); virtual int cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags); virtual int del(DbTxn *txnid, Dbt *key, u_int32_t flags); virtual void err(int, const char *, ...); virtual void errx(const char *, ...); virtual int fd(int *fdp); virtual int get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags); virtual void *get_app_private() const; virtual int get_byteswapped(int *); virtual int get_dbname(const char **, const char **); virtual int get_open_flags(u_int32_t *); virtual int get_type(DBTYPE *); virtual int get_transactional(); virtual int join(Dbc **curslist, Dbc **dbcp, u_int32_t flags); virtual int key_range(DbTxn *, Dbt *, DB_KEY_RANGE *, u_int32_t); virtual int open(DbTxn *txnid, const char *, const char *subname, DBTYPE, u_int32_t, int); virtual int pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *data, u_int32_t flags); virtual int put(DbTxn *, Dbt *, Dbt *, u_int32_t); virtual int remove(const char *, const char *, u_int32_t); virtual int rename(const char *, const char *, const char *, u_int32_t); virtual int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type, db_free_fcn_type); virtual void set_app_private(void *); virtual int set_append_recno(int (*)(Db *, Dbt *, db_recno_t)); virtual int set_bt_compare(bt_compare_fcn_type); /*deprecated*/ virtual int set_bt_compare(int (*)(Db *, const Dbt *, const Dbt *)); virtual int set_bt_maxkey(u_int32_t); virtual int get_bt_minkey(u_int32_t *); virtual int set_bt_minkey(u_int32_t); virtual int set_bt_prefix(bt_prefix_fcn_type); /*deprecated*/ virtual int set_bt_prefix(size_t (*)(Db *, const Dbt *, const Dbt *)); virtual int get_cachesize(u_int32_t *, u_int32_t *, int *); virtual int set_cachesize(u_int32_t, u_int32_t, int); virtual int set_dup_compare(dup_compare_fcn_type); /*deprecated*/ virtual int set_dup_compare(int (*)(Db *, const Dbt *, const Dbt *)); virtual int get_encrypt_flags(u_int32_t *); virtual int set_encrypt(const char *, u_int32_t); virtual void set_errcall( void (*)(const DbEnv *, const char *, const char *)); virtual void get_errfile(FILE **); virtual void set_errfile(FILE *); virtual void get_errpfx(const char **); virtual void set_errpfx(const char *); virtual int set_feedback(void (*)(Db *, int, int)); virtual int get_flags(u_int32_t *); virtual int set_flags(u_int32_t); virtual int get_h_ffactor(u_int32_t *); virtual int set_h_ffactor(u_int32_t); virtual int set_h_hash(h_hash_fcn_type); /*deprecated*/ virtual int set_h_hash(u_int32_t (*)(Db *, const void *, u_int32_t)); virtual int get_h_nelem(u_int32_t *); virtual int set_h_nelem(u_int32_t); virtual int get_lorder(int *); virtual int set_lorder(int); virtual void set_msgcall(void (*)(const DbEnv *, const char *)); virtual void get_msgfile(FILE **); virtual void set_msgfile(FILE *); virtual int get_pagesize(u_int32_t *); virtual int set_pagesize(u_int32_t); virtual int set_paniccall(void (*)(DbEnv *, int)); virtual int get_re_delim(int *); virtual int set_re_delim(int); virtual int get_re_len(u_int32_t *); virtual int set_re_len(u_int32_t); virtual int get_re_pad(int *); virtual int set_re_pad(int); virtual int get_re_source(const char **); virtual int set_re_source(const char *); virtual int get_q_extentsize(u_int32_t *); virtual int set_q_extentsize(u_int32_t); virtual int stat(DbTxn *, void *sp, u_int32_t flags); virtual int stat_print(u_int32_t flags); virtual int sync(u_int32_t flags); virtual int truncate(DbTxn *, u_int32_t *, u_int32_t); virtual int upgrade(const char *name, u_int32_t flags); virtual int verify(const char *, const char *, __DB_STD(ostream) *, u_int32_t); // These additional methods are not in the C interface, and // are only available for C++. // virtual __DB_STD(ostream) *get_error_stream(); virtual void set_error_stream(__DB_STD(ostream) *); virtual __DB_STD(ostream) *get_message_stream(); virtual void set_message_stream(__DB_STD(ostream) *); virtual DbEnv *get_env(); virtual DbMpoolFile *get_mpf(); virtual DB *get_DB() { return imp_; } virtual const DB *get_const_DB() const { return imp_; } static Db* get_Db(DB *db) { return (Db *)db->api_internal; } static const Db* get_const_Db(const DB *db) { return (const Db *)db->api_internal; }private: // no copying Db(const Db &); Db &operator = (const Db &); void cleanup(); int initialize(); int error_policy(); // instance data DB *imp_; DbEnv *env_; DbMpoolFile *mpf_; int construct_error_; u_int32_t flags_; u_int32_t construct_flags_;public: // These are public only because they need to be called // via C callback functions. They should never be used by // external users of this class. // int (*append_recno_callback_)(Db *, Dbt *, db_recno_t); int (*associate_callback_)(Db *, const Dbt *, const Dbt *, Dbt *); int (*bt_compare_callback_)(Db *, const Dbt *, const Dbt *); size_t (*bt_prefix_callback_)(Db *, const Dbt *, const Dbt *); int (*dup_compare_callback_)(Db *, const Dbt *, const Dbt *); void (*feedback_callback_)(Db *, int, int); u_int32_t (*h_hash_callback_)(Db *, const void *, u_int32_t);};//// Cursor//class _exported Dbc : protected DBC{ friend class Db;public: int close(); int count(db_recno_t *countp, u_int32_t flags); int del(u_int32_t flags); int dup(Dbc** cursorp, u_int32_t flags); int get(Dbt* key, Dbt *data, u_int32_t flags); int pget(Dbt* key, Dbt* pkey, Dbt *data, u_int32_t flags); int put(Dbt* key, Dbt *data, u_int32_t flags);private: // No data is permitted in this class (see comment at top) // Note: use Db::cursor() to get pointers to a Dbc, // and call Dbc::close() rather than delete to release them. // Dbc(); ~Dbc(); // no copying Dbc(const Dbc &); Dbc &operator = (const Dbc &);};//// Berkeley DB environment class. Provides functions for opening databases.// User of this library can use this class as a starting point for
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -