5f19668ed0775b26c86bbf5c693b953138f4c44b
[yazpp-moved-to-github.git] / zoom / zrs.cpp
1 // $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.7 2005-06-25 15:53:21 adam Exp $
2
3 // Z39.50 Result Set class
4
5 #include "zoom.h"
6
7
8 namespace ZOOM {
9     resultSet::resultSet(connection &c, const query &q) : owner(c) {
10         ZOOM_connection yazc = c._getYazConnection();
11         rs = ZOOM_connection_search(yazc, q._getYazQuery());
12         int errcode;
13         const char *errmsg;     // unused: carries same info as `errcode'
14         const char *addinfo;
15
16         if ((errcode = ZOOM_connection_error(yazc, &errmsg, &addinfo)) != 0) {
17             ZOOM_resultset_destroy(rs);
18             throw bib1Exception(errcode, addinfo);
19         }
20     }
21
22     resultSet::~resultSet() {
23         ZOOM_resultset_destroy(rs);
24     }
25
26     std::string resultSet::option(const std::string &key) const {
27         return ZOOM_resultset_option_get(rs, key.c_str());
28     }
29
30     bool resultSet::option(const std::string &key, const std::string &val) {
31       ZOOM_resultset_option_set(rs, key.c_str(), val.c_str());
32         return true;
33     }
34
35     size_t resultSet::size() const {
36         return ZOOM_resultset_size(rs);
37     }
38 }
39 /*
40  * Local variables:
41  * c-basic-offset: 4
42  * c-file-style: "Stroustrup"
43  * indent-tabs-mode: nil
44  * End:
45  * vim: shiftwidth=4 tabstop=8 expandtab
46  */
47