1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
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_
36 #include <berkeleydb/db.h>
39 #include <rtl/string.hxx>
40 #include "dp_misc_api.hxx"
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
{
60 Noncopyable(const Noncopyable
&);
61 void operator=(const Noncopyable
&);
68 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DbException
72 explicit DbException(rtl::OString
const & theWhat
)
76 const char *what() const
77 { return what_
.getStr(); }
83 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DbEnv
: db_internal::Noncopyable
91 static char *strerror(int);
94 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Db
: db_internal::Noncopyable
100 Db(DbEnv
* dbbenv
,u_int32_t flags
);
103 int close(u_int32_t flags
);
105 int open(DB_TXN
*txnid
,
107 const char *database
,
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
129 SAL_DLLPRIVATE
explicit Dbc(DBC
* pDBC
);
130 SAL_DLLPRIVATE
~Dbc();
135 int get(Dbt
*key
, Dbt
*data
, u_int32_t flags
);
138 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Dbt
: private DBT
144 Dbt(void *data_arg
, u_int32_t size_arg
);
147 Dbt(const Dbt
& other
);
148 Dbt
& operator=(const Dbt
& other
);
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
);