Windows: use Boost 1.59, msvc 14.0
[metaproxy-moved-to-github.git] / src / sru_util.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef YP2_SDU_UTIL_HPP
20 #define YP2_SDU_UTIL_HPP
21
22 #include <metaproxy/util.hpp>
23 #include <metaproxy/package.hpp>
24
25 #include <yaz/srw.h>
26
27 #include <iosfwd>
28 #include <string>
29
30 namespace std
31 {
32     std::ostream& operator<<(std::ostream& os, Z_SRW_PDU& srw_pdu);
33
34 }
35
36
37 namespace metaproxy_1 {
38     namespace util  {
39
40         class SRUServerInfo;
41
42         // std::string sru_protocol(const Z_HTTP_Request &http_req);
43         // std::string debug_http(const Z_HTTP_Request &http_req);
44         // void http_response(mp::Package &package,
45         //                   const std::string &content,
46         //                   int http_code = 200);
47
48         bool build_sru_debug_package(metaproxy_1::Package &package);
49
50         SRUServerInfo get_sru_server_info(metaproxy_1::Package &package);
51                                           // Z_SRW_explainRequest
52                                           //const *er_req);
53
54 //         bool build_simple_explain(metaproxy_1::Package &package,
55 //                                   metaproxy_1::odr &odr_en,
56 //                                   Z_SRW_PDU *sru_pdu_res,
57 //                                   SRUServerInfo sruinfo,
58 //                                   Z_SRW_explainRequest const *er_req = 0);
59
60         bool build_sru_explain(metaproxy_1::Package &package,
61                                metaproxy_1::odr &odr_en,
62                                Z_SRW_PDU *sru_pdu_res,
63                                SRUServerInfo sruinfo,
64                                const xmlNode *explain = 0,
65                                Z_SRW_explainRequest const *er_req = 0);
66
67         bool build_sru_response(metaproxy_1::Package &package,
68                                 metaproxy_1::odr &odr_en,
69                                 Z_SOAP *soap,
70                                 const Z_SRW_PDU *sru_pdu_res,
71                                 char *charset,
72                                 const char *stylesheet);
73
74         Z_SRW_PDU * decode_sru_request(metaproxy_1::Package &package,
75                                        metaproxy_1::odr &odr_de,
76                                        metaproxy_1::odr &odr_en,
77                                        Z_SRW_diagnostic **diagnostic,
78                                        int *num_diagnostic,
79                                        Z_SOAP **soap,
80                                        char *charset);
81
82         bool check_sru_query_exists(metaproxy_1::Package &package,
83                                     metaproxy_1::odr &odr_en,
84                                     Z_SRW_PDU *sru_pdu_res,
85                                     Z_SRW_searchRetrieveRequest
86                                     const *sr_req);
87
88         Z_ElementSetNames * build_esn_from_schema(metaproxy_1::odr &odr_en,
89                                                   const char *schema);
90
91         class SRUServerInfo
92         {
93         public:
94             SRUServerInfo ()
95                 : database("Default")
96                 {}
97         public:
98             std::string database;
99             std::string host;
100             std::string port;
101         };
102
103
104
105
106 //         class SRU
107 //         {
108 //         public:
109 //             enum SRU_protocol_type { SRU_NONE, SRU_GET, SRU_POST, SRU_SOAP};
110 //             typedef const int SRU_query_type;
111 //             union SRW_query {char * cql; char * xcql; char * pqf;};
112 //         private:
113 //             //bool decode(const Z_HTTP_Request &http_req);
114 //             SRU_protocol_type protocol(const Z_HTTP_Request &http_req) const;
115 //         private:
116 //             SRU_protocol_type m_protocol;
117 //             std::string m_charset;
118 //             std::string m_stylesheet;
119 //         };
120     }
121 }
122
123 #endif
124 /*
125  * Local variables:
126  * c-basic-offset: 4
127  * c-file-style: "Stroustrup"
128  * indent-tabs-mode: nil
129  * End:
130  * vim: shiftwidth=4 tabstop=8 expandtab
131  */
132