1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2011 Index Data and Mike Taylor
3 * See the file LICENSE for details.
10 #include <yaz/pquery.h>
11 #include <yazpp/cql2rpn.h>
13 using namespace yazpp_1;
15 Yaz_cql2rpn::Yaz_cql2rpn()
20 Yaz_cql2rpn::~Yaz_cql2rpn()
23 cql_transform_close(m_transform);
26 void Yaz_cql2rpn::set_pqf_file(const char *fname)
29 m_transform = cql_transform_open_fname(fname);
33 bool Yaz_cql2rpn::parse_spec_file(const char *fname, int *error)
36 cql_transform_close(m_transform);
37 m_transform = cql_transform_open_fname(fname);
38 return m_transform ? true : false;
41 int Yaz_cql2rpn::query_transform(const char *cql_query,
42 Z_RPNQuery **rpnquery, ODR o,
45 const char *addinfo = 0;
48 CQL_parser cp = cql_parser_create();
50 int r = cql_parser_string(cp, cql_query);
58 r = cql_transform_buf(m_transform, cql_parser_result(cp),
59 rpn_buf, sizeof(rpn_buf)-1);
62 YAZ_PQF_Parser pp = yaz_pqf_create();
64 *rpnquery = yaz_pqf_parse(pp, o, rpn_buf);
69 yaz_pqf_error(pp, &pqf_msg, &off);
76 r = cql_transform_error(m_transform, &addinfo);
79 cql_parser_destroy(cp);
81 *addinfop = odr_strdup(o, addinfo);
89 * c-file-style: "Stroustrup"
90 * indent-tabs-mode: nil
92 * vim: shiftwidth=4 tabstop=8 expandtab