More work on timeout handling. Work on yaz-client.
[yazpp-moved-to-github.git] / src / yaz-z-query.cpp
1 /*
2  * Copyright (c) 1998-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  * 
6  * $Log: yaz-z-query.cpp,v $
7  * Revision 1.1  1999-03-23 14:17:57  adam
8  * More work on timeout handling. Work on yaz-client.
9  *
10  */
11
12 #include <yaz-z-query.h>
13 #include <pquery.h>
14
15 Yaz_Z_Query::Yaz_Z_Query()
16 {
17     odr_encode = odr_createmem (ODR_ENCODE);
18     odr_decode = odr_createmem (ODR_DECODE);
19 }
20
21 void Yaz_Z_Query::set_rpn (const char *rpn)
22 {
23     buf = 0;
24     odr_reset (odr_encode);
25     Z_Query *query = (Z_Query*) odr_malloc (odr_encode, sizeof(*query));
26     query->which = Z_Query_type_1;
27     query->u.type_1 = p_query_rpn (odr_encode, PROTO_Z3950, rpn);
28     if (!query->u.type_1)
29         return;
30     if (!z_Query (odr_encode, &query, 0))
31         return;
32     buf = odr_getbuf (odr_encode, &len, 0);
33 }
34
35 void Yaz_Z_Query::set_Z_Query(Z_Query *z_query)
36 {
37     buf = 0;
38     odr_reset (odr_encode);
39     if (!z_Query (odr_encode, &z_query, 0))
40         return;
41     buf = odr_getbuf (odr_encode, &len, 0);
42 }
43
44 Yaz_Z_Query::~Yaz_Z_Query()
45 {
46     odr_destroy (odr_encode);
47     odr_destroy (odr_decode);
48 }
49
50 Z_Query *Yaz_Z_Query::get_Z_Query ()
51 {
52     Z_Query *query;
53     if (!buf)
54         return 0;
55     odr_setbuf (odr_decode, buf, len, 0);
56     if (!z_Query(odr_decode, &query, 0))
57         return 0;
58     return query;
59 }
60
61 void Yaz_Z_Query::print(char *str, int len)
62 {
63
64 }