File: DbstlElemTraits.html

package info (click to toggle)
db 5.1.29-9%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 150,396 kB
  • sloc: ansic: 400,169; java: 94,399; tcl: 70,967; sh: 37,399; cs: 30,758; cpp: 21,132; perl: 14,227; xml: 9,854; makefile: 3,777; yacc: 1,003; awk: 942; sql: 801; erlang: 461; python: 216; php: 24; asm: 14
file content (380 lines) | stat: -rw-r--r-- 15,223 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?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 class="navheader">
      <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="idp51678936"></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="idp51694440"></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="idp51705704"></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="idp51707032"></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>