more work on SRU explain filters
[metaproxy-moved-to-github.git] / src / sru_util.hpp
1 /* $Id: sru_util.hpp,v 1.6 2007-01-07 00:41:18 marc Exp $
2 -   Copyright (c) 2005-2006, Index Data.
3
4    See the LICENSE file for details
5  */
6
7 #ifndef YP2_SDU_UTIL_HPP
8 #define YP2_SDU_UTIL_HPP
9
10 #include "util.hpp"
11 #include "package.hpp"
12
13 //#include <yaz/zgdu.h>
14 //#include <yaz/z-core.h>
15 #include <yaz/srw.h>
16
17 #include <iosfwd>
18 #include <string>
19
20 namespace std 
21 {
22     std::ostream& operator<<(std::ostream& os, Z_SRW_PDU& srw_pdu); 
23
24 }
25
26
27 namespace metaproxy_1 {
28     namespace util  {
29
30         class SRUServerInfo;
31
32         // std::string sru_protocol(const Z_HTTP_Request &http_req);
33         // std::string debug_http(const Z_HTTP_Request &http_req);
34         // void http_response(mp::Package &package, 
35         //                   const std::string &content, 
36         //                   int http_code = 200);
37
38         bool build_sru_debug_package(metaproxy_1::Package &package);
39
40         SRUServerInfo get_sru_server_info(metaproxy_1::Package &package);
41                                           // Z_SRW_explainRequest 
42                                           //const *er_req);
43         
44 //         bool build_simple_explain(metaproxy_1::Package &package, 
45 //                                   metaproxy_1::odr &odr_en,
46 //                                   Z_SRW_PDU *sru_pdu_res,
47 //                                   SRUServerInfo sruinfo,
48 //                                   Z_SRW_explainRequest const *er_req = 0);
49         
50         bool build_sru_explain(metaproxy_1::Package &package, 
51                                metaproxy_1::odr &odr_en,
52                                Z_SRW_PDU *sru_pdu_res,
53                                SRUServerInfo sruinfo,
54                                const xmlNode *explain = 0,
55                                Z_SRW_explainRequest const *er_req = 0);
56         
57         bool build_sru_response(metaproxy_1::Package &package, 
58                                 metaproxy_1::odr &odr_en,
59                                 Z_SOAP *soap,
60                                 const Z_SRW_PDU *sru_pdu_res,
61                                 char *charset,
62                                 const char *stylesheet);        
63         
64         Z_SRW_PDU * decode_sru_request(metaproxy_1::Package &package,   
65                                        metaproxy_1::odr &odr_de,
66                                        metaproxy_1::odr &odr_en,
67                                        Z_SRW_PDU *sru_pdu_res,
68                                        Z_SOAP *&soap,
69                                        char *charset,
70                                        char *stylesheet);
71
72         bool check_sru_query_exists(metaproxy_1::Package &package,
73                                     metaproxy_1::odr &odr_en,
74                                     Z_SRW_PDU *sru_pdu_res,
75                                     Z_SRW_searchRetrieveRequest
76                                     const *sr_req);
77         
78         Z_ElementSetNames * build_esn_from_schema(metaproxy_1::odr &odr_en, 
79                                                   const char *schema);
80
81         class SRUServerInfo
82         {
83         public:
84             SRUServerInfo ()
85                 : database("Default")
86                 {}
87         public:
88             std::string database;
89             std::string host;
90             std::string port;
91         };
92         
93         
94         
95
96 //         class SRU 
97 //         {
98 //         public:
99 //             enum SRU_protocol_type { SRU_NONE, SRU_GET, SRU_POST, SRU_SOAP};
100 //             typedef const int SRU_query_type;
101 //             union SRW_query {char * cql; char * xcql; char * pqf;};
102 //         private:
103 //             //bool decode(const Z_HTTP_Request &http_req);
104 //             SRU_protocol_type protocol(const Z_HTTP_Request &http_req) const;
105 //         private:
106 //             SRU_protocol_type m_protocol;
107 //             std::string m_charset;
108 //             std::string m_stylesheet;            
109 //         };
110     }    
111 }
112
113 #endif
114 /*
115  * Local variables:
116  * c-basic-offset: 4
117  * indent-tabs-mode: nil
118  * c-file-style: "stroustrup"
119  * End:
120  * vim: shiftwidth=4 tabstop=8 expandtab
121  */