7.2.1 OID database
From YAZ version 3 and later, the oident system has been replaced by an OID database. OID database is a
misnomer .. the old odient system was also a database.
The OID database is really just a map between named Object Identifiers (string) and their OID raw equivalents.
Most operations either convert from string to OID or other way around.
Unfortunately, whenever we supply a string we must also specify the OID class. The class is necessary
because some strings correspond to multiple OIDs. An example of such a string is Bib-1 which may
either be an attribute-set or a diagnostic-set.
Applications using the YAZ database should include yaz/oid_db.h.
A YAZ database handle is of type yaz_oid_db_t. Actually that’s a pointer. You need not think deal
with that. YAZ has a built-in database which can be considered "constant" for most purposes. We can get
hold that by using function yaz_oid_std.
All functions with prefix yaz_string_to_oid converts from class + string to OID. We have variants
of this operation due to different memory allocation strategies.
All functions with prefix yaz_oid_to_string converts from OID to string + class.
Example 7.16 Create OID with YAZ DB
We can create an OID for the Bib-1 attribute set on the ODR stream odr with:
Odr_oid *bib1 =
yaz_string_to_oid_odr(yaz_oid_std(), CLASS_ATTSET, "Bib-1", odr);
This is more complex than using odr_getoidbystr. You would only use yaz_string_to_oid_-
odr when the string (here Bib-1) is supplied by a user or configuration.
7.2.2 Standard OIDs
All the object identifers in the standard OID database as returned by yaz_oid_std can referenced directly
in a program as a constant OID. Each constant OID is prefixed with yaz_oid_ - followed by OID class
(lowercase) - then by OID name (normalized and lowercase).
See Appendix A for list of all object identifiers built into YAZ. These are declared in yaz/oid_std.h
but are included by yaz/oid_db.h as well.
Example 7.17 Use a built-in OID
We can allocate our own OID filled with the constant OID for Bib-1 with:
Odr_oid *bib1 = odr_oiddup(o, yaz_oid_attset_bib1);
7.3 Nibble
Partager