Add #include <stddef.h> for size_t
-Add comment about G++'s rejection of throw(ZOOM:error) clause
+Add comment about G++'s rejection of throw(ZOOM:exception) clause
Add destructor declaration to connection class.
Remove the nfields() and field() methods from the record class --
again, see v1.3 of the AAPI.
-Add some substance to the error base class: it can now be created
+Rename the error class to exception, and its subclasses likewise. I
+think that's Telling It Like It Is, and it's certainly more in tune
+with the was v1.3 of the AAPI is going.
+
+Add some substance to the exception base class: it can now be created
(with an error-code specified), and the error-code may be both fetched
and rendered as a human-readable string. This is necessary so that
-it's possible to meaningfully catch(error e).
+it's possible to meaningfully catch(exception e).
-Add the missing char *errmsg() method to the systemError and bib1Error
-classes.
+Add the missing char *errmsg() method to the systemException and
+bib1Exception classes.
-Add a new error subclass, queryError, for reporting malformed query
-strings etc.
+Add a new exception subclass, queryException, for reporting malformed
+query strings etc.
-// $Header: /home/cvsroot/yaz++/zoom/master-header,v 1.1 2002-08-08 13:31:54 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/master-header,v 1.2 2002-08-08 16:06:08 mike Exp $
//
// ZOOM C++ Binding.
// The ZOOM homepage is at http://zoom.z3950.org/
* ZOOM_connection c;
public:
connection (const char *hostname, int portnum);
- // ### I would like to add a ``throw (ZOOM::error)'' clause
+ // ### I would like to add a ``throw (ZOOM::exception)'' clause
// here, but it looks like G++ 2.95.2 doesn't recognise it.
~connection ();
const char *option (const char *key) const;
const char *option (const char *key, const char *val);
-* ZOOM_connection _getYazConnection() const { return c; } // package-private
+* ZOOM_connection _getYazConnection () const { return c; } // package-private
};
class query {
* ZOOM_query q;
public:
virtual ~query ();
-* ZOOM_query _getYazQuery() const { return q; } // package-private
+* ZOOM_query _getYazQuery () const { return q; } // package-private
};
class prefixQuery : public query {
public:
prefixQuery (const char *pqn);
- ~prefixQuery();
+ ~prefixQuery ();
};
class CCLQuery : public query {
public:
CCLQuery (const char *ccl, void *qualset);
- ~CCLQuery();
+ ~CCLQuery ();
};
class resultSet {
* const resultSet *owner;
* ZOOM_record r;
public:
-* record::record(const resultSet *rs, ZOOM_record rec):
-* owner(rs), r(rec) {}
+* record::record (const resultSet *rs, ZOOM_record rec):
+* owner (rs), r (rec) {}
~record ();
enum syntax {
UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML
const char *rawdata () const;
};
- class error {
+ class exception {
* protected:
* int code;
public:
- error (int code);
+ exception (int code);
int errcode () const;
const char *errmsg () const;
};
- class systemError: public error {
+ class systemException: public exception {
public:
- systemError ();
+ systemException ();
int errcode () const;
const char *errmsg () const;
};
- class bib1Error: public error {
+ class bib1Exception: public exception {
* const char *info;
public:
-* ~bib1Error();
- bib1Error (int errcode, const char *addinfo);
+* ~bib1Exception ();
+ bib1Exception (int errcode, const char *addinfo);
int errcode () const;
const char *errmsg () const;
const char *addinfo () const;
};
- class queryError: public error {
+ class queryException: public exception {
* const char *q;
public:
-* ~queryError();
+* ~queryException ();
static const int PREFIX = 1;
static const int CCL = 2;
- queryError (int qtype, const char *source);
+ queryException (int qtype, const char *source);
int errcode () const;
const char *errmsg () const;
const char *addinfo () const;
-// $Header: /home/cvsroot/yaz++/zoom/zclient.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zclient.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $
// Trivial sample client
ZOOM::connection *conn;
try {
conn = new ZOOM::connection(hostname, port);
- } catch(ZOOM::bib1Error err) {
- cerr << argv[0] << ": connect: " <<
+ } catch(ZOOM::bib1Exception err) {
+ cerr << argv[0] << ": connect: bib1Exception " <<
err.errmsg() << " (" << err.addinfo() << ")\n";
return 2;
- } catch(ZOOM::error err) {
- cerr << argv[0] << ": connect: " << err.errmsg() << "\n";
+ } catch(ZOOM::exception err) {
+ cerr << argv[0] << ": connect: exception " <<
+ err.errmsg() << "\n";
return 2;
}
ZOOM::resultSet *rs;
try {
rs = new ZOOM::resultSet(*conn, pq);
- } catch(ZOOM::bib1Error err) {
+ } catch(ZOOM::bib1Exception err) {
cerr << argv[0] << ": searchSpec: " <<
err.errmsg() << " (" << err.addinfo() << ")\n";
return 3;
-// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $
// Z39.50 Connection class
const char *errmsg; // unused: carries same info as `errcode'
const char *addinfo;
if ((errcode = ZOOM_connection_error(c, &errmsg, &addinfo)) != 0) {
- throw bib1Error(errcode, addinfo);
+ throw bib1Exception(errcode, addinfo);
}
}
+++ /dev/null
-// $Header: /home/cvsroot/yaz++/zoom/Attic/zerr.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $
-
-// Z39.50 Error classes
-
-#include <errno.h>
-#include <string.h> // for strerror(), strlen(), strcpy()
-#include <stdio.h> // for sprintf()
-#include <yaz/diagbib1.h>
-#include "zoom++.h"
-
-
-namespace ZOOM {
- error::error(int errcode) {
- code = errcode;
- }
-
- int error::errcode() const {
- return code;
- }
-
- const char *error::errmsg() const {
- static char buf[40];
- sprintf(buf, "error #%d", code);
- return buf;
- }
-
-
-
- systemError::systemError() : error::error(errno){
- code = errno;
- }
-
- int systemError::errcode() const {
- return code;
- }
-
- const char *systemError::errmsg() const {
- return strerror(code);
- }
-
-
-
- bib1Error::bib1Error(int errcode, const char *addinfo) :
- error::error(errcode) {
- info = new char[strlen(addinfo)+1];
- strcpy((char*) info, addinfo);
- }
-
- bib1Error::~bib1Error() {
- delete info;
- }
-
- int bib1Error::errcode() const {
- return code;
- }
-
- const char *bib1Error::errmsg() const {
- return diagbib1_str(code);
- }
-
- const char *bib1Error::addinfo() const {
- return info;
- }
-
-
-
- queryError::queryError(int qtype, const char *source) :
- error::error(qtype) {
- q = new char[strlen(source)+1];
- strcpy((char*) q, source);
- }
-
- queryError::~queryError() {
- delete q;
- }
-
- int queryError::errcode() const {
- return code;
- }
-
- const char *queryError::errmsg() const {
- switch (code) {
- case PREFIX: return "bad prefix search";
- case CCL: return "bad CCL search";
- default: break;
- }
- return "bad search (unknown type)";
- }
-
- const char *queryError::addinfo() const {
- return q;
- }
-}
--- /dev/null
+// $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.1 2002-08-08 16:06:08 mike Exp $
+
+// Z39.50 Exception classes
+
+#include <errno.h>
+#include <string.h> // for strerror(), strlen(), strcpy()
+#include <stdio.h> // for sprintf()
+#include <yaz/diagbib1.h>
+#include "zoom++.h"
+
+
+namespace ZOOM {
+ exception::exception(int errcode) {
+ code = errcode;
+ }
+
+ int exception::errcode() const {
+ return code;
+ }
+
+ const char *exception::errmsg() const {
+ static char buf[40];
+ sprintf(buf, "error #%d", code);
+ return buf;
+ }
+
+
+
+ systemException::systemException() : exception::exception(errno){
+ code = errno;
+ }
+
+ int systemException::errcode() const {
+ return code;
+ }
+
+ const char *systemException::errmsg() const {
+ return strerror(code);
+ }
+
+
+
+ bib1Exception::bib1Exception(int errcode, const char *addinfo) :
+ exception::exception(errcode) {
+ info = new char[strlen(addinfo)+1];
+ strcpy((char*) info, addinfo);
+ }
+
+ bib1Exception::~bib1Exception() {
+ delete info;
+ }
+
+ int bib1Exception::errcode() const {
+ return code;
+ }
+
+ const char *bib1Exception::errmsg() const {
+ return diagbib1_str(code);
+ }
+
+ const char *bib1Exception::addinfo() const {
+ return info;
+ }
+
+
+
+ queryException::queryException(int qtype, const char *source) :
+ exception::exception(qtype) {
+ q = new char[strlen(source)+1];
+ strcpy((char*) q, source);
+ }
+
+ queryException::~queryException() {
+ delete q;
+ }
+
+ int queryException::errcode() const {
+ return code;
+ }
+
+ const char *queryException::errmsg() const {
+ switch (code) {
+ case PREFIX: return "bad prefix search";
+ case CCL: return "bad CCL search";
+ default: break;
+ }
+ return "bad search (unknown type)";
+ }
+
+ const char *queryException::addinfo() const {
+ return q;
+ }
+}
-// $Header: /home/cvsroot/yaz++/zoom/zquery.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zquery.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $
// Z39.50 Query classes
q = ZOOM_query_create();
if (ZOOM_query_prefix(q, pqn) == -1) {
ZOOM_query_destroy(q);
- throw queryError(queryError::PREFIX, pqn);
+ throw queryException(queryException::PREFIX, pqn);
}
}
-// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $
// Z39.50 Record class
record *rec = new record(0, 0);
if ((rec->r = ZOOM_record_clone(r)) == 0) {
// Presumably an out-of-memory error
- throw systemError();
+ throw systemException();
}
return rec;
-// $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.2 2002-08-08 16:06:08 mike Exp $
// Z39.50 Result Set class
const char *addinfo;
if ((errcode = ZOOM_connection_error(yazc, &errmsg, &addinfo)) != 0) {
- throw bib1Error(errcode, addinfo);
+ throw bib1Exception(errcode, addinfo);
}
}
const char *addinfo;
int errcode = ZOOM_connection_error(owner._getYazConnection(),
&errmsg, &addinfo);
- throw bib1Error(errcode, addinfo);
+ throw bib1Exception(errcode, addinfo);
}
// Memory management is odd here. The ZOOM-C record we've