X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Futil.cpp;h=4570c31cd6a21348f4ce3aeb97159e58224203db;hb=f47e8cf4cde2ba5465106e219c803e6424a4f177;hp=c8cf573b81248f97cb8d22aadc49962a4a46e1e7;hpb=1751782d8e3c9d4574754463ffd43373cf92133a;p=metaproxy-moved-to-github.git diff --git a/src/util.cpp b/src/util.cpp index c8cf573..4570c31 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,4 +1,4 @@ -/* $Id: util.cpp,v 1.12 2006-01-19 21:43:51 adam Exp $ +/* $Id: util.cpp,v 1.13 2006-01-20 22:38:12 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -9,8 +9,11 @@ #include #include #include +#include // for yaz_query_to_wrbuf() #include "util.hpp" +//#include + void yp2::util::piggyback(int smallSetUpperBound, int largeSetLowerBound, int mediumSetPresentNumber, @@ -38,6 +41,7 @@ void yp2::util::piggyback(int smallSetUpperBound, } } + bool yp2::util::pqf(ODR odr, Z_APDU *apdu, const std::string &q) { YAZ_PQF_Parser pqf_parser = yaz_pqf_create(); @@ -56,6 +60,49 @@ bool yp2::util::pqf(ODR odr, Z_APDU *apdu, const std::string &q) { return true; } + +std::string yp2::util::zQueryToString(Z_Query *query) +{ + std::string query_str = ""; + + if (query && query->which == Z_Query_type_1){ + Z_RPNQuery *rpn = query->u.type_1; + + if (rpn){ + + // allocate wrbuf (strings in YAZ!) + WRBUF w = wrbuf_alloc(); + + // put query in w + yaz_rpnquery_to_wrbuf(w, rpn); + + // from w to std::string + query_str = std::string(wrbuf_buf(w), wrbuf_len(w)); + + // destroy wrbuf + wrbuf_free(w, 1); + } + } + +#if 0 + if (query && query->which == Z_Query_type_1){ + + // allocate wrbuf (strings in YAZ!) + WRBUF w = wrbuf_alloc(); + + // put query in w + yaz_query_to_wrbuf(w, query); + + // from w to std::string + query_str = std::string(wrbuf_buf(w), wrbuf_len(w)); + + // destroy wrbuf + wrbuf_free(w, 1); + } +#endif + return query_str; +} + void yp2::util::get_default_diag(Z_DefaultDiagFormat *r, int &error_code, std::string &addinfo) {