libdb/docs/programmer_reference/stl.html

486 lines
16 KiB
HTML
Raw Normal View History

2011-09-13 17:44:24 +00:00
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chapter 7. Standard Template Library API</title>
<link rel="stylesheet" href="gettingStarted.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
<link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
<link rel="prev" href="csharp.html" title="Chapter 6. C# API" />
<link rel="next" href="stl_usecase.html" title="Dbstl typical use cases" />
</head>
<body>
<div xmlns="" class="navheader">
<div class="libver">
2012-11-14 21:35:20 +00:00
<p>Library Version 11.2.5.3</p>
2011-09-13 17:44:24 +00:00
</div>
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">Chapter 7. Standard Template Library API</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="csharp.html">Prev</a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="stl_usecase.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="chapter" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a id="stl"></a>Chapter 7. Standard Template Library API</h2>
</div>
</div>
</div>
<div class="toc">
<p>
<b>Table of Contents</b>
</p>
<dl>
<dt>
<span class="sect1">
<a href="stl.html#stl_intro">Dbstl introduction</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
<a href="stl.html#stl_intro_stdcompat">Standards compatible</a>
</span>
</dt>
<dt>
<span class="sect2">
<a href="stl.html#stl_intro_performance">Performance overhead</a>
</span>
</dt>
<dt>
<span class="sect2">
<a href="stl.html#stl_intro_portability">Portability</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_usecase.html">Dbstl typical use cases</a>
</span>
</dt>
<dt>
<span class="sect1">
<a href="stl_examples.html">Dbstl examples</a>
</span>
</dt>
<dt>
<span class="sect1">
<a href="stl_db_usage.html">Berkeley DB configuration</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_usage.html#idp1202384">Registering database and environment handles</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_usage.html#idp1225928">Truncate requirements</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_usage.html#idp1236168">Auto commit support</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_usage.html#idp1239792">Database and environment identity checks</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_usage.html#idp1236512">Products, constructors and configurations</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_db_advanced_usage.html">Using advanced Berkeley DB features with dbstl</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_advanced_usage.html#idp1232296">Using bulk retrieval iterators</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_advanced_usage.html#idp1232520">Using the DB_RMW flag</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_db_advanced_usage.html#idp1199288">Using secondary index database and secondary containers</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_txn_usage.html">Using transactions in dbstl</a>
</span>
</dt>
<dt>
<span class="sect1">
<a href="stl_mt_usage.html">Using dbstl in multithreaded applications</a>
</span>
</dt>
<dt>
<span class="sect1">
<a href="stl_primitive_rw.html">Working with primitive types </a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_primitive_rw.html#idp1288424">Storing strings</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_complex_rw.html">Store and Retrieve data or objects of complex types </a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_complex_rw.html#idp1279008">Storing varying length objects</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_complex_rw.html#idp1278616">Storing arbitrary sequences</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_complex_rw.html#idp1344912">Notes</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_persistence.html">Dbstl persistence</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
<a href="stl_persistence.html#directdbget">Direct database get</a>
</span>
</dt>
<dt>
<span class="sect2">
<a href="stl_persistence.html#chg_persistence">Change persistence</a>
</span>
</dt>
<dt>
<span class="sect2">
<a href="stl_persistence.html#obj_life_persistence">Object life time and persistence </a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_container_specific.html">Dbstl container specific notes</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_container_specific.html#idp1313840">db_vector specific notes</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_container_specific.html#idp1381768">Associative container specific notes</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_efficienct_use.html">Using dbstl efficiently</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_efficienct_use.html#idp1350664">Using iterators efficiently</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_efficienct_use.html#idp1350448">Using containers efficiently</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_memory_mgmt.html">Dbstl memory management</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_memory_mgmt.html#idp1384984">Freeing memory</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_memory_mgmt.html#idp1389512">Type specific notes</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_misc.html">Dbstl miscellaneous notes</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_misc.html#idp1407848">Special notes about trivial methods</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
<dt>
<span class="sect2">
2012-11-14 21:35:20 +00:00
<a href="stl_misc.html#idp1421568">Using correct container and iterator public types</a>
2011-09-13 17:44:24 +00:00
</span>
</dt>
</dl>
</dd>
<dt>
<span class="sect1">
<a href="stl_known_issues.html">Dbstl known issues</a>
</span>
</dt>
</dl>
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="stl_intro"></a>Dbstl introduction</h2>
</div>
</div>
</div>
<div class="toc">
<dl>
<dt>
<span class="sect2">
<a href="stl.html#stl_intro_stdcompat">Standards compatible</a>
</span>
</dt>
<dt>
<span class="sect2">
<a href="stl.html#stl_intro_performance">Performance overhead</a>
</span>
</dt>
<dt>
<span class="sect2">
<a href="stl.html#stl_intro_portability">Portability</a>
</span>
</dt>
</dl>
</div>
<p>
Dbstl is a C++ STL style API that provides for Berkeley DB usage. It
allows for the storage and retrieval of data/objects of any type using
Berkeley DB databases, but with an interface that mimics that of C++
STL containers. Dbstl provides access to all of the functionality of
Berkeley DB available via this STL-style API.
</p>
<p>
With proper configuration, dbstl is able to store/retrieve any complex
data types. There is no need to perform repetitive marshalling and
unmarshalling of data. Dbstl also properly manages the life-cycle of
all Berkeley DB structures and objects. All example methods referred to in this chapter
can be found in the StlAdvancedFeaturesExample class in the $DbSrc/examples_stl/StlAdvancedFeatures.cpp file, and you can
build the example in $DbSrc/build_unix directory like this:
make exstl_advancedfeatures,
where DbSrc is the source directory for Berkeley DB.
</p>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="stl_intro_stdcompat"></a>Standards compatible</h3>
</div>
</div>
</div>
<p>
Dbstl is composed of many container and iterator class templates. These
containers and iterators correspond exactly to each container and
iterator available in the C++ STL API, including identical sets of
methods. This allows existing algorithms, functions and
container-adapters for C++ STL to use dbstl containers through its
standard iterators. This means that existing STL code can manipulate
Berkeley DB databases. As a result, existing C++ STL code can very
easily use dbstl to gain persistence and transaction guarantees.
</p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="stl_intro_performance"></a>Performance overhead</h3>
</div>
</div>
</div>
<p>
Because dbstl uses C++ template technologies, its performance overhead
is minimal.
</p>
<p>
The dbstl API performs almost equally to the C API, as measured by two
different implementations of the TPC-B benchmark:
<code class="literal">ex_tpcb</code> and <code class="literal">exstl_tpcb</code>.
</p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="stl_intro_portability"></a>Portability</h3>
</div>
</div>
</div>
<p>
The degree to which dbstl is portable to a new platform is determined
by whether Berkeley DB is available on the platform, as well as whether
an appropriate C++ compiler is available on the platform.
</p>
<p>
For information on porting Berkeley DB to new platforms, see the
<em class="citetitle">Berkeley DB Porting Guide</em>.
</p>
<p>
Almost all the advanced C++ template features are used in dbstl, including:
</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>
member function templates
</p>
</li>
<li>
<p>
member function template overloads
</p>
</li>
<li>
<p>
partial specialization
</p>
</li>
<li>
<p>
default template parameters.
</p>
</li>
</ul>
</div>
<p>
For this reason, you need a standards-compatible C++ compiler to
build dbstl. As of this writing, the following compilers are known
to build dbstl successfully:
</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>
MSVC8
</p>
</li>
<li>
<p>
gcc3.4.4 and above
</p>
</li>
<li>
<p>
Intel C++ 9 and above
</p>
</li>
</ul>
</div>
<p>
For *nix platforms, if you can successfully configure your Berkeley
DB build script with <code class="literal">--enable-stl</code>, then you
should be able to successfully build dbstl library and application
code using it.
</p>
<p>
Besides its own test suite, dbstl has also been tested against,
and passes, the following test suites:
</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>
MS STL test suite
</p>
</li>
<li>
<p>
SGI STL test suite
</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="csharp.html">Prev</a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="stl_usecase.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 6. C# API </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> Dbstl typical use cases</td>
</tr>
</table>
</div>
</body>
</html>