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