Skip to content

Commit 403b168

Browse files
authored
V2 cpp20 (#148)
* Renamed a lot of files to make sure they're in the right location when I get the big C++20 move under way * Added v2 tests * Added constexpr wherever it compiles * Added filesystem and json tests to v2 * Tinkering and simplifying * More constexpr improvements * Started using concepts * Refactored string_traits to use C++20 concepts * Using nested namespaces * Added build switch to enable v2 * Replaced deprecated header * Updated percent encoding functions * Update CMake minimum version * Updated Git CI configuration * Updated Git CI configuration, enabling v2 * Updated IDNA table tests that were not compiling on CI using C++20 compiler * Fix test failure caused by misunderstanding of return type of path::generic_u8string when changing from C++17 to C++20 * Not all compilers like constexpr destructors * Added GCC 10 tests to CI * Fixed issue with member function accessor names in host class * Not everything can be constexpr yet
1 parent dd34536 commit 403b168

File tree

147 files changed

+18912
-353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+18912
-353
lines changed

.github/workflows/skyr-url-ci.yml

+71-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: skyr-url CI
22

33
# Trigger on pushes to all branches and for all pull-requests
4-
on: [push, pull_request]
4+
on: [ push, pull_request ]
55

66
env:
7-
CMAKE_VERSION: 3.16.2
7+
CMAKE_VERSION: 3.17.3
88
NINJA_VERSION: 1.9.0
99

1010
jobs:
@@ -77,6 +77,37 @@ jobs:
7777
cxx_standard: 20
7878
}
7979

80+
81+
# GCC-10
82+
- {
83+
name: "Linux GCC 10 Debug (C++17)", artifact: "Linux.tar.xz",
84+
os: ubuntu-latest,
85+
build_type: Debug,
86+
cc: "gcc-10", cxx: "g++-10",
87+
cxx_standard: 17
88+
}
89+
- {
90+
name: "Linux GCC 10 Release (C++17)", artifact: "Linux.tar.xz",
91+
os: ubuntu-latest,
92+
build_type: RelWithDebInfo,
93+
cc: "gcc-10", cxx: "g++-10",
94+
cxx_standard: 17
95+
}
96+
- {
97+
name: "Linux GCC 10 Debug (C++20)", artifact: "Linux.tar.xz",
98+
os: ubuntu-latest,
99+
build_type: Debug,
100+
cc: "gcc-10", cxx: "g++-10",
101+
cxx_standard: 20,
102+
}
103+
- {
104+
name: "Linux GCC 10 Release (C++20)", artifact: "Linux.tar.xz",
105+
os: ubuntu-latest,
106+
build_type: RelWithDebInfo,
107+
cc: "gcc-10", cxx: "g++-10",
108+
cxx_standard: 20,
109+
}
110+
80111
# Clang-8
81112
- {
82113
name: "Linux Clang 8 Debug (C++17)", artifact: "Linux.tar.xz",
@@ -153,6 +184,22 @@ jobs:
153184
cxx_standard: 20,
154185
}
155186

187+
# Clang-11
188+
- {
189+
name: "Linux Clang 11 Debug (C++20)", artifact: "Linux.tar.xz",
190+
os: ubuntu-latest,
191+
build_type: Debug,
192+
cc: "clang-11", cxx: "clang++-11",
193+
cxx_standard: 20,
194+
}
195+
- {
196+
name: "Linux Clang 11 Release (C++20)", artifact: "Linux.tar.xz",
197+
os: ubuntu-latest,
198+
build_type: RelWithDebInfo,
199+
cc: "clang-11", cxx: "clang++-11",
200+
cxx_standard: 20,
201+
}
202+
156203
# AppleClang
157204
- {
158205
name: "macOS Clang Debug (C++17)", artifact: "macOS.tar.xz",
@@ -270,6 +317,16 @@ jobs:
270317
chmod +x llvm.sh
271318
sudo ./llvm.sh 10
272319
320+
- name: Install Clang 11
321+
id: install_clang_11
322+
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'clang++-11' )
323+
shell: bash
324+
working-directory: ${{ env.HOME }}
325+
run: |
326+
wget https://apt.llvm.org/llvm.sh
327+
chmod +x llvm.sh
328+
sudo ./llvm.sh 11
329+
273330
- name: Install vcpkg (Linux)
274331
id: vcpkg_linux
275332
if: startsWith(matrix.config.os, 'ubuntu')
@@ -339,6 +396,17 @@ jobs:
339396
endif()
340397
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
341398
399+
set(BUILD_V2 OFF)
400+
if ("${{ matrix.config.name }}" STREQUAL "Windows MSVC 2019 Debug (C++20)" OR
401+
"${{ matrix.config.name }}" STREQUAL "Windows MSVC 2019 Release (C++20)" OR
402+
"${{ matrix.config.name }}" STREQUAL "Linux GCC 10 Debug (C++20)" OR
403+
"${{ matrix.config.name }}" STREQUAL "Linux GCC 10 Release (C++20)" OR
404+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 11 Debug (C++20)" OR
405+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 11 Release (C++20)"
406+
)
407+
set(BUILD_V2 ON)
408+
endif()
409+
342410
execute_process(
343411
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake
344412
-S .
@@ -349,6 +417,7 @@ jobs:
349417
-D skyr_BUILD_TESTS=ON
350418
-D skyr_BUILD_DOCS=OFF
351419
-D skyr_BUILD_EXAMPLES=OFF
420+
-D skyr_BUILD_V2=${BUILD_V2}
352421
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }}
353422
-D CMAKE_TOOLCHAIN_FILE=$ENV{GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake
354423
-D CMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/install

CMakeLists.txt

+15-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
# http://www.boost.org/LICENSE_1_0.txt)
55

66

7-
cmake_minimum_required(VERSION 3.14)
7+
cmake_minimum_required(VERSION 3.17)
88

99
project(
1010
skyr-url
11-
VERSION 1.13.0
11+
VERSION 2.0.0
1212
HOMEPAGE_URL https://cpp-netlib.github.io/url
1313
DESCRIPTION "A C++ library that implements the WhatWG URL specification"
1414
LANGUAGES CXX
@@ -25,9 +25,14 @@ option(skyr_USE_STATIC_CRT "Use static C Runtime library (/MT or MTd)." ON)
2525
option(skyr_BUILD_WITH_LLVM_LIBCXX "Instruct Clang to use LLVM's implementation of C++ standard library" OFF)
2626
option(skyr_ENABLE_FILESYSTEM_FUNCTIONS "Enable functions to convert URL to std::filesystem::path" ON)
2727
option(skyr_ENABLE_JSON_FUNCTIONS "Enable functions to convert URL components to JSON" ON)
28+
option(skyr_BUILD_V2 "Build v2, which uses C++20 features" ON)
2829

2930
set(CMAKE_VERBOSE_MAKEFILE true)
30-
set(CMAKE_CXX_STANDARD 17)
31+
if (skyr_BUILD_V2)
32+
set(CMAKE_CXX_STANDARD 20)
33+
else()
34+
set(CMAKE_CXX_STANDARD 17)
35+
endif()
3136
set(CMAKE_CXX_EXTENSIONS OFF)
3237
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3338

@@ -67,16 +72,16 @@ endif()
6772

6873
# Add an alias for projects that use skyr-url as a dependency
6974
if (NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
70-
add_library(skyr::skyr-url ALIAS skyr-url)
75+
add_library(skyr::skyr-url ALIAS skyr-url-v1)
7176
if (skyr_ENABLE_FILESYSTEM_FUNCTIONS)
72-
add_library(skyr::skyr-filesystem ALIAS skyr-filesystem)
77+
add_library(skyr::skyr-filesystem ALIAS skyr-filesystem-v1)
7378
endif()
7479
if (skyr_ENABLE_JSON_FUNCTIONS)
75-
add_library(skyr::skyr-json ALIAS skyr-json)
80+
add_library(skyr::skyr-json ALIAS skyr-json-v1)
7681
endif()
7782
endif()
7883

79-
# Install
84+
## Install
8085
include(CMakePackageConfigHelpers)
8186
include(GNUInstallDirs)
8287

@@ -90,12 +95,12 @@ write_basic_package_version_file(
9095
COMPATIBILITY SameMajorVersion
9196
ARCH_INDEPENDENT)
9297

93-
set(skyr_TARGETS skyr-url)
98+
set(skyr_TARGETS skyr-url-v1)
9499
if (skyr_ENABLE_FILESYSTEM_FUNCTIONS)
95-
list(APPEND skyr_TARGETS skyr-filesystem)
100+
list(APPEND skyr_TARGETS skyr-filesystem-v1)
96101
endif()
97102
if (skyr_ENABLE_JSON_FUNCTIONS)
98-
list(APPEND skyr_TARGETS skyr-json)
103+
list(APPEND skyr_TARGETS skyr-json-v1)
99104
endif()
100105

101106
install(TARGETS ${skyr_TARGETS}

examples/CMakeLists.txt

+1-60
Original file line numberDiff line numberDiff line change
@@ -1,60 +1 @@
1-
# Copyright (c) Glyn Matthews 2018-20.
2-
# Distributed under the Boost Software License, Version 1.0.
3-
# (See accompanying file LICENSE_1_0.txt or copy at
4-
# http://www.boost.org/LICENSE_1_0.txt)
5-
6-
include(${PROJECT_SOURCE_DIR}/cmake/skyr-url-functions.cmake)
7-
8-
set(full_warnings $<BOOL:${skyr_FULL_WARNINGS}>)
9-
set(warnings_as_errors $<BOOL:${skyr_WARNINGS_AS_ERRORS}>)
10-
set(no_exceptions $<BOOL:${skyr_BUILD_WITHOUT_EXCEPTIONS}>)
11-
set(no_rtti $<BOOL:${skyr_BUILD_WITHOUT_RTTI}>)
12-
13-
set(gnu $<CXX_COMPILER_ID:GNU>)
14-
set(clang $<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>)
15-
set(libcxx $<AND:${clang},$<BOOL:${skyr_BUILD_WITH_LLVM_LIBCXX}>>)
16-
set(msvc $<CXX_COMPILER_ID:MSVC>)
17-
18-
foreach(
19-
file_name
20-
example_01.cpp
21-
example_02.cpp
22-
example_03.cpp
23-
example_04.cpp
24-
example_05.cpp
25-
example_06.cpp
26-
example_07.cpp
27-
example_08.cpp
28-
example_09.cpp
29-
example_10.cpp
30-
example_11.cpp
31-
)
32-
skyr_remove_extension(${file_name} example)
33-
add_executable(${example} ${file_name})
34-
add_dependencies(${example} skyr-url)
35-
target_compile_options(
36-
${example}
37-
PRIVATE
38-
$<$<AND:$<OR:${gnu},${clang}>,${full_warnings}>:-Wall>
39-
$<$<AND:$<OR:${gnu},${clang}>,${warnings_as_errors}>:-Werror>
40-
$<$<AND:$<OR:${gnu},${clang}>,${no_exceptions}>:-fno-exceptions>
41-
$<$<AND:$<OR:${gnu},${clang}>,${no_rtti}>:-fno-rtti>
42-
$<$<AND:$<OR:${gnu},${clang}>,$<CONFIG:MinSizeRel>>:-flto>
43-
$<${libcxx}:-stdlib=libc++>
44-
45-
$<$<AND:${msvc},${full_warnings}>:/W4>
46-
$<$<AND:${msvc},${warnings_as_errors}>:/WX>
47-
$<$<AND:${msvc},$<NOT:${no_exceptions}>>:/EHsc>
48-
$<$<AND:${msvc},${no_rtti}>:/GR->
49-
)
50-
target_link_libraries(
51-
${example}
52-
PRIVATE
53-
skyr-url
54-
)
55-
set_target_properties(
56-
${example}
57-
PROPERTIES
58-
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/examples
59-
)
60-
endforeach()
1+
add_subdirectory(v1)

examples/v1/CMakeLists.txt

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) Glyn Matthews 2018-20.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
include(${PROJECT_SOURCE_DIR}/cmake/skyr-url-functions.cmake)
7+
8+
set(full_warnings $<BOOL:${skyr_FULL_WARNINGS}>)
9+
set(warnings_as_errors $<BOOL:${skyr_WARNINGS_AS_ERRORS}>)
10+
set(no_exceptions $<BOOL:${skyr_BUILD_WITHOUT_EXCEPTIONS}>)
11+
set(no_rtti $<BOOL:${skyr_BUILD_WITHOUT_RTTI}>)
12+
13+
set(gnu $<CXX_COMPILER_ID:GNU>)
14+
set(clang $<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>)
15+
set(libcxx $<AND:${clang},$<BOOL:${skyr_BUILD_WITH_LLVM_LIBCXX}>>)
16+
set(msvc $<CXX_COMPILER_ID:MSVC>)
17+
18+
foreach(
19+
file_name
20+
example_01.cpp
21+
example_02.cpp
22+
example_03.cpp
23+
example_04.cpp
24+
example_05.cpp
25+
example_06.cpp
26+
example_07.cpp
27+
example_08.cpp
28+
example_09.cpp
29+
example_10.cpp
30+
example_11.cpp
31+
)
32+
skyr_remove_extension(${file_name} example)
33+
add_executable(${example} ${file_name})
34+
add_dependencies(${example} skyr-url-v1)
35+
target_compile_options(
36+
${example}
37+
PRIVATE
38+
$<$<AND:$<OR:${gnu},${clang}>,${full_warnings}>:-Wall>
39+
$<$<AND:$<OR:${gnu},${clang}>,${warnings_as_errors}>:-Werror>
40+
$<$<AND:$<OR:${gnu},${clang}>,${no_exceptions}>:-fno-exceptions>
41+
$<$<AND:$<OR:${gnu},${clang}>,${no_rtti}>:-fno-rtti>
42+
$<$<AND:$<OR:${gnu},${clang}>,$<CONFIG:MinSizeRel>>:-flto>
43+
$<${libcxx}:-stdlib=libc++>
44+
45+
$<$<AND:${msvc},${full_warnings}>:/W4>
46+
$<$<AND:${msvc},${warnings_as_errors}>:/WX>
47+
$<$<AND:${msvc},$<NOT:${no_exceptions}>>:/EHsc>
48+
$<$<AND:${msvc},${no_rtti}>:/GR->
49+
)
50+
target_link_libraries(
51+
${example}
52+
PRIVATE
53+
skyr-url-v1
54+
)
55+
set_target_properties(
56+
${example}
57+
PROPERTIES
58+
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/examples
59+
)
60+
endforeach()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

include/skyr/v1/core/check_input.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <locale>
1010
#include <string>
11-
#include <range/v3/distance.hpp>
11+
#include <range/v3/iterator/operations.hpp>
1212
#include <range/v3/algorithm/find_if_not.hpp>
1313
#include <range/v3/algorithm/remove_if.hpp>
1414
#include <range/v3/view/reverse.hpp>

include/skyr/v1/domain/domain.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <range/v3/algorithm/find_if_not.hpp>
1616
#include <range/v3/action/erase.hpp>
1717
#include <range/v3/iterator.hpp>
18-
#include <range/v3/distance.hpp>
18+
#include <range/v3/iterator/operations.hpp>
1919
#include <range/v3/range/conversion.hpp>
2020
#include <range/v3/range/access.hpp>
2121
#include <range/v3/view/join.hpp>

include/skyr/v1/filesystem/path.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum class path_errc {
3232
/// \param path A filesystem path
3333
/// \returns a url object or an error on failure
3434
inline auto from_path(const stdfs::path &path) -> tl::expected<url, url_parse_errc> {
35-
return make_url("file://" + path.generic_u8string());
35+
return make_url("file://" + path.generic_string());
3636
}
3737

3838
/// Converts a URL pathname to a filesystem path

include/skyr/v1/unicode/traits/iterator_value.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class iterator_value<T*> {
2828

2929
template <class Range>
3030
using iterator_value_t = typename iterator_value<Range>::type;
31-
} // namespace unicode::traits
31+
} // namespace unicode::concepts
3232
} // namespace v1
3333
} // namespace skyr
3434

include/skyr/v1/unicode/traits/range_iterator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class range_iterator<T[N]> { // NOLINT
2828

2929
template <class Range>
3030
using range_iterator_t = typename range_iterator<Range>::type;
31-
} // namespace unicode::traits
31+
} // namespace unicode::concepts
3232
} // namespace v1
3333
} // namespace skyr
3434

include/skyr/v1/unicode/traits/range_value.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class range_value<T[N]> { // NOLINT
2828

2929
template <class Range>
3030
using range_value_t = typename range_value<Range>::type;
31-
} // namespace unicode::traits
31+
} // namespace unicode::concepts
3232
} // namespace v1
3333
} // namespace skyr
3434

include/skyr/v1/url.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ class url {
145145
/// Copy assignment operator
146146
/// \param other Another `url` object
147147
/// \return *this
148-
url &operator=(const url &other) = default;
148+
auto operator=(const url &other) -> url & = default;
149149

150150
/// Move assignment operator
151151
/// \param other Another `url` object
152152
/// \return *this
153-
url &operator=(url&& other) = default;
153+
auto operator=(url&& other) -> url & = default;
154154

155155
/// Destructor
156156
~url() = default;

0 commit comments

Comments
 (0)