libdb/docs/api_reference/STL/DbstlElemTraits.html
2011-09-13 13:44:24 -04:00

383 lines
15 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chapter 26.  DbstlElemTraits</title>
<link rel="stylesheet" href="apiReference.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB C++ Standard Template Library API Reference" />
<link rel="up" href="index.html" title="Berkeley DB C++ Standard Template Library API Reference" />
<link rel="prev" href="stlDbstlDbtoperator_assign.html" title="operator=" />
<link rel="next" href="stlDbstlElemTraitseq.html" title="eq" />
</head>
<body>
<div xmlns="" class="navheader">
<div class="libver">
<p>Library Version 11.2.5.2</p>
</div>
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">Chapter 26. 
DbstlElemTraits </th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="stlDbstlDbtoperator_assign.html">Prev</a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="stlDbstlElemTraitseq.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="chapter" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a id="DbstlElemTraits"></a>Chapter 26. 
DbstlElemTraits </h2>
</div>
</div>
</div>
<p>This class is used to register callbacks to manipulate an object of a complex type. </p>
<p>These callbacks are used by dbstl at runtime to manipulate the object.</p>
<p>A complex type is a type whose members are not located in a contiguous chunk of memory. For example, the following class A is a complex type because for any instance a of class A, a.b_ points to another object of type B, and dbstl treats the object that a.b_ points to as part of the data of the instance a. Hence, if the user needs to store a.b_ into a dbstl container, the user needs to register an appropriate callback to de-reference and store the object referenced by a.b. Similarly, the user also needs to register callbacks to marshall an array as well as to count the number of elements in such an array.</p>
<p>class A { int m; B *p_; }; class B { int n; };</p>
<p>The user also needs to register callbacks for i). returning an object¡¯s size in bytes; ii). Marshalling and unmarshalling an object; iii). Copying a complex object and and assigning an object to another object of the same type; iv). Element comparison. v). Compare two sequences of any type of objects; Measuring the length of an object sequence and copy an object sequence.</p>
<p>Several elements located in a contiguous chunk of memory form a sequence. An element of a sequence may be a simple object located at a contigous memory chunk, or a complex object, i.e. some of its members may contain references (pointers) to another region of memory. It is not necessary to store a special object to denote the end of the sequence. The callback to traverse the constituent elements of the sequence needs to able to determine the end of the sequence.</p>
<p>Marshalling means packing the object's data members into a contiguous chunk of memory; unmarshalling is the opposite of marshalling. In other words, when you unmarshall an object, its data members are populated with values from a previously marshalled version of the object.</p>
<p>The callbacks need not be set to every type explicitly. . dbstl will check if a needed callback function of this type is provided. If one is available, dbstl will use the registered callback. If the appropriate callback is not provided, dbstl will use reasonable defaults to do the job.</p>
<p>For returning the size of an object, the default behavior is to use the sizeof() operator; For marshalling and unmarshalling, dbstl uses memcpy, so the default behavior is sufficient for simple types whose data reside in a contiguous chunk of memory; Dbstl uses uses &gt;, == and &lt; for comparison operations; For char* and wchar_t * strings, dbstl already provides the appropriate callbacks, so you do not need to register them. In general, if the default behavior is adequate, you don't need to register the corresponding callback.</p>
<p>If you have registered proper callbacks, the DbstlElemTraits&lt;T&gt; can also be used as the char_traits&lt;T&gt; class for std::basic_string&lt;T, char_traits&lt;T&gt; &gt;, and you can enable your class T to form a basic_string&lt;T, DbstlElemTraits&lt;T&gt;&gt;, and use basic_string's functionality and the algorithms to manipulate it. </p>
<h4><a id="id3540699"></a> Public Members </h4>
<div class="informaltable">
<table border="1" width="80%">
<colgroup>
<col />
<col />
</colgroup>
<thead>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="xref" href="DbstlElemTraits.html#stlDbstlElemTraitsassign" title="assign">assign</a>
</td>
<td>
<p>Assignone object to another. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitseq.html" title="eq">eq</a>
</td>
<td>
<p>Check for equality of two objects. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitslt.html" title="lt">lt</a>
</td>
<td>
<p>Less than comparison. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitscompare.html" title="compare">compare</a>
</td>
<td>
<p>Sequence comparison. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitslength.html" title="length">length</a>
</td>
<td>
<p>Returns the number of elements in sequence seq1. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitscopy.html" title="copy">copy</a>
</td>
<td>
<p>Copy first cnt number of elements from seq2 to seq1. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsfind.html" title="find">find</a>
</td>
<td>
<p>Find within the first cnt elements of sequence seq the position of element equal to elem. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsmove.html" title="move">move</a>
</td>
<td>
<p>Sequence movement. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsto_char_type.html" title="to_char_type">to_char_type</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsto_int_type.html" title="to_int_type">to_int_type</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitseq_int_type.html" title="eq_int_type">eq_int_type</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitseof.html" title="eof">eof</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsnot_eof.html" title="not_eof">not_eof</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_restore_function.html" title="set_restore_function">set_restore_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_restore_function.html" title="get_restore_function">get_restore_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_assign_function.html" title="set_assign_function">set_assign_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_assign_function.html" title="get_assign_function">get_assign_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_size_function.html" title="get_size_function">get_size_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_size_function.html" title="set_size_function">set_size_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_copy_function.html" title="get_copy_function">get_copy_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_copy_function.html" title="set_copy_function">set_copy_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_sequence_len_function.html" title="set_sequence_len_function">set_sequence_len_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_sequence_len_function.html" title="get_sequence_len_function">get_sequence_len_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_sequence_copy_function.html" title="get_sequence_copy_function">get_sequence_copy_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_sequence_copy_function.html" title="set_sequence_copy_function">set_sequence_copy_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_compare_function.html" title="set_compare_function">set_compare_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_compare_function.html" title="get_compare_function">get_compare_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_sequence_compare_function.html" title="set_sequence_compare_function">set_sequence_compare_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_sequence_compare_function.html" title="get_sequence_compare_function">get_sequence_compare_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsset_sequence_n_compare_function.html" title="set_sequence_n_compare_function">set_sequence_n_compare_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsget_sequence_n_compare_function.html" title="get_sequence_n_compare_function">get_sequence_n_compare_function</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsinstance.html" title="instance">instance</a>
</td>
<td>
<p>Factory method to create a singeleton instance of this class. </p> </td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsdstr_DbstlElemTraits.html" title="~DbstlElemTraits">~DbstlElemTraits</a>
</td>
<td>
</td>
</tr>
<tr>
<td>
<a class="xref" href="stlDbstlElemTraitsDbstlElemTraits.html" title="DbstlElemTraits">DbstlElemTraits</a>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<h4><a id="id3540286"></a>
Group</h4>
<p>
<a class="xref" href="dbstl_helper_classes.html" title="Chapter 21.  Dbstl Helper Classes">
Dbstl Helper Classes </a>
</p>
<p>
</p>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="stlDbstlElemTraitsassign"></a>assign</h2>
</div>
</div>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="stlDbstlElemTraitsassign_details"></a>Function Details</h3>
</div>
</div>
</div>
<pre class="programlisting">
static void assign(T &amp;left,
const T &amp;right)
</pre>
<p>Assignone object to another. </p>
<pre class="programlisting">
static T* assign(T *seq, size_t cnt,
T elem)
</pre>
<p>Assign first cnt number of elements of sequence seq with the value of elem. </p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3541146"></a>Group: Interface compatible with std::string's char_traits.</h3>
</div>
</div>
</div>
<p>Following are char_traits funcitons, which make this class char_traits compatiable, so that it can be used in std::basic_string template, and be manipulated by the c++ stl algorithms. </p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="id3541169"></a>Class</h3>
</div>
</div>
</div>
<p>
<a class="link" href="DbstlElemTraits.html" title="Chapter 26.  DbstlElemTraits">DbstlElemTraits</a>
</p>
</div>
</div>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="stlDbstlDbtoperator_assign.html">Prev</a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="stlDbstlElemTraitseq.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">operator= </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> eq</td>
</tr>
</table>
</div>
</body>
</html>