dbstl is an C++ STL style API for Berkeley DB, based on the C++ API above. With it, you can store data/objects of any type into
or retrieve them from Berkeley DB databases as if you are using C++ STL containers. The full functionality
of Berkeley DB can still be utilized via dbstl with little performance overhead, e.g. you can use all transaction and/or replication functionality of Berkeley DB.
</p>
<p>
dbstl container/iterator class templates reside in header files dbstl_vector.h, dbstl_map.h and dbstl_set.h.
Among them, dbstl_vector.h contains dbstl::db_vector and its iterators;
dbstl_map.h contains dbstl::db_map, dbstl::db_multimap and their iterators; dbstl_set.h contains dbstl::db_set and dbstl::db_multiset and their iterators. You should
include needed header file(s) to use the container/iterator. Note that we don't use the file name with no extention --- To use dbstl::db_vector, you should do this:
And these header files reside in "stl" directory inside Berkeley DB source root directory. If you have installed
Berkeley DB, they are also available in the "include" directory in the directory where Berkeley DB is installed.
</p>
<p>
Apart from the above three header files, you may also need to include db_exception.h and db_utility.h files. The db_exception.h file contains all exception classes of dbstl, which
integrate seamlessly with Berkeley DB C++ API exceptions and C++ standard exception classes in std namespace. And the db_utility.h file contains the DbstlElemTraits which helps you
to store complex objects. These five header files are all that you need to include in order to make use of dbstl.
</p>
<p>
All symbols of dbstl, including classes, class templates, global functions, etc, reside in the namespace "dbstl", so in order to use them, you may also want to do this:
The dbstl library is always at the same place where Berkeley DB library is located, you will need to build it and link with it to use dbstl.
</p>
<p>
While making use of dbstl, you will probably want to create environment or databases directly, or set/get configurations to Berkeley DB environment or databases, etc. You are allowed to do so via Berkeley DB C/C++ API.
<p>Berkeley DB supports the standard UNIX <ahref="../api_reference/C/dbm.html"class="olink">dbm</a> and <ahref="../api_reference/C/hsearch.html"class="olink">hsearch</a> interfaces. After including a new header file and recompiling, programs will run orders of magnitude faster, and underlying databases can grow as large as necessary. Also, historic <ahref="../api_reference/C/dbm.html"class="olink">dbm</a> applications can fail once some number of entries are inserted into the database, in which the number depends on the effectiveness of the internal hashing function on the particular data set. This is not a problem with Berkeley DB.</p>