4 #include <yaz/yaz-util.h> // for yaz_matchstr()
8 record::syntax::syntax (value rs): val(rs) {}
10 record::syntax::operator std::string() const {
12 case GRS1: return "grs1";
13 case SUTRS: return "sutrs";
14 case USMARC: return "usmarc";
15 case UKMARC: return "ukmarc";
16 case XML: return "xml";
22 bool record::syntax::operator==(const record::syntax &s) const {
26 bool record::syntax::operator==(record::syntax::value rs) const {
30 record::syntax::operator record::syntax::value() const {
35 record::record(resultSet &rs, size_t i): owner(rs) {
36 if ((r = ZOOM_resultset_record(rs._getYazResultSet(), i)) == 0) {
37 const char *errmsg; // unused: carries same info as `errcode'
39 int errcode = ZOOM_connection_error(rs._getYazConnection(),
41 throw bib1Exception(errcode, addinfo);
44 // Memory management is odd here. The ZOOM-C record we've
45 // just fetched (`r') is owned by the ZOOM-C result-set we
46 // fetched it from (`rs.rs'), so the underlying (ZOOM-C)
47 // record is _not_ destroyed when this object is destroyed:
48 // it's done when the underlying result-set is deleted.
52 // Nothing to do -- see comment in constructor
55 // It's tempting to modify this method just to return either the
56 // string that ZOOM_record_get("syntax") gives us, or the VAL_*
57 // value from Yaz's OID database, but we'd break the nominal
58 // plug-compatibility of competing C++ binding implementations
61 record::syntax record::recsyn() const {
62 const char *syn = ZOOM_record_get(r, "syntax", 0);
64 // These string constants are from yaz/util/oid.c
65 if (!yaz_matchstr(syn, "xml"))
67 else if (!yaz_matchstr(syn, "GRS-1"))
69 else if (!yaz_matchstr(syn, "SUTRS"))
71 else if (!yaz_matchstr(syn, "USmarc"))
72 return syntax::USMARC;
73 else if (!yaz_matchstr(syn, "UKmarc"))
74 return syntax::UKMARC;
75 else if (!yaz_matchstr(syn, "XML") ||
76 !yaz_matchstr(syn, "text-XML") ||
77 !yaz_matchstr(syn, "application-XML"))
80 return syntax::UNKNOWN;
83 std::string record::render() const {
85 const char* data = ZOOM_record_get(r, "render", &len);
86 return std::string(data, len);
89 std::string record::rawdata() const {
91 const char* data = ZOOM_record_get(r, "raw", &len);
92 return std::string(data, len);
98 * c-file-style: "Stroustrup"
99 * indent-tabs-mode: nil
101 * vim: shiftwidth=4 tabstop=8 expandtab