Skip to content

Commit 644438f

Browse files
committed
Cleaned up redundant code, using std::string_view.
1 parent 1f87883 commit 644438f

34 files changed

Lines changed: 246 additions & 517 deletions

.travis.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,18 @@ matrix:
2424
# compiler: clang
2525
# addons:
2626
# apt:
27-
# sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test']
28-
# packages: ['clang-5.0', 'libc++-dev']
29-
# env: COMPILER='clang++-5.0'
30-
#
31-
# - os: linux
32-
# compiler: clang
33-
# addons:
34-
# apt:
3527
# sources: ['llvm-toolchain-trusty-6.0', 'ubuntu-toolchain-r-test']
3628
# packages: ['clang-6.0', 'libc++-dev']
3729
# env: COMPILER='clang++-6.0'
3830

3931
# 2/ Linux GCC Builds
4032
- os: linux
4133
compiler: gcc
42-
addons: &gcc6
34+
addons: &gcc7
4335
apt:
4436
sources: ['ubuntu-toolchain-r-test']
45-
packages: ['g++-6']
46-
env: COMPILER='g++-6'
47-
48-
# - os: linux
49-
# compiler: gcc
50-
# addons: &gcc7
51-
# apt:
52-
# sources: ['ubuntu-toolchain-r-test']
53-
# packages: ['g++-7']
54-
# env: COMPILER='g++-7'
37+
packages: ['g++-7']
38+
env: COMPILER='g++-7'
5539

5640
- os: linux
5741
compiler: gcc

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ add_subdirectory(src)
7676
if (Skyr_BUILD_TESTS)
7777
message(STATUS "Configuring tests")
7878
enable_testing()
79+
set(BUILD_GMOCK OFF)
80+
set(BUILD_GTEST ON)
7981
add_subdirectory(deps/googletest)
8082
add_subdirectory(tests)
8183
endif()

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(
99
example_01
1010
example_02
1111
example_03
12+
example_04
1213
)
1314

1415
foreach(example ${EXAMPLES})

examples/example_01.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99

1010
int main(int argc, char *argv[]) {
1111
auto url = skyr::make_url("http://example.org/\xf0\x9f\x92\xa9");
12+
std::cout << url.value().href() << std::endl;
1213
std::cout << url.value().pathname() << std::endl;
1314
}

examples/example_02.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
int main(int argc, char *argv[]) {
11-
auto url = skyr::make_url(U"/\u1F363\1F37A");
11+
auto url = skyr::make_url("\xf0\x9f\x8d\xa3\xf0\x9f\x8d\xba");
1212
if (!url) {
1313
std::cerr << "Parsing failed: " << url.error().message() << std::endl;
1414
}

examples/example_03.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
int main(int argc, char *argv[]) {
1111
auto base = skyr::make_url(
12-
"https://url.spec.whatwg.org/");
12+
"https://example.org/");
1313
auto url = skyr::make_url(
1414
"\xf0\x9f\x8f\xb3\xef\xb8\x8f\xe2\x80\x8d\xf0\x9f\x8c\x88", base.value());
1515
if (url) {

examples/example_04.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2018 Glyn Matthews.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt of copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#include <skyr/url_parse.hpp>
7+
#include <skyr/url_serialize.hpp>
8+
#include <iostream>
9+
10+
11+
int main(int argc, char *argv[]) {
12+
auto base = skyr::parse(
13+
"https://example.org/");
14+
auto url = skyr::parse(
15+
"\xf0\x9f\x8f\xb3\xef\xb8\x8f\xe2\x80\x8d\xf0\x9f\x8c\x88", base.value());
16+
if (url) {
17+
std::cout << skyr::serialize(url.value()) << std::endl;
18+
}
19+
}

include/skyr/config.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#endif // defined(SKYR_STD17)
3030
#endif // defined(__GNUC__)
3131

32-
33-
3432
#if defined(_MSC_VER)
3533
#define SKYR_URI_MSVC _MSC_VER
3634
#endif // defined(_MSC_VER)

include/skyr/domain.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#define SKYR_DOMAIN_HPP
88

99
#include <string>
10+
#include <string_view>
1011
#include <system_error>
11-
#include <skyr/string_view.hpp>
1212
#include <skyr/expected.hpp>
1313

1414
namespace skyr {
@@ -22,6 +22,7 @@ enum class domain_errc {
2222
};
2323
} // namespace skyr
2424

25+
/// \exclude
2526
namespace std {
2627
template <>
2728
struct is_error_code_enum<skyr::domain_errc> : true_type {};
@@ -37,29 +38,29 @@ std::error_code make_error_code(domain_errc error);
3738
namespace punycode {
3839
/// \param input
3940
/// \returns
40-
expected<std::string, std::error_code> encode(string_view input);
41+
expected<std::string, std::error_code> encode(std::string_view input);
4142

4243
/// \param input
4344
/// \returns
44-
expected<std::string, std::error_code> encode(u32string_view input);
45+
expected<std::string, std::error_code> encode(std::u32string_view input);
4546

4647
/// \param input
4748
/// \returns
48-
expected<std::string, std::error_code> decode(string_view input);
49+
expected<std::string, std::error_code> decode(std::string_view input);
4950
} // namespace punycode
5051

5152
/// \param domain
5253
/// \param be_strict
5354
/// returns
5455
expected<std::string, std::error_code> domain_to_ascii(
55-
string_view domain,
56+
std::string_view domain,
5657
bool be_strict = true);
5758

5859
/// \param domain
5960
/// \param be_strict
6061
/// \returns
6162
expected<std::string, std::error_code> domain_to_ascii(
62-
u32string_view domain,
63+
std::u32string_view domain,
6364
bool be_strict = true);
6465
} // namespace skyr
6566

include/skyr/ipv4_address.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#define SKYR_IPV4_ADDRESS_INC
88

99
#include <string>
10+
#include <string_view>
1011
#include <system_error>
11-
#include <skyr/string_view.hpp>
1212
#include <skyr/expected.hpp>
1313
#include <skyr/optional.hpp>
1414

@@ -61,7 +61,7 @@ class ipv4_address {
6161

6262
/// \param input
6363
/// \returns
64-
expected<ipv4_address, std::error_code> parse_ipv4_address(string_view input);
64+
expected<ipv4_address, std::error_code> parse_ipv4_address(std::string_view input);
6565
} // namespace skyr
6666

6767
#endif //SKYR_IPV4_ADDRESS_INC

0 commit comments

Comments
 (0)