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>Dbstl miscellaneous notes</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="stl.html" title="Chapter 7. Standard Template Library API" />
11 <link rel="prev" href="stl_memory_mgmt.html" title="Dbstl memory management" />
12 <link rel="next" href="stl_known_issues.html" title="Dbstl known issues" />
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">Dbstl miscellaneous notes</th>
24 <td width="20%" align="left"><a accesskey="p" href="stl_memory_mgmt.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 7. Standard Template Library API</th>
26 <td width="20%" align="right"> <a accesskey="n" href="stl_known_issues.html">Next</a></td>
31 <div class="sect1" lang="en" xml:lang="en">
32 <div class="titlepage">
35 <h2 class="title" style="clear: both"><a id="stl_misc"></a>Dbstl miscellaneous notes</h2>
43 <a href="stl_misc.html#idp1407848">Special notes about trivial methods</a>
48 <a href="stl_misc.html#idp1421568">Using correct container and iterator public types</a>
53 <div class="sect2" lang="en" xml:lang="en">
54 <div class="titlepage">
57 <h3 class="title"><a id="idp1407848"></a>Special notes about trivial methods</h3>
62 There are some standard STL methods which are meaningless in dbstl, but they are kept in
63 dbstl as no-ops so as to stay consistent with the standard. These are:
65 <table class="simplelist" border="0" summary="Simple list">
68 <code class="methodname">db_vecter::reserve();</code>
73 <code class="methodname">db_vector::max_size();</code>
78 <code class="methodname">db_vector::capacity();</code>
83 <code class="methodname">db_map::reserve();</code>
88 <code class="methodname">db_map::max_size();</code>
93 <code class="methodname">db_vector<>::max_size()</code> and
94 <code class="methodname">db_map<>::max_size()</code> both return 2^30. This does not mean
95 that Berkeley DB can only hold that much data. This value is returned to conform to some
96 compilers' overflow rules — if we set bigger numbers like 2^32 or 2^31, some compilers
97 complain that the number has overflowed.
100 See the Berkeley DB documentation for information about limitations on how much data a
104 There are also some read-only functions. You set the configuration
105 for these using the Berkeley DB API. You access them using the container's methods. Again,
106 this is to keep consistent with C++ standard STL containers, such as:
108 <table class="simplelist" border="0" summary="Simple list">
111 <code class="methodname">db_map::key_comp();</code>
116 <code class="methodname">db_map::value_comp();</code>
121 <code class="methodname">db_map::hash_funct();</code>
126 <code class="methodname">db_map::key_eq();</code>
131 <div class="sect2" lang="en" xml:lang="en">
132 <div class="titlepage">
135 <h3 class="title"><a id="idp1421568"></a>Using correct container and iterator public types</h3>
140 All public types defined by the C++ STL specification are present in dbstl. One thing to
141 note is the <span class="bold"><strong>value_type</strong></span>. dbstl defines the <span class="bold"><strong>value_type</strong></span> for each iterator and container class to be the raw
142 type without the <code class="classname">ElementRef</code>/<code class="classname">ElementHolder</code>
143 wrapper, so this type of variable can not be used to store data in a database. There is a
144 <span class="bold"><strong>value_type_wrap</strong></span> type for each container and iterator type,
145 with the raw type wrapped by the
146 <code class="classname">ElementRef</code>/<code class="classname">ElementHolder</code>.
149 For example, when type <code class="literal">int_vector_t</code> is defined as
151 <pre class="programlisting">db_vector<int, ElementHolder<int> ></pre>
153 its <span class="bold"><strong>value_type</strong></span> is <code class="literal">int</code>, its
154 <span class="bold"><strong>value_type_wrap</strong></span> is <code class="literal">ElementHolder<int></code>,
155 and its reference and pointer types are <code class="literal">ElementHolder<int>&</code> and
156 <code class="literal">ElementHolder<int>*</code> respectively. If you need to store data, use
157 <span class="bold"><strong>value_type_wrap</strong></span> to make use of the wrapper to store data
161 The reason we leave <span class="bold"><strong>value_type</strong></span> as the raw type is that we
162 want the existing algorithms in the STL library to work with dbstl because we have seen that
163 without doing so, a few tests will fail.
166 You need to use the same type as the return type of the data element retrieval functions to
167 hold a value in order to properly manipulate the data element. For example, when calling
169 <pre class="programlisting">db_vector<T>::operator[]</pre>
171 check that the return type for this function is
173 <pre class="programlisting">db_vector<T>::datatype_wrap</pre>
175 Then, hold the return value using an object of the same type:
177 <pre class="programlisting">db_vector<T>::datatype_wrap refelem = vctr[3];</pre>
180 <div class="navfooter">
182 <table width="100%" summary="Navigation footer">
184 <td width="40%" align="left"><a accesskey="p" href="stl_memory_mgmt.html">Prev</a> </td>
185 <td width="20%" align="center">
186 <a accesskey="u" href="stl.html">Up</a>
188 <td width="40%" align="right"> <a accesskey="n" href="stl_known_issues.html">Next</a></td>
191 <td width="40%" align="left" valign="top">Dbstl memory management </td>
192 <td width="20%" align="center">
193 <a accesskey="h" href="index.html">Home</a>
195 <td width="40%" align="right" valign="top"> Dbstl known issues</td>