0a9fbb3b6657364056f0eb20a81707b92e8397d2
[yazpp-moved-to-github.git] / zoom / master-header
1 // $Id: master-header,v 1.8 2002-11-04 23:12:18 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 YAZ_EXPORT query;
24   class YAZ_EXPORT resultSet;
25   class YAZ_EXPORT 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 YAZ_EXPORT connection {
34 *   ZOOM_connection c;
35 *   friend class resultSet; // so it can use _getYazConnection()
36 *   ZOOM_connection _getYazConnection () const { return c; }
37   public:
38     connection (const char *hostname, int portnum);
39     ~connection ();
40     const char *option (const char *key) const;
41     const char *option (const char *key, const char *val);
42   };
43
44   class query {
45       // pure virtual class: derive concrete subclasses from it.
46 *   friend class resultSet; // so it can use _getYazQuery()
47 *   ZOOM_query _getYazQuery () const { return q; }
48 * protected:
49 *   ZOOM_query q;
50   public:
51     virtual ~query ();
52   };
53
54   class YAZ_EXPORT prefixQuery : public query {
55   public:
56     prefixQuery (const char *pqn);
57     ~prefixQuery ();
58   };
59
60   class YAZ_EXPORT CCLQuery : public query {
61   public:
62     CCLQuery (const char *ccl, void *qualset);
63     ~CCLQuery ();
64   };
65
66   class YAZ_EXPORT 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 YAZ_EXPORT record {
79 *   const resultSet *owner;
80 *   ZOOM_record r;
81 *   friend class resultSet; // so it can use this constructor
82 *   record::record (const resultSet *rs, ZOOM_record rec):
83 *       owner (rs), r (rec) {}
84   public:
85     ~record ();
86     enum syntax {
87       UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML
88     };
89     record *clone () const;
90     syntax recsyn () const;
91     const char *render () const;
92     const char *rawdata () const;
93   };
94
95   class YAZ_EXPORT exception {
96 * protected:
97 *   int code;
98   public:
99     exception (int code);
100     int errcode () const;
101     const char *errmsg () const;
102   };
103
104   class YAZ_EXPORT systemException: public exception {
105   public:
106     systemException ();
107     int errcode () const;
108     const char *errmsg () const;
109   };
110
111   class YAZ_EXPORT bib1Exception: public exception {
112 *   const char *info;
113   public:
114 *   ~bib1Exception ();
115     bib1Exception (int errcode, const char *addinfo);
116     int errcode () const;
117     const char *errmsg () const;
118     const char *addinfo () const;
119   };
120
121   class YAZ_EXPORT queryException: public exception {
122 *   const char *q;
123   public:
124 *   ~queryException ();
125     enum {
126      PREFIX = 1,
127      CCL = 2
128     };
129     queryException (int qtype, const char *source);
130     int errcode () const;
131     const char *errmsg () const;
132     const char *addinfo () const;
133   };
134 }