|
|
Index Data > YAZ > YAZ User's Guide and Reference > Object Identifiers
The basic YAZ representation of an OID is an array of integers,
terminated with the value -1. This integer is of type
Fundamental OID operations and the type
An OID can either be declared as a automatic variable or it can
allocated using the memory utilities or ODR/NMEM. It's
guaranteed that an OID can fit in Example 7.13. Create OID on stack We can create an OID for the Bib-1 attribute set with:
Odr_oid bib1[OID_SIZE];
bib1[0] = 1;
bib1[1] = 2;
bib1[2] = 840;
bib1[3] = 10003;
bib1[4] = 3;
bib1[5] = 1;
bib1[6] = -1;
And OID may also be filled from a string-based representation using dots (.). This is achieved by function
int oid_dotstring_to_oid(const char *name, Odr_oid *oid);
This functions returns 0 if name could be converted; -1 otherwise. Example 7.14. Using oid_oiddotstring_to_oid We can fill the Bib-1 attribute set OID easier with:
Odr_oid bib1[OID_SIZE];
oid_oiddotstring_to_oid("1.2.840.10003.3.1", bib1);
We can also allocate an OID dynamically on a ODR stream with:
Odr_oid *odr_getoidbystr(ODR o, const char *str);
This creates an OID from string-based representation using dots.
This function take an ODR stream as parameter. This stream is used to
allocate memory for the data elements, which is released on a
subsequent call to Example 7.15. Using odr_getoidbystr We can create a OID for the Bib-1 attribute set with:
Odr_oid *bib1 = odr_getoidbystr(odr, "1.2.840.10003.3.1");
The function
char *oid_oid_to_dotstring(const Odr_oid *oid, char *oidbuf)
does the reverse of
OIDs can be copied with
Odr_oid *odr_oiddup(ODR odr, const Odr_oid *o);
OIDs can be compared with 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
Applications using the YAZ database should include
A YAZ database handle is of type
All functions with prefix
All functions with prefix
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
All the object identifers in the standard OID database as returned
by
See Appendix A, List of Object Identifiers
for list of all object identifiers
built into YAZ.
These are declared in 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);
|
|||
|
|
||||
| Copyright Index Data ApS 2008 | ||||