• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/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>DbEnv</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="env.html" title="Chapter��5.�� The DbEnv Handle" />
11    <link rel="prev" href="envclose.html" title="DbEnv::close()" />
12    <link rel="next" href="envdbremove.html" title="DbEnv::dbremove()" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">DbEnv</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="envclose.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��5.��
23                The DbEnv Handle
24        </th>
25          <td width="20%" align="right">��<a accesskey="n" href="envdbremove.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="envcreate"></a>DbEnv</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db_cxx.h&gt;
39
40class DbEnv { 
41public: 
42        DbEnv(u_int32 flags); 
43        ~DbEnv();
44
45        DB_ENV *DbEnv::get_DB_ENV(); 
46        const DB_ENV *DbEnv::get_const_DB_ENV() const; 
47        static DbEnv *DbEnv::get_DbEnv(DB_ENV *dbenv); 
48        static const DbEnv *DbEnv::get_const_DbEnv(const DB_ENV *dbenv); 
49        ... 
50}; </pre>
51      <p>
52        The <code class="classname">DbEnv</code> object is the handle for a Berkeley DB environment ��� 
53        a collection including support for some or all of caching, locking, logging and transaction subsystems, as well as
54        databases and log files. Methods of the <code class="classname">DbEnv</code> handle are used to configure the environment
55        as well as to operate on subsystems and databases in the environment.
56    </p>
57      <p>
58        <code class="classname">DbEnv</code> handles are free-threaded if the 
59        <a class="link" href="envopen.html#envopen_DB_THREAD">DB_THREAD</a> flag is specified to the
60        <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method when the environment is opened.
61        The <code class="classname">DbEnv</code> handle should not be closed while any other handle
62        remains open that is using it as a reference (for example, 
63        <a class="link" href="db.html" title="Chapter��2.�� The Db Handle">Db</a> or <a class="link" href="txn.html" title="Chapter��13.�� The DbTxn Handle">DbTxn</a>). 
64        Once either the
65        <a class="xref" href="envclose.html" title="DbEnv::close()">DbEnv::close()</a> or 
66        <a class="xref" href="envremove.html" title="DbEnv::remove()">DbEnv::remove()</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 the <code class="classname">DbEnv</code> object. 
71        The constructor allocates memory internally; calling the 
72        <a class="xref" href="envclose.html" title="DbEnv::close()">DbEnv::close()</a> or 
73        <a class="xref" href="envremove.html" title="DbEnv::remove()">DbEnv::remove()</a> 
74         methods will free that memory.
75    </p>
76      <p>
77            Before the handle may be used, you must open it using the 
78            <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a>
79            method.
80    </p>
81      <p>
82            The <span class="bold"><strong>flags</strong></span> parameter must be set to 0.
83    </p>
84      <div class="itemizedlist">
85        <ul type="disc">
86          <li>
87            <p><a id="env_DB_CXX_NO_EXCEPTIONS"></a>
88                        <code class="literal">DB_CXX_NO_EXCEPTIONS</code>
89                    </p>
90            <p>
91                            The Berkeley DB C++ API supports two different error behaviors. By default, whenever an error
92                            occurs, an exception is thrown that encapsulates the error information. This
93                            generally allows for cleaner logic for transaction processing because a try block can
94                            surround a single transaction. However, if
95                            <code class="literal">DB_CXX_NO_EXCEPTIONS</code> is specified, exceptions
96                            are not thrown; instead, each individual function returns an error code.
97                    </p>
98          </li>
99        </ul>
100      </div>
101      <p>
102        Each <code class="classname">DbEnv</code> object has an associated <code class="literal">DB_ENV</code>
103        structure, which is used by the underlying implementation of Berkeley DB and its C-language
104        API. The <code class="methodname">DbEnv::get_DB_ENV()</code> method returns a pointer to this
105        struct. Given a <code class="literal">const DbEnv</code> object,
106        <code class="methodname">DbEnv::get_const_DB_ENV()</code> returns a const pointer to the same
107        struct.
108    </p>
109      <p>
110        Given a <code class="literal">DB_ENV</code> struct, the <code class="methodname">DbEnv::get_DbEnv()</code>
111        method returns the corresponding <code class="classname">DbEnv</code> object,
112        if there is one. If the <code class="literal">DB_ENV</code> struct was not associated with a
113        <code class="classname">DbEnv</code> (that is, it was not
114        returned from a call to <code class="methodname">DbEnv::get_DB_ENV()</code>), then the result of
115        <code class="methodname">DbEnv::get_DbEnv()</code> is
116        undefined. Given a <code class="literal">const DB_ENV</code> struct,
117        <code class="methodname">DbEnv::get_const_Db_Env()</code> returns the associated 
118        <code class="literal">const DbEnv</code> object, if there is one.
119    </p>
120      <p>
121        These methods may be useful for Berkeley DB applications including both C and C++ language
122        software. It should not be necessary to use these calls in a purely C++ application.
123    </p>
124      <div class="sect2" lang="en" xml:lang="en">
125        <div class="titlepage">
126          <div>
127            <div>
128              <h3 class="title"><a id="id1663125"></a>Class</h3>
129            </div>
130          </div>
131        </div>
132        <p>
133                     <a class="link" href="env.html" title="Chapter��5.�� The DbEnv Handle">DbEnv</a>
134            </p>
135      </div>
136      <div class="sect2" lang="en" xml:lang="en">
137        <div class="titlepage">
138          <div>
139            <div>
140              <h3 class="title"><a id="id1663348"></a>See Also</h3>
141            </div>
142          </div>
143        </div>
144        <p>
145                     <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 
146                </p>
147      </div>
148    </div>
149    <div class="navfooter">
150      <hr />
151      <table width="100%" summary="Navigation footer">
152        <tr>
153          <td width="40%" align="left"><a accesskey="p" href="envclose.html">Prev</a>��</td>
154          <td width="20%" align="center">
155            <a accesskey="u" href="env.html">Up</a>
156          </td>
157          <td width="40%" align="right">��<a accesskey="n" href="envdbremove.html">Next</a></td>
158        </tr>
159        <tr>
160          <td width="40%" align="left" valign="top">DbEnv::close()��</td>
161          <td width="20%" align="center">
162            <a accesskey="h" href="index.html">Home</a>
163          </td>
164          <td width="40%" align="right" valign="top">��DbEnv::dbremove()</td>
165        </tr>
166      </table>
167    </div>
168  </body>
169</html>
170