From 3c714ed0d987533fedde0747836ac0f30fdd0b11 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 9 Apr 2014 15:24:17 +0200 Subject: [PATCH] allow RPN to CQL conversion with Yaz_cql2rpn class YPP-13 --- include/yazpp/cql2rpn.h | 1 + src/yaz-cql2rpn.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/yazpp/cql2rpn.h b/include/yazpp/cql2rpn.h index 211e3da..6f4d820 100644 --- a/include/yazpp/cql2rpn.h +++ b/include/yazpp/cql2rpn.h @@ -37,6 +37,7 @@ class YAZ_EXPORT Yaz_cql2rpn { bool parse_spec_file(const char *fname, int *error); int query_transform(const char *cql, Z_RPNQuery **rpnquery, ODR o, char **addinfop); + int rpn2cql_transform(Z_RPNQuery *q, WRBUF cql, ODR o, char **addinfop); private: cql_transform_t m_transform; }; diff --git a/src/yaz-cql2rpn.cpp b/src/yaz-cql2rpn.cpp index 7e1900c..d61d34c 100644 --- a/src/yaz-cql2rpn.cpp +++ b/src/yaz-cql2rpn.cpp @@ -11,6 +11,7 @@ #include #include #include +#include using namespace yazpp_1; @@ -40,6 +41,20 @@ bool Yaz_cql2rpn::parse_spec_file(const char *fname, int *error) return m_transform ? true : false; } +int Yaz_cql2rpn::rpn2cql_transform(Z_RPNQuery *q, WRBUF cql, ODR o, + char **addinfop) +{ + int r = cql_transform_rpn2cql_wrbuf(m_transform, cql, q); + *addinfop = 0; + if (r) + { + const char *addinfo = 0; + r = cql_transform_error(m_transform, &addinfo); + *addinfop = odr_strdup_null(o, addinfo); + } + return r; +} + int Yaz_cql2rpn::query_transform(const char *cql_query, Z_RPNQuery **rpnquery, ODR o, char **addinfop) -- 1.7.10.4