Chapter 3. ZOOM-C++

Table of Contents

1. Introduction
2. ZOOM::connection
2.1. References
3. ZOOM::query and subclasses
3.1. ZOOM::prefixQuery
3.2. ZOOM::CCLQuery
3.3. Discussion
3.4. References
4. ZOOM::resultSet
4.1. References
5. ZOOM::record
5.1. Memory Management
5.2. References
6. ZOOM::exception and subclasses
6.1. ZOOM::systemException
6.2. ZOOM::bib1Exception
6.3. ZOOM::queryException
6.4. Revised Sample Program
6.5. References

1. Introduction

ZOOM is the emerging standard API for information retrieval programming using the Z39.50 protocol. ZOOM's Abstract API specifies semantics for classes representing key IR concepts such as connections, queries, result sets and records; and there are various bindings specifying how those concepts should be represented in various programming languages.

The YAZ++ library includes an implementation of the C++ binding for ZOOM, enabling quick, easy development of client applications.

For example, here is a tiny Z39.50 client that fetches and displays the MARC record for Farlow & Brett Surman's The Complete Dinosaur from the Library of Congress's Z39.50 server:

    #include <iostream>
    #include <yazpp/zoom.h>

    using namespace ZOOM;

    int main(int argc, char **argv)
        connection conn("", 210);
        conn.option("databaseName", "LCDB");
        conn.option("preferredRecordSyntax", "USMARC");
        resultSet rs(conn, prefixQuery("@attr 1=7 0253333490"));
        const record *rec = rs.getRecord(0);
        cout << rec->render() << endl;


For the sake of simplicity, this program does not check for errors: we show a more robust version of the same program later.

YAZ++'s implementation of the C++ binding is a thin layer over YAZ's implementation of the C binding. For information on the supported options and other such details, see the ZOOM-C documentation, which can be found on-line at

All of the classes defined by ZOOM-C++ are in the ZOOM namespace. We will now consider the five main classes in turn:

  • connection

  • query and its subclasses prefixQuery and CCLQuery

  • resultSet

  • record

  • exception and its subclasses systemException, bib1Exception and queryException