Skip to content

Commit 7bee012

Browse files
committed
Merge pull request #11 from glynos/master
Changes to URI
2 parents 1c3a293 + 3317c50 commit 7bee012

21 files changed

+969
-813
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) Glyn Matthews 2012.
1+
# Copyright (c) Glyn Matthews 2012, 2013.
22
# Distributed under the Boost Software License, Version 1.0.
33
# (See accompanying file LICENSE_1_0.txt or copy at
44
# http://www.boost.org/LICENSE_1_0.txt)
@@ -10,7 +10,7 @@ project(Uri)
1010
find_package(Threads REQUIRED)
1111
set(Boost_USE_STATIC_LIBS ON)
1212
set(Boost_USE_MULTITHREADED ON)
13-
find_package(Boost 1.53 REQUIRED)
13+
find_package(Boost 1.53 REQUIRED system filesystem)
1414

1515
include_directories(${Uri_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS})
1616

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Copyright (c) Glyn Matthews 2012.
1+
# Copyright (c) Glyn Matthews 2012, 2013.
22
# Distributed under the Boost Software License, Version 1.0.
33
# (See accompanying file LICENSE_1_0.txt or copy at
44
# http://www.boost.org/LICENSE_1_0.txt)
55

66
set(Uri_SRCS
77
${CMAKE_CURRENT_SOURCE_DIR}/uri.cpp
8-
${CMAKE_CURRENT_SOURCE_DIR}/uri_io.cpp
98
${CMAKE_CURRENT_SOURCE_DIR}/uri_builder.cpp
109
${CMAKE_CURRENT_SOURCE_DIR}/detail/uri_parse.cpp)
1110
if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
1211
add_library(cppnetlib-uri ${Uri_SRCS})
12+
target_link_libraries(cppnetlib-uri ${Boost_LIBRARIES})
1313
install(
1414
TARGETS
1515
cppnetlib-uri

src/network/uri/config.hpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,5 @@
1818
#define NETWORK_URI_DECL
1919
#endif // defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK)
2020

21-
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
22-
#define NETWORK_URI_NOEXCEPT noexcept
23-
#else
24-
#define NETWORK_URI_NOEXCEPT
25-
#endif // !defined(BOOST_NO_CXX11_NOEXCEPT)
26-
27-
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
28-
#define NETWORK_URI_DEFAULTED_FUNCTION = default
29-
#else
30-
#define NETWORK_URI_DEFAULTED_FUNCTION
31-
#endif // !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
32-
33-
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
34-
#define NETWORK_URI_DELETED_FUNCTION = delete
35-
#else
36-
#define NETWORK_URI_DELETED_FUNCTION
37-
#endif // !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
38-
3921

4022
#endif // NETWORK_URI_CONFIG_INC

src/network/uri/decode.hpp

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/network/uri/detail/decode.hpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) Glyn Matthews 2011, 2012, 2013.
2+
// Copyright 2012 Dean Michael Berris <[email protected]>
3+
// Copyright 2012 Google, Inc.
4+
// Distributed under the Boost Software License, Version 1.0.
5+
// (See accompanying file LICENSE_1_0.txt or copy at
6+
// http://www.boost.org/LICENSE_1_0.txt)
7+
8+
#ifndef NETWORK_URI_DECODE_INC
9+
#define NETWORK_URI_DECODE_INC
10+
11+
#include <iterator>
12+
#include <cassert>
13+
14+
namespace network {
15+
namespace detail {
16+
template <
17+
typename CharT
18+
>
19+
CharT letter_to_hex(CharT in) {
20+
if ((in >= '0') && (in <= '9')) {
21+
return in - '0';
22+
}
23+
24+
if ((in >= 'a') && (in <= 'f')) {
25+
return in + 10 - 'a';
26+
}
27+
28+
if ((in >= 'A') && (in <= 'F')) {
29+
return in + 10 - 'A';
30+
}
31+
// throw
32+
return CharT();
33+
}
34+
35+
template <
36+
class InputIterator,
37+
typename CharT
38+
>
39+
InputIterator decode_char(InputIterator it, CharT &v) {
40+
assert(*it == '%');
41+
++it;
42+
auto v0 = detail::letter_to_hex(*it);
43+
++it;
44+
auto v1 = detail::letter_to_hex(*it);
45+
++it;
46+
v = (0x10 * v0) + v1;
47+
return it;
48+
}
49+
50+
template <
51+
class InputIterator,
52+
class OutputIterator
53+
>
54+
OutputIterator decode(InputIterator in_begin,
55+
InputIterator in_end,
56+
OutputIterator out_begin) {
57+
auto it = in_begin;
58+
auto out = out_begin;
59+
while (it != in_end) {
60+
if (*it == '%') {
61+
it = decode_char(it, *out);
62+
++out;
63+
}
64+
else {
65+
*out++ = *it++;
66+
}
67+
}
68+
return out;
69+
}
70+
71+
template <
72+
class String
73+
>
74+
String decode(const String &source) {
75+
String unencoded;
76+
decode(std::begin(source), std::end(source),
77+
std::back_inserter(unencoded));
78+
return unencoded;
79+
}
80+
} // namespace detail
81+
} // namespace network
82+
83+
#endif // NETWORK_URI_DECODE_INC

0 commit comments

Comments
 (0)