-// $Id: master-header,v 1.13 2002-12-02 15:55:57 mike Exp $
+// $Id: master-header,v 1.14 2003-07-02 10:25:13 adam Exp $
//
// ZOOM C++ Binding.
// The ZOOM homepage is at http://zoom.z3950.org/
// bib1Exception::errcode() returns a code from the
// Bib-1 Diagnostic Set.
class YAZ_EXPORT bib1Exception: public exception {
-* const string &info;
+* const std::string &info;
public:
* ~bib1Exception ();
bib1Exception (int code, const std::string &addinfo);
};
class YAZ_EXPORT queryException : public exception {
-* const string &q;
+* const std::string &q;
public:
* ~queryException ();
enum { PREFIX, CCL };
-// $Id: zclient.cpp,v 1.6 2002-12-02 15:57:58 mike Exp $
+// $Id: zclient.cpp,v 1.7 2003-07-02 10:25:13 adam Exp $
// Simple sample client
#include <stdlib.h> // for atoi()
-#include <iostream.h>
+#include <iostream>
#include "zoom.h"
int main(int argc, char **argv)
{
if (argc != 5) {
- cerr << "Usage: " <<
+ std::cerr << "Usage: " <<
argv[0] << " <host> <port> <dbname> <@prefix-search>\n";
return 1;
}
resultSet rs(conn, pq);
size_t n = rs.size();
- cout << "found " << n << " records:\n";
+ std::cout << "found " << n << " records:\n";
for (size_t i = 0; i < n; i++) {
const record rec(rs, i);
- cout << "=== record " << i+1 <<
- " (record-syntax " << (string) rec.recsyn() << ")" <<
+ std::cout << "=== record " << i+1 <<
+ " (record-syntax " << (std::string) rec.recsyn() << ")" <<
" ===\n" << rec.render();
}
} catch(bib1Exception& err) {
- cerr << argv[0] << ": bib1Exception " <<
+ std::cerr << argv[0] << ": bib1Exception " <<
err.errmsg() << " (" << err.addinfo() << ")\n";
return 2;
} catch(ZOOM::exception& err) {
- cerr << argv[0] << ": exception " <<
+ std::cerr << argv[0] << ": exception " <<
err.errmsg() << "\n";
return 3;
}
-// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.4 2002-11-30 22:33:21 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.5 2003-07-02 10:25:13 adam Exp $
// Z39.50 Connection class
namespace ZOOM {
- connection::connection(const string &hostname, int portnum) {
+ connection::connection(const std::string &hostname, int portnum) {
const char *line_printer_size_hostname = hostname.c_str();
//###cerr << "opening " << hostname << ":" << portnum << "\n";
c = ZOOM_connection_new(line_printer_size_hostname, portnum);
}
}
- string connection::option(const string &key) const {
+ std::string connection::option(const std::string &key) const {
return ZOOM_connection_option_get(c, key.c_str());
}
- bool connection::option(const string &key, const string &val) {
+ bool connection::option(const std::string &key, const std::string &val) {
// No way to tell whether ZOOM_connection_option_set() accepts key
ZOOM_connection_option_set(c, key.c_str(), val.c_str());
return true;
-// $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.7 2002-11-30 22:33:21 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.8 2003-07-02 10:25:13 adam Exp $
// Z39.50 Exception classes
+#include <iostream>
#include <errno.h>
#include <string.h> // for strerror(), strlen(), strcpy()
-#include <stdio.h> // for sprintf()
#include "zoom.h"
return code;
}
- string exception::errmsg() const {
+ std::string exception::errmsg() const {
static char buf[40];
sprintf(buf, "error #%d", code);
return buf;
code = errno;
}
- string systemException::errmsg() const {
+ std::string systemException::errmsg() const {
return strerror(code);
}
- bib1Exception::bib1Exception(int errcode, const string &addinfo) :
+ bib1Exception::bib1Exception(int errcode, const std::string &addinfo) :
exception(errcode), info(addinfo) {
- cerr << "WARNING: made bib1Exception(" << errcode << "=" <<
+ std::cerr << "WARNING: made bib1Exception(" << errcode << "=" <<
ZOOM_diag_str(errcode) << ", '" << addinfo << "')\n";
}
// or less work -- it just leaks memory. (Or does it?)
}
- string bib1Exception::errmsg() const {
+ std::string bib1Exception::errmsg() const {
return ZOOM_diag_str(code);
}
- string bib1Exception::addinfo() const {
+ std::string bib1Exception::addinfo() const {
return info;
}
- queryException::queryException(int qtype, const string &source) :
+ queryException::queryException(int qtype, const std::string &source) :
exception(qtype), q(source) {}
queryException::~queryException() {
//delete q; // ### see comment on bib1Exception destructor
}
- string queryException::errmsg() const {
+ std::string queryException::errmsg() const {
switch (code) {
case PREFIX: return "bad prefix search";
case CCL: return "bad CCL search";
return "bad search (unknown type)";
}
- string queryException::addinfo() const {
+ std::string queryException::addinfo() const {
return q;
}
}
-// $Header: /home/cvsroot/yaz++/zoom/zquery.cpp,v 1.4 2002-11-30 22:33:21 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zquery.cpp,v 1.5 2003-07-02 10:25:13 adam Exp $
// Z39.50 Query classes
q = 0;
}
-
-
- prefixQuery::prefixQuery(const string &pqn) {
+ prefixQuery::prefixQuery(const std::string &pqn) {
q = ZOOM_query_create();
if (ZOOM_query_prefix(q, pqn.c_str()) == -1) {
ZOOM_query_destroy(q);
- CCLQuery::CCLQuery(const string &ccl, void *qualset) {
+ CCLQuery::CCLQuery(const std::string &ccl, void *qualset) {
throw "Oops. No CCL support in ZOOM-C yet. Sorry.";
}
-// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.5 2002-11-30 22:33:21 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.6 2003-07-02 10:25:13 adam Exp $
// Z39.50 Record class
namespace ZOOM {
record::syntax::syntax (value rs): val(rs) {}
- record::syntax::operator string() const {
+ record::syntax::operator std::string() const {
switch (val) {
case GRS1: return "grs1";
case SUTRS: return "sutrs";
return syntax::UNKNOWN;
}
- string record::render() const {
+ std::string record::render() const {
int len;
return ZOOM_record_get(r, "render", &len);
}
- string record::rawdata() const {
+ std::string record::rawdata() const {
int len;
return ZOOM_record_get(r, "raw", &len);
}
-// $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.4 2002-11-30 22:33:21 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.5 2003-07-02 10:25:13 adam Exp $
// Z39.50 Result Set class
ZOOM_resultset_destroy(rs);
}
- string resultSet::option(const string &key) const {
+ std::string resultSet::option(const std::string &key) const {
return ZOOM_resultset_option_get(rs, key.c_str());
}
- bool resultSet::option(const string &key, const string &val) {
+ bool resultSet::option(const std::string &key, const std::string &val) {
ZOOM_resultset_option_set(rs, key.c_str(), val.c_str());
return true;
}