From 5c95dd8965784197cdf753ae5a37dfd7695d8cae Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 29 Oct 2013 15:10:25 +0100 Subject: [PATCH] Sort conversion in az_cql2rpn::query_transform YPP-9 --- src/yaz-cql2rpn.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/yaz-cql2rpn.cpp b/src/yaz-cql2rpn.cpp index 711d49d..7b67975 100644 --- a/src/yaz-cql2rpn.cpp +++ b/src/yaz-cql2rpn.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include using namespace yazpp_1; @@ -55,13 +56,32 @@ int Yaz_cql2rpn::query_transform(const char *cql_query, } else { - WRBUF w = wrbuf_alloc(); - r = cql_transform(m_transform, cql_parser_result(cp), wrbuf_vp_puts, w); + WRBUF pqf = wrbuf_alloc(); + r = cql_transform(m_transform, cql_parser_result(cp), + wrbuf_vp_puts, pqf); if (!r) { + WRBUF sortkeys = wrbuf_alloc(); + WRBUF sortspec = wrbuf_alloc(); + if (cql_sortby_to_sortkeys(cql_parser_result(cp), + wrbuf_vp_puts, sortkeys)) + { + r = YAZ_SRW_UNSUPP_SORT_TYPE; + } + else + { + yaz_srw_sortkeys_to_sort_spec(wrbuf_cstr(sortkeys), sortspec); + Z_SortKeySpecList *sksl = + yaz_sort_spec(o, wrbuf_cstr(sortspec)); + if (sksl) + yaz_sort_spec_to_type7(sksl, pqf); + } + wrbuf_destroy(sortspec); + wrbuf_destroy(sortkeys); + YAZ_PQF_Parser pp = yaz_pqf_create(); - *rpnquery = yaz_pqf_parse(pp, o, wrbuf_cstr(w)); + *rpnquery = yaz_pqf_parse(pp, o, wrbuf_cstr(pqf)); if (!*rpnquery) { size_t off; @@ -75,7 +95,7 @@ int Yaz_cql2rpn::query_transform(const char *cql_query, { r = cql_transform_error(m_transform, &addinfo); } - wrbuf_destroy(w); + wrbuf_destroy(pqf); } cql_parser_destroy(cp); *addinfop = odr_strdup_null(o, addinfo); -- 1.7.10.4