2 * Copyright (c) 1998-2001, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-z-query.cpp,v 1.11 2002-10-09 12:50:26 adam Exp $
8 #include <yaz++/z-query.h>
9 #include <yaz/pquery.h>
11 Yaz_Z_Query::Yaz_Z_Query()
13 odr_encode = odr_createmem (ODR_ENCODE);
14 odr_decode = odr_createmem (ODR_DECODE);
15 odr_print = odr_createmem (ODR_PRINT);
18 int Yaz_Z_Query::set_rpn (const char *rpn)
21 odr_reset (odr_encode);
22 Z_Query *query = (Z_Query*) odr_malloc (odr_encode, sizeof(*query));
23 query->which = Z_Query_type_1;
24 query->u.type_1 = p_query_rpn (odr_encode, PROTO_Z3950, rpn);
27 if (!z_Query (odr_encode, &query, 0, 0))
29 // z_Query(odr_print, &query, 0, 0);
30 buf = odr_getbuf (odr_encode, &len, 0);
34 void Yaz_Z_Query::set_Z_Query(Z_Query *z_query)
37 odr_reset (odr_encode);
38 if (!z_Query (odr_encode, &z_query, 0, 0))
40 buf = odr_getbuf (odr_encode, &len, 0);
43 Yaz_Z_Query::~Yaz_Z_Query()
45 odr_destroy (odr_encode);
46 odr_destroy (odr_decode);
47 odr_destroy (odr_print);
50 Z_Query *Yaz_Z_Query::get_Z_Query ()
55 odr_setbuf (odr_decode, buf, len, 0);
56 if (!z_Query(odr_decode, &query, 0, 0))
61 void Yaz_Z_Query::print(char *str, int len)
66 int Yaz_Z_Query::match(Yaz_Z_Query *other)
68 if (len != other->len)
70 if (!buf || !other->buf)
72 if (memcmp(buf, other->buf, len))