• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/db-4.8.30/docs/api_reference/CXX/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Db</title>
7    <link rel="stylesheet" href="apiReference.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
10    <link rel="up" href="db.html" title="Chapter 2.  The Db Handle" />
11    <link rel="prev" href="dbclose.html" title="Db::close()" />
12    <link rel="next" href="dbcompact.html" title="Db::compact()" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Db</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="dbclose.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 2. 
23                The Db Handle
24        </th>
25          <td width="20%" align="right"> <a accesskey="n" href="dbcompact.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="sect1" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title" style="clear: both"><a id="dbcreate"></a>Db</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db_cxx.h&gt;
39
40class Db { 
41public: 
42        Db(DbEnv *dbenv, u_int32_t flags); 
43        ~Db();
44
45         DB *Db::get_DB(); 
46         const DB *Db::get_const_DB() const; 
47         static Db *Db::get_Db(DB *db); 
48         static const Db *Db::get_const_Db(const DB *db); 
49         ... 
50}; </pre>
51      <p>
52        The Db handle is the handle for a Berkeley DB database, which may or may not be part of a
53        database environment.
54    </p>
55      <p>
56        Db handles are free-threaded if the 
57        <a class="link" href="envopen.html#envopen_DB_THREAD">DB_THREAD</a> flag is specified to 
58        the <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> method when the database is opened or 
59        if the database environment in which the database is opened is free-threaded. The handle 
60        should not be closed while any other handle that refers to the database is in use; for 
61        example, database handles must not be closed while cursor handles into the database remain 
62        open, or transactions that include operations on the database have not yet been committed 
63        or aborted.  Once the <a class="xref" href="dbclose.html" title="Db::close()">Db::close()</a>, 
64        <a class="xref" href="dbremove.html" title="Db::remove()">Db::remove()</a>, 
65        <a class="xref" href="dbrename.html" title="Db::rename()">Db::rename()</a>, or
66        <a class="xref" href="dbverify.html" title="Db::verify()">Db::verify()</a> 
67        methods are called, the handle may not be accessed again, regardless of the method's return.
68    </p>
69      <p>
70        The constructor creates a <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a> object that is the
71        handle for a Berkeley DB database. The constructor allocates memory internally; calling
72        the <a class="xref" href="dbclose.html" title="Db::close()">Db::close()</a>,
73        <a class="xref" href="dbremove.html" title="Db::remove()">Db::remove()</a>, or
74        <a class="xref" href="dbrename.html" title="Db::rename()">Db::rename()</a>
75        methods will free that memory.        
76    </p>
77      <p>
78        Note that destroying the <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
79        object is synonomous with calling <code class="literal">Db::close(0)</code>.
80    </p>
81      <p>
82        Each <code class="methodname">Db</code> object has an associated <code class="methodname">DB</code>
83        struct, which is used by the underlying implementation of Berkeley DB and its C-language
84        API. The <code class="methodname">Db::get_DB()</code>  method returns a pointer to this struct.
85        Given a <code class="methodname">const Db</code> object,
86        <code class="methodname">Db::get_const_DB()</code> returns a const pointer to the same struct.
87    </p>
88      <p>
89        Given a <code class="literal">DB</code> struct, the <code class="methodname">Db::get_Db()</code> method 
90        returns the corresponding <code class="classname">Db</code> object, if there is
91        one. If the <code class="literal">DB</code> object was not associated with a 
92        <code class="classname">Db</code> (that is, it was not returned from a call
93        to the <code class="methodname">Db::get_DB()</code> method), then the result of 
94        <code class="methodname">Db::get_Db()</code> is undefined. Given a 
95        <code class="literal">const DB struct</code>,
96        <code class="methodname">Db::get_const_Db()</code> returns the associated 
97        <code class="literal">const Db</code>object, if there is one.
98    </p>
99      <p>
100        These methods may be useful for Berkeley DB applications including both C and C++
101        language software. It should not be necessary to use these calls in a purely C++
102        application.
103    </p>
104      <div class="sect2" lang="en" xml:lang="en">
105        <div class="titlepage">
106          <div>
107            <div>
108              <h3 class="title"><a id="id1631976"></a>Parameters</h3>
109            </div>
110          </div>
111        </div>
112        <div class="sect3" lang="en" xml:lang="en">
113          <div class="titlepage">
114            <div>
115              <div>
116                <h4 class="title"><a id="id1632068"></a>dbenv</h4>
117              </div>
118            </div>
119          </div>
120          <p>
121                 
122                <span>If no <span class="bold"><strong>dbenv</strong></span> value is specified,</span> 
123                the database is standalone; that is, it is not part of any Berkeley DB
124                environment.
125            </p>
126          <p>
127                
128                <span>
129                    If a <span class="bold"><strong>dbenv</strong></span> value is specified,
130                </span>
131                the database is created within the specified Berkeley DB environment. 
132                The database access methods automatically make calls to the other
133                subsystems in Berkeley DB, based on the enclosing environment.  For
134                example, if the environment has been configured to use locking, the
135                access methods will automatically acquire the correct locks when
136                reading and writing pages of the database.
137            </p>
138        </div>
139        <div class="sect3" lang="en" xml:lang="en">
140          <div class="titlepage">
141            <div>
142              <div>
143                <h4 class="title"><a id="id1631995"></a>flags</h4>
144              </div>
145            </div>
146          </div>
147          <p>
148                  The <span class="bold"><strong>flags</strong></span> parameter is currently
149                  unused, and must be set to 0.
150             </p>
151          <div class="itemizedlist">
152            <ul type="disc">
153              <li>
154                <p>
155                                <code class="literal">DB_CXX_NO_EXCEPTION</code>
156                            </p>
157                <p>
158                                The Berkeley DB C++ API supports two different error behaviors. By
159                                default, whenever an error occurs, an exception is thrown that
160                                encapsulates the error information. This generally allows for
161                                cleaner logic for transaction processing because a try block can
162                                surround a single transaction. However, if this flag is
163                                specified, exceptions are not thrown; instead, each individual
164                                function returns an error code. 
165                            </p>
166                <p>
167                                If a <span class="bold"><strong>dbenv</strong></span> value is specified,
168                                this flag is ignored, and the error behavior of the specified
169                                environment is used instead.
170                            </p>
171              </li>
172            </ul>
173          </div>
174        </div>
175      </div>
176      <div class="sect2" lang="en" xml:lang="en">
177        <div class="titlepage">
178          <div>
179            <div>
180              <h3 class="title"><a id="id1631996"></a>Class</h3>
181            </div>
182          </div>
183        </div>
184        <p>
185            <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
186        </p>
187      </div>
188      <div class="sect2" lang="en" xml:lang="en">
189        <div class="titlepage">
190          <div>
191            <div>
192              <h3 class="title"><a id="id1632066"></a>See Also</h3>
193            </div>
194          </div>
195        </div>
196        <p>
197            <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 
198        </p>
199      </div>
200    </div>
201    <div class="navfooter">
202      <hr />
203      <table width="100%" summary="Navigation footer">
204        <tr>
205          <td width="40%" align="left"><a accesskey="p" href="dbclose.html">Prev</a> </td>
206          <td width="20%" align="center">
207            <a accesskey="u" href="db.html">Up</a>
208          </td>
209          <td width="40%" align="right"> <a accesskey="n" href="dbcompact.html">Next</a></td>
210        </tr>
211        <tr>
212          <td width="40%" align="left" valign="top">Db::close() </td>
213          <td width="20%" align="center">
214            <a accesskey="h" href="index.html">Home</a>
215          </td>
216          <td width="40%" align="right" valign="top"> Db::compact()</td>
217        </tr>
218      </table>
219    </div>
220  </body>
221</html>
222