Changes to master-header to generate an "interface.h" equivalent
[yazpp-moved-to-github.git] / zoom / master-header
1 // $Id: master-header,v 1.11 2002-11-25 13:33:22 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 #include <string>
11
12
13 */*
14 * * This is a bit stupid.  The fact that our ZOOM-C++ implementation is
15 * * based on the ZOOM-C implementation is our Dirty Little Secret, and
16 * * there is in principle no reason why client code need be bothered
17 * * with it.  Except of course that the public class declarations in
18 * * C++ have to lay their private parts out for the world to see
19 * * (oo-er).  Hence the inclusion of <yaz/zoom.h>
20 * */
21 *#include <yaz/zoom.h>
22 *
23 namespace ZOOM {
24   // Forward declarations for type names.
25   class YAZ_EXPORT query;
26   class YAZ_EXPORT resultSet;
27   class YAZ_EXPORT record;
28
29   class YAZ_EXPORT connection {
30 *   ZOOM_connection c;
31 *   friend class resultSet; // so it can use _getYazConnection()
32 *   ZOOM_connection _getYazConnection () const { return c; }
33     // connections are non-copyable.
34     connection (const connection &);
35     connection &operator= (const connection &);
36   public:
37     connection ();
38     connection (const std::string &hostname, int portnum);
39     ~connection ();
40     void connect (const std::string &hostname, int portnum);
41     std::string option (const std::string &key) const;
42     bool option (const std::string &key, const std::string &val);
43   };
44
45   class query {
46       // base class for all query types
47 *   friend class resultSet; // so it can use _getYazQuery()
48 *   ZOOM_query _getYazQuery () const { return q; }
49 * protected:
50 *   ZOOM_query q;
51   public:
52     virtual ~query ();
53   };
54
55   class YAZ_EXPORT prefixQuery : public query {
56   public:
57     prefixQuery (const std::string &pqn);
58     ~prefixQuery ();
59   };
60
61   class YAZ_EXPORT CCLQuery : public query {
62   public:
63     CCLQuery (const std::string &ccl, void *qualset);
64     ~CCLQuery ();
65   };
66
67   class YAZ_EXPORT resultSet {
68 *   connection &owner;
69 *   ZOOM_resultset rs;
70     // resultSets are non-copyable.
71     resultSet (const resultSet &);
72     resultSet &operator= (const resultSet &);
73   public:
74     resultSet (connection &c, const query &q);
75     ~resultSet ();
76     std::string option (const std::string &key) const;
77     bool option (const std::string &key, const std::string &val);
78     size_t size () const;
79   };
80
81   class YAZ_EXPORT record {
82 *   const resultSet *owner;
83 *   ZOOM_record r;
84 *   friend class resultSet; // so it can use this constructor
85 *   record::record (const resultSet *rs, ZOOM_record rec):
86 *       owner (rs), r (rec) {}
87   public:
88     class syntax {
89     public:
90       enum value {
91         UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML
92       };
93       syntax (value rs) : i(rs) {};
94       operator std::string () const;
95       bool operator== (const syntax &s) const;
96       bool operator== (value rs) const;
97       operator value () const;
98     };
99
100     record (resultSet &rs, size_t num);
101     ~record ();
102     syntax recsyn () const;
103     std::string render () const;
104     std::string rawdata () const;
105   };
106
107   // Base exception class; from which all other ZOOM exceptions
108   // are derived. Other classes that use this as their base
109   // class may want to provide their own errcode() and errmsg()
110   // functions -- hence they are made virtual.
111   class YAZ_EXPORT exception {
112 * protected:
113 *   int code;
114   public:
115     exception (int code);
116     virtual ~exception ();
117     virtual int errcode () const;
118     virtual std::string errmsg () const;
119   };
120
121   // systemException could be thrown for timeouts, protocol errors,
122   // network outages.
123   class YAZ_EXPORT systemException : public exception {
124   public:
125     systemException ();         // Uses value of system `errno'
126     systemException (int code);
127   };
128
129   // bib1Exception::errcode() returns a code from the
130   // Bib-1 Diagnostic Set.
131   class YAZ_EXPORT bib1Exception: public exception {
132 *   const char *info;
133   public:
134 *   ~bib1Exception ();
135     bib1Exception (int code, const std::string &addinfo);
136     std::string addinfo () const;
137   };
138
139   class YAZ_EXPORT queryException : public exception {
140 *   const char *q;
141   public:
142 *   ~queryException ();
143     enum { PREFIX, CCL };
144     queryException (int qtype, const std::string &source);
145     std::string addinfo () const;
146   };
147 }