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">
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>Chapter 7. Standard Template Library API</title>
7 <link rel="stylesheet" href="gettingStarted.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 Programmer's Reference Guide" />
10 <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
11 <link rel="prev" href="csharp.html" title="Chapter 6. C# API" />
12 <link rel="next" href="stl_usecase.html" title="Dbstl typical use cases" />
15 <div xmlns="" class="navheader">
17 <p>Library Version 11.2.5.3</p>
19 <table width="100%" summary="Navigation header">
21 <th colspan="3" align="center">Chapter 7. Standard Template Library API</th>
24 <td width="20%" align="left"><a accesskey="p" href="csharp.html">Prev</a> </td>
25 <th width="60%" align="center"> </th>
26 <td width="20%" align="right"> <a accesskey="n" href="stl_usecase.html">Next</a></td>
31 <div class="chapter" lang="en" xml:lang="en">
32 <div class="titlepage">
35 <h2 class="title"><a id="stl"></a>Chapter 7. Standard Template Library API</h2>
41 <b>Table of Contents</b>
46 <a href="stl.html#stl_intro">Dbstl introduction</a>
53 <a href="stl.html#stl_intro_stdcompat">Standards compatible</a>
58 <a href="stl.html#stl_intro_performance">Performance overhead</a>
63 <a href="stl.html#stl_intro_portability">Portability</a>
70 <a href="stl_usecase.html">Dbstl typical use cases</a>
75 <a href="stl_examples.html">Dbstl examples</a>
80 <a href="stl_db_usage.html">Berkeley DB configuration</a>
87 <a href="stl_db_usage.html#idp1202384">Registering database and environment handles</a>
92 <a href="stl_db_usage.html#idp1225928">Truncate requirements</a>
97 <a href="stl_db_usage.html#idp1236168">Auto commit support</a>
102 <a href="stl_db_usage.html#idp1239792">Database and environment identity checks</a>
107 <a href="stl_db_usage.html#idp1236512">Products, constructors and configurations</a>
114 <a href="stl_db_advanced_usage.html">Using advanced Berkeley DB features with dbstl</a>
121 <a href="stl_db_advanced_usage.html#idp1232296">Using bulk retrieval iterators</a>
126 <a href="stl_db_advanced_usage.html#idp1232520">Using the DB_RMW flag</a>
131 <a href="stl_db_advanced_usage.html#idp1199288">Using secondary index database and secondary containers</a>
138 <a href="stl_txn_usage.html">Using transactions in dbstl</a>
143 <a href="stl_mt_usage.html">Using dbstl in multithreaded applications</a>
148 <a href="stl_primitive_rw.html">Working with primitive types </a>
155 <a href="stl_primitive_rw.html#idp1288424">Storing strings</a>
162 <a href="stl_complex_rw.html">Store and Retrieve data or objects of complex types </a>
169 <a href="stl_complex_rw.html#idp1279008">Storing varying length objects</a>
174 <a href="stl_complex_rw.html#idp1278616">Storing arbitrary sequences</a>
179 <a href="stl_complex_rw.html#idp1344912">Notes</a>
186 <a href="stl_persistence.html">Dbstl persistence</a>
193 <a href="stl_persistence.html#directdbget">Direct database get</a>
198 <a href="stl_persistence.html#chg_persistence">Change persistence</a>
203 <a href="stl_persistence.html#obj_life_persistence">Object life time and persistence </a>
210 <a href="stl_container_specific.html">Dbstl container specific notes</a>
217 <a href="stl_container_specific.html#idp1313840">db_vector specific notes</a>
222 <a href="stl_container_specific.html#idp1381768">Associative container specific notes</a>
229 <a href="stl_efficienct_use.html">Using dbstl efficiently</a>
236 <a href="stl_efficienct_use.html#idp1350664">Using iterators efficiently</a>
241 <a href="stl_efficienct_use.html#idp1350448">Using containers efficiently</a>
248 <a href="stl_memory_mgmt.html">Dbstl memory management</a>
255 <a href="stl_memory_mgmt.html#idp1384984">Freeing memory</a>
260 <a href="stl_memory_mgmt.html#idp1389512">Type specific notes</a>
267 <a href="stl_misc.html">Dbstl miscellaneous notes</a>
274 <a href="stl_misc.html#idp1407848">Special notes about trivial methods</a>
279 <a href="stl_misc.html#idp1421568">Using correct container and iterator public types</a>
286 <a href="stl_known_issues.html">Dbstl known issues</a>
291 <div class="sect1" lang="en" xml:lang="en">
292 <div class="titlepage">
295 <h2 class="title" style="clear: both"><a id="stl_intro"></a>Dbstl introduction</h2>
303 <a href="stl.html#stl_intro_stdcompat">Standards compatible</a>
308 <a href="stl.html#stl_intro_performance">Performance overhead</a>
313 <a href="stl.html#stl_intro_portability">Portability</a>
319 Dbstl is a C++ STL style API that provides for Berkeley DB usage. It
320 allows for the storage and retrieval of data/objects of any type using
321 Berkeley DB databases, but with an interface that mimics that of C++
322 STL containers. Dbstl provides access to all of the functionality of
323 Berkeley DB available via this STL-style API.
326 With proper configuration, dbstl is able to store/retrieve any complex
327 data types. There is no need to perform repetitive marshalling and
328 unmarshalling of data. Dbstl also properly manages the life-cycle of
329 all Berkeley DB structures and objects. All example methods referred to in this chapter
330 can be found in the StlAdvancedFeaturesExample class in the $DbSrc/examples_stl/StlAdvancedFeatures.cpp file, and you can
331 build the example in $DbSrc/build_unix directory like this:
332 make exstl_advancedfeatures,
333 where DbSrc is the source directory for Berkeley DB.
335 <div class="sect2" lang="en" xml:lang="en">
336 <div class="titlepage">
339 <h3 class="title"><a id="stl_intro_stdcompat"></a>Standards compatible</h3>
344 Dbstl is composed of many container and iterator class templates. These
345 containers and iterators correspond exactly to each container and
346 iterator available in the C++ STL API, including identical sets of
347 methods. This allows existing algorithms, functions and
348 container-adapters for C++ STL to use dbstl containers through its
349 standard iterators. This means that existing STL code can manipulate
350 Berkeley DB databases. As a result, existing C++ STL code can very
351 easily use dbstl to gain persistence and transaction guarantees.
354 <div class="sect2" lang="en" xml:lang="en">
355 <div class="titlepage">
358 <h3 class="title"><a id="stl_intro_performance"></a>Performance overhead</h3>
363 Because dbstl uses C++ template technologies, its performance overhead
367 The dbstl API performs almost equally to the C API, as measured by two
368 different implementations of the TPC-B benchmark:
369 <code class="literal">ex_tpcb</code> and <code class="literal">exstl_tpcb</code>.
372 <div class="sect2" lang="en" xml:lang="en">
373 <div class="titlepage">
376 <h3 class="title"><a id="stl_intro_portability"></a>Portability</h3>
381 The degree to which dbstl is portable to a new platform is determined
382 by whether Berkeley DB is available on the platform, as well as whether
383 an appropriate C++ compiler is available on the platform.
386 For information on porting Berkeley DB to new platforms, see the
387 <em class="citetitle">Berkeley DB Porting Guide</em>.
390 Almost all the advanced C++ template features are used in dbstl, including:
392 <div class="itemizedlist">
396 member function templates
401 member function template overloads
406 partial specialization
411 default template parameters.
417 For this reason, you need a standards-compatible C++ compiler to
418 build dbstl. As of this writing, the following compilers are known
419 to build dbstl successfully:
421 <div class="itemizedlist">
435 Intel C++ 9 and above
441 For *nix platforms, if you can successfully configure your Berkeley
442 DB build script with <code class="literal">--enable-stl</code>, then you
443 should be able to successfully build dbstl library and application
447 Besides its own test suite, dbstl has also been tested against,
448 and passes, the following test suites:
450 <div class="itemizedlist">
467 <div class="navfooter">
469 <table width="100%" summary="Navigation footer">
471 <td width="40%" align="left"><a accesskey="p" href="csharp.html">Prev</a> </td>
472 <td width="20%" align="center"> </td>
473 <td width="40%" align="right"> <a accesskey="n" href="stl_usecase.html">Next</a></td>
476 <td width="40%" align="left" valign="top">Chapter 6. C# API </td>
477 <td width="20%" align="center">
478 <a accesskey="h" href="index.html">Home</a>
480 <td width="40%" align="right" valign="top"> Dbstl typical use cases</td>