X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=zoom%2Fzrs.cpp;h=aa8ae412c95fd220771de25faf2da33989ce6812;hb=a78a33783fe04e47932ad2c4a10e70659b0d15f4;hp=39d042296409ea45dc5c78b3d4f9261f90f3597a;hpb=8e0f7888835eb1a84882b440209ec125ce5856c1;p=yazpp-moved-to-github.git diff --git a/zoom/zrs.cpp b/zoom/zrs.cpp index 39d0422..aa8ae41 100644 --- a/zoom/zrs.cpp +++ b/zoom/zrs.cpp @@ -1,8 +1,8 @@ -// $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.6 2003-09-22 13:04:52 mike Exp $ // Z39.50 Result Set class -#include "zoom++.h" +#include "zoom.h" namespace ZOOM { @@ -14,7 +14,8 @@ namespace ZOOM { const char *addinfo; if ((errcode = ZOOM_connection_error(yazc, &errmsg, &addinfo)) != 0) { - throw bib1Error(errcode, addinfo); + ZOOM_resultset_destroy(rs); + throw bib1Exception(errcode, addinfo); } } @@ -22,38 +23,16 @@ namespace ZOOM { ZOOM_resultset_destroy(rs); } - const char *resultSet::option(const char *key) const { - return ZOOM_resultset_option_get(rs, key); + std::string resultSet::option(const std::string &key) const { + return ZOOM_resultset_option_get(rs, key.c_str()); } - const char *resultSet::option(const char *key, const char *val) { - // ### There may be memory-management issues here. - const char *old = ZOOM_resultset_option_get(rs, key); - ZOOM_resultset_option_set(rs, key, val); - return old; + bool resultSet::option(const std::string &key, const std::string &val) { + ZOOM_resultset_option_set(rs, key.c_str(), val.c_str()); + return true; } size_t resultSet::size() const { return ZOOM_resultset_size(rs); } - - const record *resultSet::getRecord(size_t i) const { - ZOOM_record rec; - if ((rec = ZOOM_resultset_record(rs, i)) == 0) { - const char *errmsg; // unused: carries same info as `errcode' - const char *addinfo; - int errcode = ZOOM_connection_error(owner._getYazConnection(), - &errmsg, &addinfo); - throw bib1Error(errcode, addinfo); - } - - // Memory management is odd here. The ZOOM-C record we've - // just fetched (`rec') is owned by the ZOOM-C result-set we - // fetched it from (`rs'), so all we need to allocate is a - // ZOOM-C++ wrapper for it, which is destroyed at the - // appropriate time -- but the underlying (ZOOM-C) record is - // _not_ destroyed at that time, because it's done when the - // underlying result-set is deleted. - return new record(this, rec); - } }