From: Adam Dickmeiss Date: Tue, 29 Oct 2013 14:10:25 +0000 (+0100) Subject: Sort conversion in az_cql2rpn::query_transform YPP-9 X-Git-Tag: v1.5.1~1^2 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=5c95dd8965784197cdf753ae5a37dfd7695d8cae;p=yazpp-moved-to-github.git Sort conversion in az_cql2rpn::query_transform YPP-9 --- 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);