7 #include <yaz/yaz-util.h> // for yaz_matchstr()
11 record::syntax::syntax (value rs): val(rs) {}
13 record::syntax::operator std::string() const {
15 case GRS1: return "grs1";
16 case SUTRS: return "sutrs";
17 case USMARC: return "usmarc";
18 case UKMARC: return "ukmarc";
19 case XML: return "xml";
25 bool record::syntax::operator==(const record::syntax &s) const {
29 bool record::syntax::operator==(record::syntax::value rs) const {
33 record::syntax::operator record::syntax::value() const {
38 record::record(resultSet &rs, size_t i): owner(rs) {
39 if ((r = ZOOM_resultset_record(rs._getYazResultSet(), i)) == 0) {
40 const char *errmsg; // unused: carries same info as `errcode'
42 int errcode = ZOOM_connection_error(rs._getYazConnection(),
44 throw bib1Exception(errcode, addinfo);
47 // Memory management is odd here. The ZOOM-C record we've
48 // just fetched (`r') is owned by the ZOOM-C result-set we
49 // fetched it from (`rs.rs'), so the underlying (ZOOM-C)
50 // record is _not_ destroyed when this object is destroyed:
51 // it's done when the underlying result-set is deleted.
55 // Nothing to do -- see comment in constructor
58 // It's tempting to modify this method just to return either the
59 // string that ZOOM_record_get("syntax") gives us, or the VAL_*
60 // value from Yaz's OID database, but we'd break the nominal
61 // plug-compatibility of competing C++ binding implementations
64 record::syntax record::recsyn() const {
65 const char *syn = ZOOM_record_get(r, "syntax", 0);
67 // These string constants are from yaz/util/oid.c
68 if (!yaz_matchstr(syn, "xml"))
70 else if (!yaz_matchstr(syn, "GRS-1"))
72 else if (!yaz_matchstr(syn, "SUTRS"))
74 else if (!yaz_matchstr(syn, "USmarc"))
75 return syntax::USMARC;
76 else if (!yaz_matchstr(syn, "UKmarc"))
77 return syntax::UKMARC;
78 else if (!yaz_matchstr(syn, "XML") ||
79 !yaz_matchstr(syn, "text-XML") ||
80 !yaz_matchstr(syn, "application-XML"))
83 return syntax::UNKNOWN;
86 std::string record::render() const {
88 const char* data = ZOOM_record_get(r, "render", &len);
89 return std::string(data, len);
92 std::string record::rawdata() const {
94 const char* data = ZOOM_record_get(r, "raw", &len);
95 return std::string(data, len);
101 * c-file-style: "Stroustrup"
102 * indent-tabs-mode: nil
104 * vim: shiftwidth=4 tabstop=8 expandtab