summaryrefslogtreecommitdiff
path: root/docs/programmer_reference/stl_primitive_rw.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/programmer_reference/stl_primitive_rw.html')
-rw-r--r--docs/programmer_reference/stl_primitive_rw.html202
1 files changed, 112 insertions, 90 deletions
diff --git a/docs/programmer_reference/stl_primitive_rw.html b/docs/programmer_reference/stl_primitive_rw.html
index a17d1d3f..be44c1be 100644
--- a/docs/programmer_reference/stl_primitive_rw.html
+++ b/docs/programmer_reference/stl_primitive_rw.html
@@ -14,7 +14,7 @@
<body>
<div xmlns="" class="navheader">
<div class="libver">
- <p>Library Version 11.2.5.3</p>
+ <p>Library Version 12.1.6.1</p>
</div>
<table width="100%" summary="Navigation header">
<tr>
@@ -40,126 +40,146 @@
<dl>
<dt>
<span class="sect2">
- <a href="stl_primitive_rw.html#idp1288424">Storing strings</a>
+ <a href="stl_primitive_rw.html#idp849056">Storing strings</a>
</span>
</dt>
</dl>
</div>
- <p>
- To store simple primitive types such as <code class="literal">int</code>,
- <code class="literal">long</code>, <code class="literal">double</code>, and so forth, an
- additional type parameter for the container class
- templates is needed. For example, to store an <code class="literal">int</code>
- in a <code class="classname">db_vector</code>, use this container class:
-</p>
+ <p>
+ To store simple primitive types such as
+ <code class="literal">int</code>, <code class="literal">long</code>,
+ <code class="literal">double</code>, and so forth, an additional
+ type parameter for the container class templates is needed.
+ For example, to store an <code class="literal">int</code> in a
+ <code class="classname">db_vector</code>, use this container
+ class:
+ </p>
<pre class="programlisting">db_vector&lt;int, ElementHolder&lt;int&gt; &gt;;</pre>
- <p>
- To map integers to doubles, use this:
-</p>
+ <p>
+ To map integers to doubles, use this:
+ </p>
<pre class="programlisting">db_map&lt;int, double, ElementHolder&lt;double&gt; &gt;;</pre>
- <p>
- To store a <code class="literal">char*</code> string with <code class="literal">long</code> keys,
- use this:
-</p>
+ <p>
+ To store a <code class="literal">char*</code> string with
+ <code class="literal">long</code> keys, use this:
+ </p>
<pre class="programlisting">db_map&lt;long, char*, ElementHolder&lt;char*&gt; &gt;;</pre>
- <p>
- Use this for <code class="literal">const char*</code> strings:
-</p>
+ <p>
+ Use this for <code class="literal">const char*</code> strings:
+ </p>
<pre class="programlisting">db_map&lt;long, const char*, ElementHolder&lt;const char*&gt; &gt;;</pre>
- <p>
- To map one const string to another, use this type:
-</p>
+ <p>
+ To map one const string to another, use this type:
+ </p>
<pre class="programlisting">db_map&lt;const char*, const char*, ElementHolder&lt;const char*&gt; &gt;;</pre>
- <p>
- The <code class="methodname">StlAdvancedFeaturesExample::primitive()</code> method demonstrates more of these examples.
-</p>
+ <p>
+ The
+ <code class="methodname">StlAdvancedFeaturesExample::primitive()</code>
+ method demonstrates more of these examples.
+ </p>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
- <h3 class="title"><a id="idp1288424"></a>Storing strings</h3>
+ <h3 class="title"><a id="idp849056"></a>Storing strings</h3>
</div>
</div>
</div>
<p>
- For <code class="literal">char*</code> and <code class="literal">wchar_t*</code> strings,
- <code class="methodname">_DB_STL_StoreElement()</code> must be called
- following partial or total modifications before iterator movement,
- <code class="literal">container::operator[]</code> or
- <code class="literal">iterator::operator*/-&gt;</code> calls. Without the
- <code class="methodname">_DB_STL_StoreElement()</code> call, the modified
- change will be lost. If storing an new value like this:
-</p>
+ For <code class="literal">char*</code> and
+ <code class="literal">wchar_t*</code> strings,
+ <code class="methodname">_DB_STL_StoreElement()</code> must
+ be called following partial or total modifications before
+ iterator movement,
+ <code class="literal">container::operator[]</code> or
+ <code class="literal">iterator::operator*/-&gt;</code> calls.
+ Without the
+ <code class="methodname">_DB_STL_StoreElement()</code> call,
+ the modified change will be lost. If storing an new value
+ like this:
+ </p>
<pre class="programlisting">*iterator = new_char_star_string;</pre>
<p>
- the call to <code class="methodname">_DB_STL_StoreElement()</code> is not needed.
-</p>
- <p>
- Note that passing a NULL pointer to a container of
- <code class="literal">char*</code> type or passing a
- <code class="classname">std::string</code> with no contents at all will insert
- an empty string of zero length into the database.
-</p>
- <p>
- The string returned from a container will not live beyond the next
- iterator movement call, <code class="literal">container::operator[]</code> or
- <code class="literal">iterator::operator*/-&gt;</code> call.
-</p>
+ the call to
+ <code class="methodname">_DB_STL_StoreElement()</code> is not
+ needed.
+ </p>
+ <p>
+ Note that passing a NULL pointer to a container of
+ <code class="literal">char*</code> type or passing a
+ <code class="classname">std::string</code> with no contents at
+ all will insert an empty string of zero length into the
+ database.
+ </p>
+ <p>
+ The string returned from a container will not live
+ beyond the next iterator movement call,
+ <code class="literal">container::operator[]</code> or
+ <code class="literal">iterator::operator*/-&gt;</code> call.
+ </p>
<p>
-
- A <span class="bold"><strong>db_map::value_type::second_type</strong></span> or
- <span class="bold"><strong>db_map::datatype_wrap</strong></span> should be used
- to hold a reference to a <code class="literal">container::operator[]</code>
- return value. Then the reference should be used for repeated
- references to that value. The *iterator is of type
- <code class="literal">ElementHolder&lt;char *&gt;</code>, which can be automatically converted to a
- <code class="literal">char *</code> pointer using its type conversion operator.
- Wherever an auto conversion is done by the compiler, the conversion
- operator of <code class="literal">ElementHolder&lt;T&gt;</code> is called. This
- avoids almost all explicit conversions, except for two use cases:
-
-</p>
+ A <span class="bold"><strong>db_map::value_type::second_type</strong></span> or
+ <span class="bold"><strong>db_map::datatype_wrap</strong></span>
+ should be used to hold a reference to a
+ <code class="literal">container::operator[]</code> return value.
+ Then the reference should be used for repeated references
+ to that value. The *iterator is of type
+ <code class="literal">ElementHolder&lt;char *&gt;</code>, which
+ can be automatically converted to a <code class="literal">char*</code> pointer
+ using its type conversion
+ operator. Wherever an auto conversion is done by the
+ compiler, the conversion operator of
+ <code class="literal">ElementHolder&lt;T&gt;</code> is called.
+ This avoids almost all explicit conversions, except for
+ two use cases:
+ </p>
<div class="orderedlist">
<ol type="1">
<li>
- <p>
- The *iterator is used as a "..." parameter like this:
- </p>
+ <p>
+ The *iterator is used as a "..." parameter like
+ this:
+ </p>
<pre class="programlisting">printf("this is the special case %s", *iterator);</pre>
- <p>
- This compiles but causes errors. Instead, an explicit cast
- should be used:
- </p>
+ <p>
+ This compiles but causes errors. Instead, an
+ explicit cast should be used:
+ </p>
<pre class="programlisting">printf("this is the special case %s", (char *)*iterator);</pre>
</li>
<li>
<p>
- For some old compilers, such as gcc3.4.6, the *iterator cannot be
- used with the ternary <code class="literal">?</code> operator, like
- this:
- </p>
+ For some old compilers, such as gcc3.4.6, the
+ *iterator cannot be used with the ternary
+ <code class="literal">?</code> operator, like this:
+ </p>
<pre class="programlisting">expr ? *iterator : var</pre>
- <p>
- Even when <span class="bold"><strong>var</strong></span> is the same
- type as the iterator's <code class="literal">value_type</code>, the
- compiler fails to perform an auto conversion.
- </p>
+ <p>
+ Even when <span class="bold"><strong>var</strong></span>
+ is the same type as the iterator's
+ <code class="literal">value_type</code>, the compiler
+ fails to perform an auto conversion.
+ </p>
</li>
</ol>
</div>
<p>
- When using <code class="classname">std::string</code> or
- <code class="classname">std::wstring</code> as the data type for dbstl
- containers — that is, <code class="classname">db_vector&lt;string&gt;</code>,
- and <code class="classname">db_map&lt;string, wstring&gt;</code> — the
- string's content rather than the string object itself is stored in order
- to maintain persistence.
-</p>
- <p>
- You can find example code demonstrating string storage in the
- <code class="methodname">StlAdvancedFeaturesExample::char_star_string_storage()</code> and
- <code class="methodname">StlAdvancedFeaturesExample::storing_std_strings()</code> methods.
-</p>
+ When using <code class="classname">std::string</code> or
+ <code class="classname">std::wstring</code> as the data type
+ for dbstl containers — that is,
+ <code class="classname">db_vector&lt;string&gt;</code>, and
+ <code class="classname">db_map&lt;string, wstring&gt;</code>
+ — the string's content rather than the string object
+ itself is stored in order to maintain persistence.
+ </p>
+ <p>
+ You can find example code demonstrating string storage
+ in the
+ <code class="methodname">StlAdvancedFeaturesExample::char_star_string_storage()</code>
+ and
+ <code class="methodname">StlAdvancedFeaturesExample::storing_std_strings()</code>
+ methods.
+ </p>
</div>
</div>
<div class="navfooter">
@@ -173,11 +193,13 @@
<td width="40%" align="right"> <a accesskey="n" href="stl_complex_rw.html">Next</a></td>
</tr>
<tr>
- <td width="40%" align="left" valign="top">Using dbstl in multithreaded applications </td>
+ <td width="40%" align="left" valign="top">Using dbstl in multithreaded
+ applications </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
- <td width="40%" align="right" valign="top"> Store and Retrieve data or objects of complex types </td>
+ <td width="40%" align="right" valign="top"> Store and Retrieve data or
+ objects of complex types </td>
</tr>
</table>
</div>