~ubuntu-branches/ubuntu/precise/yazpp/precise

« back to all changes in this revision

Viewing changes to doc/zoom-record.html

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Simon
  • Date: 2007-01-22 12:28:56 UTC
  • Revision ID: james.westby@ubuntu.com-20070122122856-b74ahbio5cqcohai
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>ZOOM::record</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REL="HOME"
 
10
TITLE="YAZ++ User's Guide and Reference"
 
11
HREF="yazpp.html"><LINK
 
12
REL="UP"
 
13
TITLE="ZOOM-C++"
 
14
HREF="zoom.html"><LINK
 
15
REL="PREVIOUS"
 
16
TITLE="ZOOM::resultSet"
 
17
HREF="zoom-resultset.html"><LINK
 
18
REL="NEXT"
 
19
TITLE="ZOOM::exception and subclasses"
 
20
HREF="zoom-exception.html"><LINK
 
21
REL="STYLESHEET"
 
22
TYPE="text/css"
 
23
HREF="common/style1.css"></HEAD
 
24
><BODY
 
25
CLASS="sect1"
 
26
BGCOLOR="#FFFFFF"
 
27
TEXT="#000000"
 
28
LINK="#0000FF"
 
29
VLINK="#840084"
 
30
ALINK="#0000FF"
 
31
><DIV
 
32
CLASS="NAVHEADER"
 
33
><TABLE
 
34
SUMMARY="Header navigation table"
 
35
WIDTH="100%"
 
36
BORDER="0"
 
37
CELLPADDING="0"
 
38
CELLSPACING="0"
 
39
><TR
 
40
><TH
 
41
COLSPAN="3"
 
42
ALIGN="center"
 
43
>YAZ++ User's Guide and Reference</TH
 
44
></TR
 
45
><TR
 
46
><TD
 
47
WIDTH="10%"
 
48
ALIGN="left"
 
49
VALIGN="bottom"
 
50
><A
 
51
HREF="zoom-resultset.html"
 
52
ACCESSKEY="P"
 
53
>Prev</A
 
54
></TD
 
55
><TD
 
56
WIDTH="80%"
 
57
ALIGN="center"
 
58
VALIGN="bottom"
 
59
>Chapter 3. ZOOM-C++</TD
 
60
><TD
 
61
WIDTH="10%"
 
62
ALIGN="right"
 
63
VALIGN="bottom"
 
64
><A
 
65
HREF="zoom-exception.html"
 
66
ACCESSKEY="N"
 
67
>Next</A
 
68
></TD
 
69
></TR
 
70
></TABLE
 
71
><HR
 
72
ALIGN="LEFT"
 
73
WIDTH="100%"></DIV
 
74
><DIV
 
75
CLASS="sect1"
 
76
><H1
 
77
CLASS="sect1"
 
78
><A
 
79
NAME="zoom-record"
 
80
><TT
 
81
CLASS="literal"
 
82
>ZOOM::record</TT
 
83
></A
 
84
></H1
 
85
><P
 
86
>&#13;   A <TT
 
87
CLASS="literal"
 
88
>ZOOM::record</TT
 
89
> object represents a chunk of data
 
90
   from a <TT
 
91
CLASS="literal"
 
92
>resultSet</TT
 
93
> returned from a server.
 
94
  </P
 
95
><P
 
96
>&#13;   The class has this declaration:
 
97
  </P
 
98
><PRE
 
99
CLASS="synopsis"
 
100
>&#13;    class record {
 
101
    public:
 
102
      ~record ();
 
103
      enum syntax {
 
104
        UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML
 
105
      };
 
106
      record *clone () const;
 
107
      syntax recsyn () const;
 
108
      const char *render () const;
 
109
      const char *rawdata () const;
 
110
    };
 
111
  </PRE
 
112
><P
 
113
>&#13;   Records returned from Z39.50 servers are encoded using a record
 
114
   syntax: the various national MARC formats are commonly used for
 
115
   bibliographic data, GRS-1 or XML for complex structured data, SUTRS
 
116
   for simple human-readable text, etc.  The
 
117
   <TT
 
118
CLASS="literal"
 
119
>record::syntax</TT
 
120
> enumeration specifies constants
 
121
   representing common record syntaxes, and the
 
122
   <TT
 
123
CLASS="literal"
 
124
>recsyn()</TT
 
125
> method returns the value corresponding
 
126
   to the record-syntax of the record on which it is invoked.
 
127
   <DIV
 
128
CLASS="note"
 
129
><BLOCKQUOTE
 
130
CLASS="note"
 
131
><P
 
132
><B
 
133
>Note: </B
 
134
>
 
135
     Because this interface uses an enumeration, it is difficult to
 
136
     extend to other record syntaxes - for example, DANMARC, the MARC
 
137
     variant widely used in Denmark.  We might either grow the
 
138
     enumeration substantially, or change the interface to return
 
139
     either an integer or a string.
 
140
    </P
 
141
></BLOCKQUOTE
 
142
></DIV
 
143
>
 
144
  </P
 
145
><P
 
146
>&#13;   The simplest thing to do with a retrieved record is simply to
 
147
   <TT
 
148
CLASS="literal"
 
149
>render()</TT
 
150
> it.  This returns a human-readable, but
 
151
   not necessarily very pretty, representation of the contents of the
 
152
   record.  This is useful primarily for testing and debugging, since
 
153
   the application has no control over how the record appears.
 
154
   (The application must <SPAN
 
155
CLASS="emphasis"
 
156
><I
 
157
CLASS="emphasis"
 
158
>not</I
 
159
></SPAN
 
160
>
 
161
   <TT
 
162
CLASS="literal"
 
163
>delete</TT
 
164
> the returned string - it is ``owned'' by
 
165
   the record object.)
 
166
  </P
 
167
><P
 
168
>&#13;   More sophisticated applications will want to deal with the raw data
 
169
   themselves: the <TT
 
170
CLASS="literal"
 
171
>rawdata()</TT
 
172
> method returns it.
 
173
   Its format will vary depending on the record syntax: SUTRS, MARC
 
174
   and XML records are returned ``as is'', and GRS-1 records as a
 
175
   pointer to their top-level node, which is a
 
176
   <TT
 
177
CLASS="literal"
 
178
>Z_GenericRecord</TT
 
179
> structure as defined in the
 
180
   <TT
 
181
CLASS="literal"
 
182
>&#60;yaz/z-grs.h&#62;</TT
 
183
> header file.
 
184
   (The application must <SPAN
 
185
CLASS="emphasis"
 
186
><I
 
187
CLASS="emphasis"
 
188
>not</I
 
189
></SPAN
 
190
>
 
191
   <TT
 
192
CLASS="literal"
 
193
>delete</TT
 
194
> the returned data - it is ``owned'' by
 
195
   the record object.)
 
196
  </P
 
197
><P
 
198
>&#13;   Perceptive readers will notice that there are no methods for access
 
199
   to individual fields within a record.  That's because the different
 
200
   record syntaxes are so different that there is no even a uniform
 
201
   notion of what a field is across them all, let alone a sensible way
 
202
   to implement such a function.  Fetch the raw data instead, and pick
 
203
   it apart ``by hand''.
 
204
  </P
 
205
><DIV
 
206
CLASS="sect2"
 
207
><H2
 
208
CLASS="sect2"
 
209
><A
 
210
NAME="AEN352"
 
211
>Memory Management</A
 
212
></H2
 
213
><P
 
214
>&#13;    The <TT
 
215
CLASS="literal"
 
216
>record</TT
 
217
> objects returned from
 
218
    <TT
 
219
CLASS="literal"
 
220
>resultSet::getRecord()</TT
 
221
> are ``owned'' by the
 
222
    result set object: that means that the application is not
 
223
    responsible for <TT
 
224
CLASS="literal"
 
225
>delete</TT
 
226
>ing them - each
 
227
    <TT
 
228
CLASS="literal"
 
229
>record</TT
 
230
> is automatically deallocated when the
 
231
    <TT
 
232
CLASS="literal"
 
233
>resultSet</TT
 
234
> that owns it is
 
235
    <TT
 
236
CLASS="literal"
 
237
>delete</TT
 
238
>d.
 
239
   </P
 
240
><P
 
241
>&#13;    Usually that's what you want: it means that you can easily fetch a
 
242
    record, use it and forget all about it, like this:
 
243
   </P
 
244
><PRE
 
245
CLASS="programlisting"
 
246
>&#13;    resultSet rs(conn, query);
 
247
    cout &#60;&#60; rs.getRecord(0)-&#62;render();
 
248
   </PRE
 
249
><P
 
250
>&#13;    But sometimes you want a <TT
 
251
CLASS="literal"
 
252
>record</TT
 
253
> to live on past
 
254
    the lifetime of the <TT
 
255
CLASS="literal"
 
256
>resultSet</TT
 
257
> from which it was
 
258
    fetched.  In this case, the <TT
 
259
CLASS="literal"
 
260
>clone(f)</TT
 
261
> method can
 
262
    be used to make an autonomous copy.  The application must
 
263
    <TT
 
264
CLASS="literal"
 
265
>delete</TT
 
266
> it when it doesn't need it any longer:
 
267
   </P
 
268
><PRE
 
269
CLASS="programlisting"
 
270
>&#13;    record *rec;
 
271
    {
 
272
        resultSet rs(conn, query);
 
273
        rec = rs.getRecord(0)-&#62;clone();
 
274
        // `rs' goes out of scope here, and is deleted
 
275
    }
 
276
    cout &#60;&#60; rec-&#62;render();
 
277
    delete rec;
 
278
   </PRE
 
279
></DIV
 
280
><DIV
 
281
CLASS="sect2"
 
282
><H2
 
283
CLASS="sect2"
 
284
><A
 
285
NAME="AEN369"
 
286
>References</A
 
287
></H2
 
288
><P
 
289
></P
 
290
><UL
 
291
><LI
 
292
><P
 
293
>&#13;      <A
 
294
HREF="http://zoom.z3950.org/api/zoom-1.3.html#3.5"
 
295
TARGET="_top"
 
296
>Section 3.5 (Record) of the ZOOM Abstract API</A
 
297
>
 
298
     </P
 
299
></LI
 
300
><LI
 
301
><P
 
302
>&#13;      <A
 
303
HREF="http://www.indexdata.dk/yaz/doc/zoom.records.tkl"
 
304
TARGET="_top"
 
305
>The Records section of the ZOOM-C documentation</A
 
306
>
 
307
     </P
 
308
></LI
 
309
></UL
 
310
></DIV
 
311
></DIV
 
312
><DIV
 
313
CLASS="NAVFOOTER"
 
314
><HR
 
315
ALIGN="LEFT"
 
316
WIDTH="100%"><TABLE
 
317
SUMMARY="Footer navigation table"
 
318
WIDTH="100%"
 
319
BORDER="0"
 
320
CELLPADDING="0"
 
321
CELLSPACING="0"
 
322
><TR
 
323
><TD
 
324
WIDTH="33%"
 
325
ALIGN="left"
 
326
VALIGN="top"
 
327
><A
 
328
HREF="zoom-resultset.html"
 
329
ACCESSKEY="P"
 
330
>Prev</A
 
331
></TD
 
332
><TD
 
333
WIDTH="34%"
 
334
ALIGN="center"
 
335
VALIGN="top"
 
336
><A
 
337
HREF="yazpp.html"
 
338
ACCESSKEY="H"
 
339
>Home</A
 
340
></TD
 
341
><TD
 
342
WIDTH="33%"
 
343
ALIGN="right"
 
344
VALIGN="top"
 
345
><A
 
346
HREF="zoom-exception.html"
 
347
ACCESSKEY="N"
 
348
>Next</A
 
349
></TD
 
350
></TR
 
351
><TR
 
352
><TD
 
353
WIDTH="33%"
 
354
ALIGN="left"
 
355
VALIGN="top"
 
356
><TT
 
357
CLASS="literal"
 
358
>ZOOM::resultSet</TT
 
359
></TD
 
360
><TD
 
361
WIDTH="34%"
 
362
ALIGN="center"
 
363
VALIGN="top"
 
364
><A
 
365
HREF="zoom.html"
 
366
ACCESSKEY="U"
 
367
>Up</A
 
368
></TD
 
369
><TD
 
370
WIDTH="33%"
 
371
ALIGN="right"
 
372
VALIGN="top"
 
373
><TT
 
374
CLASS="literal"
 
375
>ZOOM::exception</TT
 
376
> and subclasses</TD
 
377
></TR
 
378
></TABLE
 
379
></DIV
 
380
></BODY
 
381
></HTML
 
382
>
 
 
b'\\ No newline at end of file'