📄 db_cxx.in
字号:
// We can add data to this class if needed // since it is implemented via a pointer. // (see comment at top) // Note: use DbEnv::memp_fcreate() to get pointers to a DbMpoolFile, // and call DbMpoolFile::close() rather than delete to release them. // DbMpoolFile(); // Shut g++ up.protected: virtual ~DbMpoolFile();private: // no copying DbMpoolFile(const DbMpoolFile &); void operator = (const DbMpoolFile &);};//// This is filled in and returned by the DbEnv::txn_recover() method.//class _exported DbPreplist{public: DbTxn *txn; u_int8_t gid[DB_XIDDATASIZE];};//// A sequence record in a database//class _exported DbSequence{public: DbSequence(Db *db, u_int32_t flags); virtual ~DbSequence(); int open(DbTxn *txnid, Dbt *key, u_int32_t flags); int initial_value(db_seq_t value); int close(u_int32_t flags); int remove(DbTxn *txnid, u_int32_t flags); int stat(DB_SEQUENCE_STAT **sp, u_int32_t flags); int stat_print(u_int32_t flags); int get(DbTxn *txnid, int32_t delta, db_seq_t *retp, u_int32_t flags); int get_cachesize(int32_t *sizep); int set_cachesize(int32_t size); int get_flags(u_int32_t *flagsp); int set_flags(u_int32_t flags); int get_range(db_seq_t *minp, db_seq_t *maxp); int set_range(db_seq_t min, db_seq_t max); Db *get_db(); Dbt *get_key(); virtual DB_SEQUENCE *get_DB_SEQUENCE() { return imp_; } virtual const DB_SEQUENCE *get_const_DB_SEQUENCE() const { return imp_; } static DbSequence* get_DbSequence(DB_SEQUENCE *seq) { return (DbSequence *)seq->api_internal; } static const DbSequence* get_const_DbSequence(const DB_SEQUENCE *seq) { return (const DbSequence *)seq->api_internal; } // For internal use only. static DbSequence* wrap_DB_SEQUENCE(DB_SEQUENCE *seq);private: DbSequence(DB_SEQUENCE *seq); // no copying DbSequence(const DbSequence &); DbSequence &operator = (const DbSequence &); DB_SEQUENCE *imp_; DBT key_;};//// Transaction//class _exported DbTxn{ friend class DbEnv;public: int abort(); int commit(u_int32_t flags); int discard(u_int32_t flags); u_int32_t id(); int prepare(u_int8_t *gid); int set_timeout(db_timeout_t timeout, u_int32_t flags); virtual DB_TXN *get_DB_TXN() { return imp_; } virtual const DB_TXN *get_const_DB_TXN() const { return imp_; } static DbTxn* get_DbTxn(DB_TXN *txn) { return (DbTxn *)txn->api_internal; } static const DbTxn* get_const_DbTxn(const DB_TXN *txn) { return (const DbTxn *)txn->api_internal; } // For internal use only. static DbTxn* wrap_DB_TXN(DB_TXN *txn);private: DB_TXN *imp_; // We can add data to this class if needed // since it is implemented via a pointer. // (see comment at top) // Note: use DbEnv::txn_begin() to get pointers to a DbTxn, // and call DbTxn::abort() or DbTxn::commit rather than // delete to release them. // DbTxn(); // For internal use only. DbTxn(DB_TXN *txn); virtual ~DbTxn(); // no copying DbTxn(const DbTxn &); void operator = (const DbTxn &);};//// A chunk of data, maybe a key or value.//class _exported Dbt : private DBT{ friend class Db; friend class Dbc; friend class DbEnv; friend class DbLogc; friend class DbSequence;public: // key/data void *get_data() const { return data; } void set_data(void *value) { data = value; } // key/data length u_int32_t get_size() const { return size; } void set_size(u_int32_t value) { size = value; } // RO: length of user buffer. u_int32_t get_ulen() const { return ulen; } void set_ulen(u_int32_t value) { ulen = value; } // RO: get/put record length. u_int32_t get_dlen() const { return dlen; } void set_dlen(u_int32_t value) { dlen = value; } // RO: get/put record offset. u_int32_t get_doff() const { return doff; } void set_doff(u_int32_t value) { doff = value; } // flags u_int32_t get_flags() const { return flags; } void set_flags(u_int32_t value) { flags = value; } // Conversion functions DBT *get_DBT() { return (DBT *)this; } const DBT *get_const_DBT() const { return (const DBT *)this; } static Dbt* get_Dbt(DBT *dbt) { return (Dbt *)dbt; } static const Dbt* get_const_Dbt(const DBT *dbt) { return (const Dbt *)dbt; } Dbt(void *data, u_int32_t size); Dbt(); ~Dbt(); Dbt(const Dbt &); Dbt &operator = (const Dbt &);private: // Note: no extra data appears in this class (other than // inherited from DBT) since we need DBT and Dbt objects // to have interchangable pointers. // // When subclassing this class, remember that callback // methods like bt_compare, bt_prefix, dup_compare may // internally manufacture DBT objects (which later are // cast to Dbt), so such callbacks might receive objects // not of your subclassed type.};//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// multiple key/data/reco iterator classes//// DbMultipleIterator is a shared private base class for the three types// of bulk-return Iterator; it should never be instantiated directly,// but it handles the functionality shared by its subclasses.class _exported DbMultipleIterator{public: DbMultipleIterator(const Dbt &dbt);protected: u_int8_t *data_; u_int32_t *p_;};class _exported DbMultipleKeyDataIterator : private DbMultipleIterator{public: DbMultipleKeyDataIterator(const Dbt &dbt) : DbMultipleIterator(dbt) {} bool next(Dbt &key, Dbt &data);};class _exported DbMultipleRecnoDataIterator : private DbMultipleIterator{public: DbMultipleRecnoDataIterator(const Dbt &dbt) : DbMultipleIterator(dbt) {} bool next(db_recno_t &recno, Dbt &data);};class _exported DbMultipleDataIterator : private DbMultipleIterator{public: DbMultipleDataIterator(const Dbt &dbt) : DbMultipleIterator(dbt) {} bool next(Dbt &data);};//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Exception classes//// Almost any error in the DB library throws a DbException.// Every exception should be considered an abnormality// (e.g. bug, misuse of DB, file system error).//class _exported DbException : public __DB_STD(exception){public: virtual ~DbException() throw(); DbException(int err); DbException(const char *description); DbException(const char *description, int err); DbException(const char *prefix, const char *description, int err); int get_errno() const; virtual const char *what() const throw(); DbEnv *get_env() const; void set_env(DbEnv *env); DbException(const DbException &); DbException &operator = (const DbException &);private: void describe(const char *prefix, const char *description); char *what_; int err_; // errno DbEnv *env_;};//// A specific sort of exception that occurs when// an operation is aborted to resolve a deadlock.//class _exported DbDeadlockException : public DbException{public: virtual ~DbDeadlockException() throw(); DbDeadlockException(const char *description); DbDeadlockException(const DbDeadlockException &); DbDeadlockException &operator = (const DbDeadlockException &);};//// A specific sort of exception that occurs when// a lock is not granted, e.g. by lock_get or lock_vec.// Note that the Dbt is only live as long as the Dbt used// in the offending call.//class _exported DbLockNotGrantedException : public DbException{public: virtual ~DbLockNotGrantedException() throw(); DbLockNotGrantedException(const char *prefix, db_lockop_t op, db_lockmode_t mode, const Dbt *obj, const DbLock lock, int index); DbLockNotGrantedException(const char *description); DbLockNotGrantedException(const DbLockNotGrantedException &); DbLockNotGrantedException &operator = (const DbLockNotGrantedException &); db_lockop_t get_op() const; db_lockmode_t get_mode() const; const Dbt* get_obj() const; DbLock *get_lock() const; int get_index() const;private: db_lockop_t op_; db_lockmode_t mode_; const Dbt *obj_; DbLock *lock_; int index_;};//// A specific sort of exception that occurs when// user declared memory is insufficient in a Dbt.//class _exported DbMemoryException : public DbException{public: virtual ~DbMemoryException() throw(); DbMemoryException(Dbt *dbt); DbMemoryException(const char *prefix, Dbt *dbt); DbMemoryException(const DbMemoryException &); DbMemoryException &operator = (const DbMemoryException &); Dbt *get_dbt() const;private: Dbt *dbt_;};//// A specific sort of exception that occurs when// recovery is required before continuing DB activity.//class _exported DbRunRecoveryException : public DbException{public: virtual ~DbRunRecoveryException() throw(); DbRunRecoveryException(const char *description); DbRunRecoveryException(const DbRunRecoveryException &); DbRunRecoveryException &operator = (const DbRunRecoveryException &);};#endif /* !_DB_CXX_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -