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.
// 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.
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.)
I failed to get it to compile using the Solaris compiler -- probably due to my own stupidity.
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.
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.
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.
Mike Taylor maintains the ZOOM website at http://zoom.z3950.org and is the driving force behind (and originator of) ZOOM.