1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2010 Index Data and Mike Taylor
3 * See the file LICENSE for details.
7 #include <yaz/pquery.h>
8 #include <yazpp/cql2rpn.h>
10 using namespace yazpp_1;
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);
30 bool Yaz_cql2rpn::parse_spec_file(const char *fname, int *error)
33 cql_transform_close(m_transform);
34 m_transform = cql_transform_open_fname(fname);
35 return m_transform ? true : false;
38 int Yaz_cql2rpn::query_transform(const char *cql_query,
39 Z_RPNQuery **rpnquery, ODR o,
42 const char *addinfo = 0;
45 CQL_parser cp = cql_parser_create();
47 int r = cql_parser_string(cp, cql_query);
55 r = cql_transform_buf(m_transform, cql_parser_result(cp),
56 rpn_buf, sizeof(rpn_buf)-1);
59 YAZ_PQF_Parser pp = yaz_pqf_create();
61 *rpnquery = yaz_pqf_parse(pp, o, rpn_buf);
66 yaz_pqf_error(pp, &pqf_msg, &off);
73 r = cql_transform_error(m_transform, &addinfo);
76 cql_parser_destroy(cp);
78 *addinfop = odr_strdup(o, addinfo);
86 * c-file-style: "Stroustrup"
87 * indent-tabs-mode: nil
89 * vim: shiftwidth=4 tabstop=8 expandtab