Table of Contents
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.
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.
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.
Because dbstl uses C++ template technologies, its performance overhead is minimal.
The dbstl API performs almost equally to the C API, as
measured by two different implementations of the TPC-B
benchmark: ex_tpcb
and
exstl_tpcb
.
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.
For information on porting Berkeley DB to new platforms, see the Berkeley DB Porting Guide.
Almost all the advanced C++ template features are used in dbstl, including:
member function templates
member function template overloads
partial specialization
default template parameters.
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:
MSVC8
gcc3.4.4 and above
Intel C++ 9 and above
For *nix platforms, if you can successfully configure
your Berkeley DB build script with
--enable-stl
, then you should be
able to successfully build dbstl library and application
code using it.
Besides its own test suite, dbstl has also been tested against, and passes, the following test suites:
MS STL test suite
SGI STL test suite