more work on zeerex explain filter, to be continued
[metaproxy-moved-to-github.git] / src / sru_util.hpp
1 /* $Id: sru_util.hpp,v 1.5 2007-01-05 12:26:50 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         // std::string sru_protocol(const Z_HTTP_Request &http_req);
31         // std::string debug_http(const Z_HTTP_Request &http_req);
32         // void http_response(mp::Package &package, 
33         //                   const std::string &content, 
34         //                   int http_code = 200);
35
36         bool build_sru_debug_package(metaproxy_1::Package &package);
37
38         void get_sru_server_info(metaproxy_1::Package &package, 
39                                  Z_SRW_explainRequest 
40                                  const *er_req);
41         
42         bool build_simple_explain(metaproxy_1::Package &package, 
43                                   metaproxy_1::odr &odr_en,
44                                   Z_SRW_PDU *sru_pdu_res,
45                                   Z_SRW_explainRequest const *er_req);
46         
47         bool build_sru_response(metaproxy_1::Package &package, 
48                                 metaproxy_1::odr &odr_en,
49                                 Z_SOAP *soap,
50                                 const Z_SRW_PDU *sru_pdu_res,
51                                 char *charset,
52                                 const char *stylesheet);        
53         
54         Z_SRW_PDU * decode_sru_request(metaproxy_1::Package &package,   
55                                        metaproxy_1::odr &odr_de,
56                                        metaproxy_1::odr &odr_en,
57                                        Z_SRW_PDU *sru_pdu_res,
58                                        Z_SOAP *&soap,
59                                        char *charset,
60                                        char *stylesheet);
61
62         bool check_sru_query_exists(metaproxy_1::Package &package,
63                                     metaproxy_1::odr &odr_en,
64                                     Z_SRW_PDU *sru_pdu_res,
65                                     Z_SRW_searchRetrieveRequest
66                                     const *sr_req);
67         
68         Z_ElementSetNames * build_esn_from_schema(metaproxy_1::odr &odr_en, 
69                                                   const char *schema);
70
71         class SRUServerInfo
72         {
73         public:
74             SRUServerInfo ()
75                 : database("Default")
76                 {}
77         public:
78             std::string database;
79             std::string host;
80             std::string port;
81         };
82         
83         
84         
85
86 //         class SRU 
87 //         {
88 //         public:
89 //             enum SRU_protocol_type { SRU_NONE, SRU_GET, SRU_POST, SRU_SOAP};
90 //             typedef const int SRU_query_type;
91 //             union SRW_query {char * cql; char * xcql; char * pqf;};
92 //         private:
93 //             //bool decode(const Z_HTTP_Request &http_req);
94 //             SRU_protocol_type protocol(const Z_HTTP_Request &http_req) const;
95 //         private:
96 //             SRU_protocol_type m_protocol;
97 //             std::string m_charset;
98 //             std::string m_stylesheet;            
99 //         };
100     }    
101 }
102
103 #endif
104 /*
105  * Local variables:
106  * c-basic-offset: 4
107  * indent-tabs-mode: nil
108  * c-file-style: "stroustrup"
109  * End:
110  * vim: shiftwidth=4 tabstop=8 expandtab
111  */