1 // $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.4 2002-10-09 09:07:10 mike Exp $
6 #include <yaz/yaz-util.h> // for yaz_matchstr()
12 // Must have been clone()d
13 ZOOM_record_destroy(r);
17 // ### Would this operation be better expressed as a copy constructor?
18 record *record::clone() const {
19 // It's tempting just to replace `r' with a clone, and return
20 // `this', but probably more honest to allocate a new C++
23 record *rec = new record(0, 0);
24 if ((rec->r = ZOOM_record_clone(r)) == 0) {
25 // Presumably an out-of-memory error
26 throw systemException();
32 // It's tempting to modify this method just to return either the
33 // string that ZOOM_record_get("syntax") gives us, or the VAL_*
34 // value from Yaz's OID database, but we'd break the nominal
35 // plug-compatibility of competing C++ binding implementations
38 record::syntax record::recsyn() const {
39 const char *syn = ZOOM_record_get(r, "syntax", 0);
41 // These string constants are from yaz/util/oid.c
42 if (!yaz_matchstr(syn, "xml"))
44 else if (!yaz_matchstr(syn, "GRS-1"))
46 else if (!yaz_matchstr(syn, "SUTRS"))
48 else if (!yaz_matchstr(syn, "USmarc"))
50 else if (!yaz_matchstr(syn, "UKmarc"))
52 else if (!yaz_matchstr(syn, "XML") ||
53 !yaz_matchstr(syn, "text-XML") ||
54 !yaz_matchstr(syn, "application-XML"))
60 const char *record::render() const {
62 return ZOOM_record_get(r, "render", &len);
65 const char *record::rawdata() const {
67 return ZOOM_record_get(r, "raw", &len);