~ubuntu-branches/ubuntu/precise/yazpp/precise

« back to all changes in this revision

Viewing changes to zoom/interface.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Simon
  • Date: 2007-01-22 12:28:56 UTC
  • Revision ID: james.westby@ubuntu.com-20070122122856-b74ahbio5cqcohai
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// $Id: master-header,v 1.17 2003/09/24 18:07:31 adam Exp $
 
2
//
 
3
// ZOOM C++ Binding.
 
4
// The ZOOM homepage is at http://zoom.z3950.org/
 
5
//
 
6
// Derived from version 1.3a at
 
7
//      http://zoom.z3950.org/bind/cplusplus/zoom-1.3a.hh
 
8
 
 
9
#include <stddef.h>             // for size_t
 
10
#include <string>
 
11
 
 
12
 
 
13
namespace ZOOM {
 
14
  // Forward declarations for type names.
 
15
  class query;
 
16
  class resultSet;
 
17
  class record;
 
18
 
 
19
  class connection {
 
20
    // connections are non-copyable.
 
21
    connection (const connection &);
 
22
    connection &operator= (const connection &);
 
23
  public:
 
24
    connection ();
 
25
    connection (const std::string &hostname, int portnum);
 
26
    ~connection ();
 
27
    void connect (const std::string &hostname, int portnum);
 
28
    std::string option (const std::string &key) const;
 
29
    bool option (const std::string &key, const std::string &val);
 
30
  };
 
31
 
 
32
  class query {
 
33
      // base class for all query types
 
34
  public:
 
35
    query ();
 
36
    virtual ~query ();
 
37
  };
 
38
 
 
39
  class prefixQuery : public query {
 
40
  public:
 
41
    prefixQuery (const std::string &pqn);
 
42
    ~prefixQuery ();
 
43
  };
 
44
 
 
45
  class CCLQuery : public query {
 
46
  public:
 
47
    CCLQuery (const std::string &ccl, void *qualset);
 
48
    ~CCLQuery ();
 
49
  };
 
50
 
 
51
  class resultSet {
 
52
    // resultSets are non-copyable.
 
53
    resultSet (const resultSet &);
 
54
    resultSet &operator= (const resultSet &);
 
55
  public:
 
56
    resultSet (connection &c, const query &q);
 
57
    ~resultSet ();
 
58
    std::string option (const std::string &key) const;
 
59
    bool option (const std::string &key, const std::string &val);
 
60
    size_t size () const;
 
61
  };
 
62
 
 
63
  class record {
 
64
  public:
 
65
    class syntax {
 
66
    public:
 
67
      enum value {
 
68
        UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML
 
69
      };
 
70
      syntax (value rs);
 
71
      operator std::string () const;
 
72
      bool operator== (const syntax &s) const;
 
73
      bool operator== (value rs) const;
 
74
      operator value () const;
 
75
    };
 
76
 
 
77
    record (resultSet &rs, size_t num);
 
78
    ~record ();
 
79
    syntax recsyn () const;
 
80
    std::string render () const;
 
81
    std::string rawdata () const;
 
82
  };
 
83
 
 
84
  // Base exception class; from which all other ZOOM exceptions
 
85
  // are derived. Other classes that use this as their base
 
86
  // class may want to provide their own errcode() and errmsg()
 
87
  // functions -- hence they are made virtual.
 
88
  class exception {
 
89
  public:
 
90
    exception (int code);
 
91
    virtual ~exception ();
 
92
    virtual int errcode () const;
 
93
    virtual std::string errmsg () const;
 
94
  };
 
95
 
 
96
  // systemException could be thrown for timeouts, protocol errors,
 
97
  // network outages.
 
98
  class systemException : public exception {
 
99
  public:
 
100
    systemException ();         // Uses value of system `errno'
 
101
    systemException (int code);
 
102
  };
 
103
 
 
104
  // bib1Exception::errcode() returns a code from the
 
105
  // Bib-1 Diagnostic Set.
 
106
  class bib1Exception: public exception {
 
107
  public:
 
108
    bib1Exception (int code, const std::string &addinfo);
 
109
    std::string addinfo () const;
 
110
  };
 
111
 
 
112
  class queryException : public exception {
 
113
  public:
 
114
    enum { PREFIX, CCL };
 
115
    queryException (int qtype, const std::string &source);
 
116
    std::string addinfo () const;
 
117
  };
 
118
}