2 * Copyright (c) 1998-2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-cql2rpn.cpp,v 1.5 2004-11-30 21:10:30 adam Exp $
9 #include <yaz/pquery.h>
10 #include <yaz++/cql2rpn.h>
12 Yaz_cql2rpn::Yaz_cql2rpn()
17 Yaz_cql2rpn::~Yaz_cql2rpn()
20 cql_transform_close(m_transform);
23 void Yaz_cql2rpn::set_pqf_file(const char *fname)
26 m_transform = cql_transform_open_fname(fname);
29 int Yaz_cql2rpn::query_transform(const char *cql_query,
30 Z_RPNQuery **rpnquery, ODR o,
33 const char *addinfo = 0;
36 CQL_parser cp = cql_parser_create();
38 int r = cql_parser_string(cp, cql_query);
41 yaz_log(YLOG_LOG, "CQL Parse Error");
47 r = cql_transform_buf(m_transform, cql_parser_result(cp),
48 rpn_buf, sizeof(rpn_buf)-1);
51 YAZ_PQF_Parser pp = yaz_pqf_create();
53 *rpnquery = yaz_pqf_parse(pp, o, rpn_buf);
58 int code = yaz_pqf_error(pp, &pqf_msg, &off);
59 yaz_log(YLOG_WARN, "PQF Parser Error %s (code %d)",
67 r = cql_transform_error(m_transform, &addinfo);
68 yaz_log(YLOG_LOG, "CQL Transform Error %d %s", r,
69 addinfo ? addinfo : "");
72 cql_parser_destroy(cp);
74 *addinfop = odr_strdup(o, addinfo);