Sudz

Sudz is an implementation of ZOOM for C++. You use this software at your own risk. It comes with no warranty. You might find sudz useful for testing ZOOM, but until I've created a more featured query class you may find it a little limiting. You can however do searches on author, title, subject, publisher, date, document id and "any".

This implementation uses Boost and ZedKit. They can be found at:

This implementation only uses one boost class, shared_ptr, but there's lots of useful/nice stuff in Boost, so download it all anyway if you haven't already got it.

Download

sudz.tar.gz

Hello World!

The ZOOM "hello world" program is as follows:
// Note the deliberate bug. If the query found zero records, then
// trying to print record 0 will most likely cause a core dump!
// In reality, you should check the size of the result set first.

#include <iostream>
#include "zoom.hh"

using namespace ZOOM;

int main ()
{
  connection conn ("z3950.copac.ac.uk", 210);
  conn.option ("databaseName", "copac");
  resultSet rs (conn, simpleQuery ("ti=\"tale of two cities\""));
  std::cout << record (rs, 0).render () << std::endl;
}
Note that record objects are created by passing a resultSet and a record number to the record class constructor. The render function will try and turn a MARC or GRS-1 record into something that is human readable.

Compiling

You'll need to install the software mentioned above and then edit the Makefile to match your installation. When you run make it will try and make a file called libzoom.a and two programs: sudz and hello. Hello takes no arguments -- it is a minimal program to show how lovely the ZOOM api is. Sudz is also very minimal, but tries to do something useful -- see the comments at the start of sudz.cc for the command line arguments it takes (or just run sudz with no arguments.)

Solaris

I've compiled this on a Solaris 8 system using gcc 3.3.2 with ZedKit 2.1.

I failed to get it to compile using the Solaris compiler -- probably due to my own stupidity.

Linux

Compiles okay on Debian Linux 2.2 using a 2.4 kernel with gcc 2.59.2 with ZedKit 2.1 and STLport (as the STL with gcc 2.59.2 is lacking some of the templates needed.) If you are using gcc 3.x then you shouldn't need a spearate STL library.

Mac OS X

Compiles okay under Mac OS X 10.2.1 with gcc 3.1 with ZedKit 3. No need for STLport with this configuration.

When compiling ZedKit, I had to edit z3950_includes.h to remove duplicate definitions of sys_nerr and sys_errlist. Also edited the Makefile to stop it trying to build shared libraries. There are lots of compiler warnings -- but it all seems to work okay.

Windows

I've never tried compiling it on a Windows machine.

Queries

The only query type supported is the simpleQuery class. This takes one argument (a string) which is a list of attribute term pairs, eg:
   simpleQuery ("ti=\"tale of two cities\" au=dickens");
The only attributes recognised are: au, any, bad, date, docid, id, pub, sub, ti, tip. You can see what Bib-1 attributes these translate to by looking in the file query.cc.

Date searches can be for ranges by using attribute/value pairs like: date="1900-", date="1890-1910", etc.

Generally speaking, only boolean AND is supported and then only implicitly. If two attribute/values pairs are specified then a boolean AND is assumed to join them (as in the example for "A tale of two cities" above. A limited form of boolean OR is availble by using the token || within a value, eg:

   sub="railway || railroad"

Phrase searching can also be done if the terms are enclosed withing double quotes, eg:

   simpleQuery ("ti=\"\\\"tale of two cities\\\"\" au=dickens");
I'm afraid the multiple levels of quoting make that look pretty horrible. You can combine phrase searching with keyword searching within the same attribute/value pair, eg:
   simpleQuery ("ti=\"\\\"midland railway\\\" locomotives\"");

You can also combine phrase, keyword and the || token; in this case the || token takes precedence.

Right truncation is specified by use of the asterisk character.

One day I hope to get around to supporting CQL queries.

Result Sets

The resultSet class caches all the records it receives from a target -- which helps cut down on network traffic.

Records

As well as the ZOOM::record class, there is also a sudz::record class. Sudz::record implements the field() function that has been removed from ZOOM. Other than that sudz::record is a ZOOM::record.

Documentation

This is all there is I'm afraid.

Changes

28/10/2003
Fixed the resultSet class to stop it retrieving records multiple times if they are accessed in reverse order.

Surrogate diagnostics should no longer cause an exception. Instead a diagRecord object will be retrieved from the resultSet instead.

Added -r option to the command line of the sudz program to make it display records in reverse order.

Feedback

Please send any feedback regarding this implementation to Ashley Sanders at a.sanders@mcc.ac.uk.

Mike Taylor maintains the ZOOM website at http://zoom.z3950.org and is the driving force behind (and originator of) ZOOM.


Last updated: 9th December, 2003.