// $Id: zoom-1.0a.hh,v 1.1.1.1 2001/10/25 16:15:03 mike Exp $
//
// ZOOM C++ Binding.
// The ZOOM homepage is at http://zoom.z3950.org/
//
// This file is maintained by Ashley Sanders <ashley.sanders@man.ac.uk>

namespace ZOOM {

  enum Z3950_recordSyntax {
    Z3950_recordSyntax_GRS1,
    Z3950_recordSyntax_SUTRS,
    Z3950_recordSyntax_USMARC,
    Z3950_recordSyntax_XML,
  };

  class Z3950 {
  public:
    static const void *option (const char *key);
    static const void *option (const char *key, const void *val);
    static int errcode ();
    static char *errmsg ();
    static char *addinfo ();
  };

  class Z3950_connection {
  public:
    Z3950_connection (const char *hostname, int portnum);
    const void *option (const char *key);
    const void *option (const char *key, const void *val);
    Z3950_resultSet *search (Z3950_search *search);
    int errcode ();
    const char *errmsg ();
    const char *addinfo ();
  };

  class Z3950_search {
    // pure virtual class: derive concrete subclasses from it
  };

  class Z3950_prefix_search: public Z3950_search {
    Z3950_prefix_search (const char *query);
  };

  class Z3950_asimple_search: public Z3950_search {
    Z3950_asimple_search (const char *query);
  };

  // ### Also need CCL search, build-by-hand tree, etc.


  class Z3950_resultSet {
    // No public constructor: these are created by Z3950_connection
  public:
    const void *option (const char *key);
    const void *option (const char *key, const void *val);
    size_t size ();
    Z3950_record *record (size_t i);
    Z3950_record **records (size_t *np);
    int errcode ();
    const char *errmsg ();
    const char *addinfo ();
  };

  class Z3950_record {
    // No public constructor: these are created by Z3950_resultSet
  public:
    Z3950_recordSyntax recsyn () const;
    size_t nfields () const;
    char *field (const char *spec);
    char *render ();
    char *rawdata (size_t *psize);
  };

  class Z3950_error {
    // pure virtual class: derive concrete subclasses from it
  };

  class Z3950_system_error: public Z3950_error {
    const int i;
  public:
    Z3950_system_error (int errcode) : i(errcode) {};
    int errcode () const { return i; };
  };

  class Z3950_bib1_error: public Z3950_error {
    const int i;
    const char *pc;
  public:
    Z3950_bib1_error (int errcode, const char *addinfo) :
      i(errcode), pc(addinfo) {};
    int errcode () const { return i; }
    const char *addinfo () const { return pc; }
  };

}

