|
14 | 14 | #defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 |
15 | 15 |
|
16 | 16 | #include<boost/network/traits/string.hpp> |
17 | | -#include<boost/fusion/adapted/struct/adapt_struct.hpp> |
18 | 17 | #include<boost/fusion/include/adapt_struct.hpp> |
19 | 18 | #include<boost/assign/list_of.hpp> |
| 19 | +#include<boost/network/support/is_default_wstring.hpp> |
| 20 | +#include<boost/network/support/is_default_wstring.hpp> |
20 | 21 |
|
21 | 22 | namespaceboost {namespacenetwork {namespacehttp { |
22 | 23 |
|
23 | 24 | template<classTag> |
24 | | -structrequest_header |
25 | | - { |
26 | | -typedef Tag tag; |
27 | | -typedeftypename string<Tag>::type string_type; |
28 | | - string_type name, value; |
| 25 | +structunsupported_tag; |
| 26 | + |
| 27 | +structrequest_header_narrow { |
| 28 | +typedef std::string string_type; |
| 29 | + std::string name, value; |
| 30 | + }; |
| 31 | + |
| 32 | +structrequest_header_wide { |
| 33 | +typedef std::wstring string_type; |
| 34 | + std::wstring name, value; |
29 | 35 | }; |
30 | 36 |
|
31 | 37 | template<classTag> |
32 | | -inlinevoidswap(request_header<Tag> & l, request_header<Tag> & r) { |
| 38 | +structrequest_header |
| 39 | + : mpl::if_< |
| 40 | + is_default_string<Tag>, |
| 41 | + request_header_narrow, |
| 42 | +typename mpl::if_< |
| 43 | + is_default_wstring<Tag>, |
| 44 | + request_header_wide, |
| 45 | + unsupported_tag<Tag> |
| 46 | + >::type |
| 47 | + > |
| 48 | + {}; |
| 49 | + |
| 50 | +inlinevoidswap(request_header_narrow & l, request_header_narrow & r) { |
33 | 51 | swap(l.name, r.name); |
34 | 52 | swap(l.value, r.value); |
35 | 53 | } |
36 | 54 |
|
37 | | -template<classTag> |
38 | | -structresponse_header { |
39 | | -typedef Tag tag; |
40 | | -typedeftypename string<Tag>::type string_type; |
41 | | - string_type name, value; |
| 55 | +inlinevoidswap(request_header_wide & l, request_header_wide & r) { |
| 56 | +swap(l.name, r.name); |
| 57 | +swap(l.value, r.value); |
| 58 | + } |
| 59 | + |
| 60 | +structresponse_header_narrow { |
| 61 | +typedef std::string string_type; |
| 62 | + std::string name, value; |
| 63 | + }; |
| 64 | + |
| 65 | +structresponse_header_wide { |
| 66 | +typedef std::wstring string_type; |
| 67 | + std::wstring name, value; |
42 | 68 | }; |
43 | 69 |
|
44 | 70 | template<classTag> |
45 | | -voidswap(response_header<Tag> & l, response_header<Tag> & r) { |
| 71 | +structresponse_header |
| 72 | + : mpl::if_< |
| 73 | + is_default_string<Tag>, |
| 74 | + response_header_narrow, |
| 75 | +typename mpl::if_< |
| 76 | + is_default_wstring<Tag>, |
| 77 | + response_header_wide, |
| 78 | + unsupported_tag<Tag> |
| 79 | + >::type |
| 80 | + > |
| 81 | + {}; |
| 82 | + |
| 83 | +inlinevoidswap(response_header_narrow & l, response_header_narrow & r) { |
46 | 84 | std::swap(l.name, r.name); |
47 | 85 | std::swap(l.value, r.value); |
48 | 86 | } |
49 | 87 |
|
| 88 | +inlinevoidswap(response_header_wide & l, response_header_wide & r) { |
| 89 | +std::swap(l.name, r.name); |
| 90 | +std::swap(l.value, r.value); |
| 91 | + } |
| 92 | + |
50 | 93 | }// namespace http |
51 | 94 |
|
52 | 95 | }// namespace network |
53 | 96 |
|
54 | 97 | }// namespace boost |
55 | 98 |
|
56 | | -BOOST_FUSION_ADAPT_TPL_STRUCT( |
57 | | - (Tag), |
58 | | - (boost::network::http::request_header)(Tag), |
59 | | - (typename boost::network::string<Tag>::type, name) |
60 | | - (typename boost::network::string<Tag>::type, value) |
| 99 | +BOOST_FUSION_ADAPT_STRUCT( |
| 100 | + boost::network::http::request_header_narrow, |
| 101 | + (std::string, name) |
| 102 | + (std::string, value) |
| 103 | + ) |
| 104 | + |
| 105 | +BOOST_FUSION_ADAPT_STRUCT( |
| 106 | + boost::network::http::request_header_wide, |
| 107 | + (std::wstring, name) |
| 108 | + (std::wstring, value) |
| 109 | + ) |
| 110 | + |
| 111 | +BOOST_FUSION_ADAPT_STRUCT( |
| 112 | + boost::network::http::response_header_narrow, |
| 113 | + (std::string, name) |
| 114 | + (std::string, value) |
61 | 115 | ) |
62 | 116 |
|
63 | | -BOOST_FUSION_ADAPT_TPL_STRUCT( |
64 | | - (Tag), |
65 | | - (boost::network::http::response_header) (Tag), |
66 | | - (typename boost::network::string<Tag>::type, name) |
67 | | - (typename boost::network::string<Tag>::type, value) |
| 117 | +BOOST_FUSION_ADAPT_STRUCT( |
| 118 | + boost::network::http::response_header_wide, |
| 119 | + (std::wstring, name) |
| 120 | + (std::wstring, value) |
68 | 121 | ) |
69 | 122 |
|
70 | 123 | #endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 |