From 64248c6114c42391aa85cf70958707b5acdc3482 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 25 Nov 2002 13:33:22 +0000 Subject: [PATCH] Changes to master-header to generate an "interface.h" equivalent to Ashley's (bar some tweaks to comments, whitespace, etc.) This will become version 1.3b of the ZOOM C++ binding specification. WARNING -- CODE DOES NOT COMPILE since I have not yet updated the implementation to work with the new interface. --- zoom/master-header | 89 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/zoom/master-header b/zoom/master-header index c88bcd8..e8ad2a8 100644 --- a/zoom/master-header +++ b/zoom/master-header @@ -1,4 +1,4 @@ -// $Id: master-header,v 1.10 2002-11-13 11:48:07 mike Exp $ +// $Id: master-header,v 1.11 2002-11-25 13:33:22 mike Exp $ // // ZOOM C++ Binding. // The ZOOM homepage is at http://zoom.z3950.org/ @@ -7,6 +7,8 @@ // http://zoom.z3950.org/bind/cplusplus/zoom-1.0g.hh #include // for size_t +#include + */* * * This is a bit stupid. The fact that our ZOOM-C++ implementation is @@ -24,22 +26,24 @@ namespace ZOOM { class YAZ_EXPORT resultSet; class YAZ_EXPORT record; - const char *option (const char *key); - const char *option (const char *key, const char *val); - class YAZ_EXPORT connection { * ZOOM_connection c; * friend class resultSet; // so it can use _getYazConnection() * ZOOM_connection _getYazConnection () const { return c; } + // connections are non-copyable. + connection (const connection &); + connection &operator= (const connection &); public: - connection (const char *hostname, int portnum); + connection (); + connection (const std::string &hostname, int portnum); ~connection (); - const char *option (const char *key) const; - const char *option (const char *key, const char *val); + void connect (const std::string &hostname, int portnum); + std::string option (const std::string &key) const; + bool option (const std::string &key, const std::string &val); }; class query { - // pure virtual class: derive concrete subclasses from it. + // base class for all query types * friend class resultSet; // so it can use _getYazQuery() * ZOOM_query _getYazQuery () const { return q; } * protected: @@ -50,26 +54,28 @@ namespace ZOOM { class YAZ_EXPORT prefixQuery : public query { public: - prefixQuery (const char *pqn); + prefixQuery (const std::string &pqn); ~prefixQuery (); }; class YAZ_EXPORT CCLQuery : public query { public: - CCLQuery (const char *ccl, void *qualset); + CCLQuery (const std::string &ccl, void *qualset); ~CCLQuery (); }; class YAZ_EXPORT resultSet { * connection &owner; * ZOOM_resultset rs; + // resultSets are non-copyable. + resultSet (const resultSet &); + resultSet &operator= (const resultSet &); public: resultSet (connection &c, const query &q); ~resultSet (); - const char *option (const char *key) const; - const char *option (const char *key, const char *val); + std::string option (const std::string &key) const; + bool option (const std::string &key, const std::string &val); size_t size () const; - const record *getRecord (size_t i) const; }; class YAZ_EXPORT record { @@ -79,50 +85,63 @@ namespace ZOOM { * record::record (const resultSet *rs, ZOOM_record rec): * owner (rs), r (rec) {} public: - ~record (); - enum syntax { - UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML + class syntax { + public: + enum value { + UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML + }; + syntax (value rs) : i(rs) {}; + operator std::string () const; + bool operator== (const syntax &s) const; + bool operator== (value rs) const; + operator value () const; }; - record *clone () const; + + record (resultSet &rs, size_t num); + ~record (); syntax recsyn () const; - const char *render () const; - const char *rawdata () const; + std::string render () const; + std::string rawdata () const; }; + // Base exception class; from which all other ZOOM exceptions + // are derived. Other classes that use this as their base + // class may want to provide their own errcode() and errmsg() + // functions -- hence they are made virtual. class YAZ_EXPORT exception { * protected: * int code; public: exception (int code); - int errcode () const; - const char *errmsg () const; + virtual ~exception (); + virtual int errcode () const; + virtual std::string errmsg () const; }; - class YAZ_EXPORT systemException: public exception { + // systemException could be thrown for timeouts, protocol errors, + // network outages. + class YAZ_EXPORT systemException : public exception { public: - systemException (); - const char *errmsg () const; + systemException (); // Uses value of system `errno' + systemException (int code); }; + // bib1Exception::errcode() returns a code from the + // Bib-1 Diagnostic Set. class YAZ_EXPORT bib1Exception: public exception { * const char *info; public: * ~bib1Exception (); - bib1Exception (int errcode, const char *addinfo); - const char *errmsg () const; - const char *addinfo () const; + bib1Exception (int code, const std::string &addinfo); + std::string addinfo () const; }; - class YAZ_EXPORT queryException: public exception { + class YAZ_EXPORT queryException : public exception { * const char *q; public: * ~queryException (); - enum { - PREFIX = 1, - CCL = 2 - }; - queryException (int qtype, const char *source); - const char *errmsg () const; - const char *addinfo () const; + enum { PREFIX, CCL }; + queryException (int qtype, const std::string &source); + std::string addinfo () const; }; } -- 1.7.10.4