33// (See accompanying file LICENSE_1_0.txt or copy at
44// http://www.boost.org/LICENSE_1_0.txt)
55
6-
76#ifndef __BOOST_NETWORK_URI_DECODE_INC__
8- #define __BOOST_NETWORK_URI_DECODE_INC__
9-
10-
11- #include < boost/iterator/iterator_traits.hpp>
12- #include < boost/range/begin.hpp>
13- #include < boost/range/end.hpp>
14- #include < cassert>
7+ #define __BOOST_NETWORK_URI_DECODE_INC__
158
9+ #include < boost/iterator/iterator_traits.hpp>
10+ #include < boost/range/begin.hpp>
11+ #include < boost/range/end.hpp>
12+ #include < cassert>
1613
1714namespace boost {
1815namespace network {
1916namespace uri {
2017namespace detail {
21- template <
22- typename CharT
23- >
24- CharTletter_to_hex (CharT in)
25- {
26- switch (in)
27- {
18+ template <typename CharT>
19+ CharTletter_to_hex (CharT in) {
20+ switch (in) {
2821case ' 0' :
2922case ' 1' :
3023case ' 2' :
@@ -35,74 +28,65 @@ CharT letter_to_hex(CharT in)
3528case ' 7' :
3629case ' 8' :
3730case ' 9' :
38- return in -' 0' ;
31+ return in -' 0' ;
3932case ' a' :
4033case ' b' :
4134case ' c' :
4235case ' d' :
4336case ' e' :
4437case ' f' :
45- return in +10 -' a' ;
38+ return in +10 -' a' ;
4639case ' A' :
4740case ' B' :
4841case ' C' :
4942case ' D' :
5043case ' E' :
5144case ' F' :
52- return in +10 -' A' ;
53- }
54- return CharT ();
45+ return in +10 -' A' ;
46+ }
47+ return CharT ();
5548}
56- }// namespace detail
49+ }// namespace detail
5750
58- template <
59- class InputIterator ,
60- class OutputIterator
61- >
51+ template <class InputIterator ,class OutputIterator >
6252OutputIteratordecode (const InputIterator &in_begin,
6353const InputIterator &in_end,
6454const OutputIterator &out_begin) {
65- typedef typename boost::iterator_value<InputIterator>::type value_type;
55+ typedef typename boost::iterator_value<InputIterator>::type value_type;
6656
67- InputIterator it = in_begin;
68- OutputIterator out = out_begin;
69- while (it != in_end) {
70- if (*it ==' %' )
71- {
72- ++it;
73- value_type v0 =detail::letter_to_hex (*it);
74- ++it;
75- value_type v1 =detail::letter_to_hex (*it);
76- ++it;
77- *out++ =0x10 * v0 + v1;
78- }
79- else
80- {
81- *out++ = *it++;
82- }
57+ InputIterator it = in_begin;
58+ OutputIterator out = out_begin;
59+ while (it != in_end) {
60+ if (*it ==' %' ) {
61+ ++it;
62+ value_type v0 =detail::letter_to_hex (*it);
63+ ++it;
64+ value_type v1 =detail::letter_to_hex (*it);
65+ ++it;
66+ *out++ =0x10 * v0 + v1;
67+ }else if (*it ==' +' ) {
68+ *out++ =' ' ;
69+ ++it;
70+ }else {
71+ *out++ = *it++;
8372 }
84- return out;
73+ }
74+ return out;
8575}
8676
87- template <
88- class SinglePassRange ,
89- class OutputIterator
90- >
91- inline
92- OutputIteratordecode (const SinglePassRange &range,
93- const OutputIterator &out) {
94- return decode (boost::begin (range),boost::end (range), out);
77+ template <class SinglePassRange ,class OutputIterator >
78+ inline OutputIteratordecode (const SinglePassRange &range,
79+ const OutputIterator &out) {
80+ return decode (boost::begin (range),boost::end (range), out);
9581}
9682
97- inline
98- std::stringdecoded (const std::string &input) {
99- std::string decoded;
100- decode (input,std::back_inserter (decoded));
101- return decoded;
83+ inline std::stringdecoded (const std::string &input) {
84+ std::string decoded;
85+ decode (input,std::back_inserter (decoded));
86+ return decoded;
10287}
103- }// namespace uri
104- }// namespace network
105- }// namespace boost
106-
88+ }// namespace uri
89+ }// namespace network
90+ }// namespace boost
10791
108- #endif // __BOOST_NETWORK_URI_DECODE_INC__
92+ #endif // __BOOST_NETWORK_URI_DECODE_INC__