Added ZOOM.
[yazpp-moved-to-github.git] / zoom / master-header
1 // $Header: /home/cvsroot/yaz++/zoom/master-header,v 1.1 2002-08-08 13:31:54 mike Exp $
2 //
3 // ZOOM C++ Binding.
4 // The ZOOM homepage is at http://zoom.z3950.org/
5 //
6 // Derived from version 1.0g at
7 //      http://zoom.z3950.org/bind/cplusplus/zoom-1.0g.hh
8
9 #include <stddef.h>             // for size_t
10
11 */*
12 * * This is a bit stupid.  The fact that our ZOOM-C++ implementation is
13 * * based on the ZOOM-C implementation is our Dirty Little Secret, and
14 * * there is in principle no reason why client code need be bothered
15 * * with it.  Except of course that the public class declarations in
16 * * C++ have to lay their private parts out for the world to see
17 * * (oo-er).  Hence the inclusion of <yaz/zoom.h>
18 * */
19 *#include <yaz/zoom.h>
20 *
21 namespace ZOOM {
22   // Forward declarations for type names.
23   class query;
24   class resultSet;
25   class record;
26
27   const char *option (const char *key);
28   const char *option (const char *key, const char *val);
29   int errcode ();
30   char *errmsg ();
31   char *addinfo ();
32
33   class connection {
34 *   ZOOM_connection c;
35   public:
36     connection (const char *hostname, int portnum);
37     // ### I would like to add a ``throw (ZOOM::error)'' clause
38     // here, but it looks like G++ 2.95.2 doesn't recognise it.
39     ~connection ();
40     const char *option (const char *key) const;
41     const char *option (const char *key, const char *val);
42 *   ZOOM_connection _getYazConnection() const { return c; } // package-private
43   };
44
45   class query {
46       // pure virtual class: derive concrete subclasses from it.
47 * protected:
48 *   ZOOM_query q;
49   public:
50     virtual ~query ();
51 *   ZOOM_query _getYazQuery() const { return q; } // package-private
52   };
53
54   class prefixQuery : public query {
55   public:
56     prefixQuery (const char *pqn);
57     ~prefixQuery();
58   };
59
60   class CCLQuery : public query {
61   public:
62     CCLQuery (const char *ccl, void *qualset);
63     ~CCLQuery();
64   };
65
66   class resultSet {
67 *   connection &owner;
68 *   ZOOM_resultset rs;
69   public:
70     resultSet (connection &c, const query &q);
71     ~resultSet ();
72     const char *option (const char *key) const;
73     const char *option (const char *key, const char *val);
74     size_t size () const;
75     const record *getRecord (size_t i) const;
76   };
77
78   class record {
79 *   const resultSet *owner;
80 *   ZOOM_record r;
81   public:
82 *   record::record(const resultSet *rs, ZOOM_record rec):
83 *       owner(rs), r(rec) {}
84     ~record ();
85     enum syntax {
86       UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML
87     };
88     record *clone () const;
89     syntax recsyn () const;
90     const char *render () const;
91     const char *rawdata () const;
92   };
93
94   class error {
95 * protected:
96 *   int code;
97   public:
98     error (int code);
99     int errcode () const;
100     const char *errmsg () const;
101   };
102
103   class systemError: public error {
104   public:
105     systemError ();
106     int errcode () const;
107     const char *errmsg () const;
108   };
109
110   class bib1Error: public error {
111 *   const char *info;
112   public:
113 *   ~bib1Error();
114     bib1Error (int errcode, const char *addinfo);
115     int errcode () const;
116     const char *errmsg () const;
117     const char *addinfo () const;
118   };
119
120   class queryError: public error {
121 *   const char *q;
122   public:
123 *   ~queryError();
124     static const int PREFIX = 1;
125     static const int CCL = 2;
126     queryError (int qtype, const char *source);
127     int errcode () const;
128     const char *errmsg () const;
129     const char *addinfo () const;
130   };
131 }