Update ooo320-m1
[ooovba.git] / desktop / source / deployment / inc / db.hxx
blobb78e54bb71e649f930499aab6be9ebc8ff635c5a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: db.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef BERKELEYDBPROXY_DB_HXX_
31 #define BERKELEYDBPROXY_DB_HXX_
33 #ifdef SYSTEM_DB
34 #include <db.h>
35 #else
36 #include <berkeleydb/db.h>
37 #endif
39 #include <rtl/string.hxx>
40 #include "dp_misc_api.hxx"
42 extern "C" {
43 typedef void *(*db_malloc_fcn_type)(size_t);
44 typedef void *(*db_realloc_fcn_type)(void *, size_t);
45 typedef void (*db_free_fcn_type)(void *);
49 namespace berkeleydbproxy {
51 class DbEnv;
52 class Dbc;
53 class Dbt;
55 namespace db_internal
57 class Noncopyable
59 // not implemented
60 Noncopyable(const Noncopyable&);
61 void operator=(const Noncopyable&);
62 protected:
63 Noncopyable() {}
64 ~Noncopyable() {}
68 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DbException
70 rtl::OString what_;
71 public:
72 explicit DbException(rtl::OString const & theWhat)
73 : what_(theWhat)
76 const char *what() const
77 { return what_.getStr(); }
78 int get_errno() const
79 { return 0; }
83 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DbEnv : db_internal::Noncopyable
85 friend class Db;
87 private:
88 DB_ENV* m_pDBENV;
90 public:
91 static char *strerror(int);
94 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Db : db_internal::Noncopyable
96 private:
97 DB* m_pDBP;
99 public:
100 Db(DbEnv* dbbenv,u_int32_t flags);
101 ~Db();
103 int close(u_int32_t flags);
105 int open(DB_TXN *txnid,
106 const char *file,
107 const char *database,
108 DBTYPE type,
109 u_int32_t flags,
110 int mode);
112 int sync(u_int32_t flags);
113 int del(Dbt *key, u_int32_t flags);
115 int get(DB_TXN* txnid, Dbt *key, Dbt *data, u_int32_t flags);
116 int put(DB_TXN* txnid, Dbt *key, Dbt *data, u_int32_t flags);
118 int cursor(DB_TXN *txnid, Dbc **cursorp, u_int32_t flags);
121 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Dbc : db_internal::Noncopyable
123 friend class Db;
124 friend class Dbt;
126 private:
127 DBC* m_pDBC;
129 SAL_DLLPRIVATE explicit Dbc(DBC* pDBC);
130 SAL_DLLPRIVATE ~Dbc();
132 public:
133 int close();
135 int get(Dbt *key, Dbt *data, u_int32_t flags);
138 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Dbt: private DBT
140 friend class Db;
141 friend class Dbc;
143 public:
144 Dbt(void *data_arg, u_int32_t size_arg);
146 Dbt();
147 Dbt(const Dbt & other);
148 Dbt & operator=(const Dbt & other);
150 ~Dbt();
152 void *get_data() const;
153 void set_data(void *value);
155 u_int32_t get_size() const;
156 void set_size(u_int32_t value);
160 #endif