Skip to content

Commit d961c70

Browse files
committed
Made the documentation more coherent
1 parent fc68b04 commit d961c70

35 files changed

+427
-479
lines changed

README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ ctest
5656

5757
## Examples
5858

59+
These examples are based on the [WhatWG API specification](https://url.spec.whatwg.org/#example-5434421b)
60+
5961
### Creating a URL without a base URL
6062

6163
Parses a string, "https://example.org/💩", without using a base URL:
@@ -111,11 +113,6 @@ int main(int argc, char *argv[]) {
111113
112114
This gives the output: `https://example.org/%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%F0%9F%8C%88`
113115
114-
## Why *skyr*?
115-
116-
This name was chosen by a random project name generator, which
117-
itself was randomly chosen.
118-
119116
## Dependencies
120117
121118
This library uses [optional](https://github.com/TartanLlama/optional),
@@ -148,6 +145,11 @@ This library is released under the Boost Software License (please see
148145
http://boost.org/LICENSE_1_0.txt or the accompanying LICENSE_1_0.txt
149146
file for the full text.
150147
148+
## Why *skyr*?
149+
150+
This name was chosen by a random project name generator, which
151+
itself was randomly chosen.
152+
151153
## Contact
152154
153155
Any questions about this library can be addressed to the cpp-netlib

docs/CMakeLists.txt

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ if (DOXYGEN_FOUND)
2222
file(COPY url_search_parameters.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
2323
file(COPY optional.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
2424
file(COPY expected.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
25-
file(COPY url_record.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
26-
file(COPY url_parse_error.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
27-
file(COPY unicode_error.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
28-
file(COPY ipv4_address.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
29-
file(COPY ipv6_address.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
30-
file(COPY unicode.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
31-
file(COPY domain.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
32-
file(COPY percent_encode.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
25+
# file(COPY url_record.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
26+
# file(COPY ipv4_address.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
27+
# file(COPY ipv6_address.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
28+
# file(COPY unicode.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
29+
# file(COPY domain.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
30+
# file(COPY percent_encode.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
3331
file(COPY changelog.rst DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
3432
configure_file(
3533
${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in

docs/Doxyfile.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ WARNINGS = YES
741741
# will automatically be disabled.
742742
# The default value is: YES.
743743

744-
WARN_IF_UNDOCUMENTED = YES
744+
WARN_IF_UNDOCUMENTED = NO
745745

746746
# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
747747
# potential errors in the documentation, such as not documenting some parameters
@@ -802,7 +802,6 @@ INPUT = @CMAKE_SOURCE_DIR@/include/skyr/config.hpp \
802802
@CMAKE_SOURCE_DIR@/include/skyr/url.hpp \
803803
@CMAKE_SOURCE_DIR@/include/skyr/url_error.hpp \
804804
@CMAKE_SOURCE_DIR@/include/skyr/url_parse.hpp \
805-
@CMAKE_SOURCE_DIR@/include/skyr/url_parse_state.hpp \
806805
@CMAKE_SOURCE_DIR@/include/skyr/url_record.hpp \
807806
@CMAKE_SOURCE_DIR@/include/skyr/url_search_parameters.hpp \
808807
@CMAKE_SOURCE_DIR@/include/skyr/url_serialize.hpp

docs/conf.py.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ copyright = '2018, Glyn Matthews'
2626
author = 'Glyn Matthews'
2727

2828
# The short X.Y version
29-
version = '1.0'
29+
version = '0.5'
3030
# The full version, including alpha/beta/rc tags
31-
release = '1.0 alpha'
31+
release = '0.5'
3232

3333

3434
# -- General configuration ---------------------------------------------------

docs/domain.rst

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ Domain name processing
1010
.. doxygenfunction:: skyr::domain_to_ascii(std::string_view, bool)
1111

1212
.. doxygenfunction:: skyr::domain_to_ascii(std::u32string_view, bool)
13+
14+
.. doxygenenum:: skyr::domain_errc

docs/expected.rst

-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44
.. doxygenclass:: skyr::expected
55
:members:
66

7-
.. doxygenclass:: skyr::unexpected
8-
97
.. doxygenclass:: skyr::bad_expected_access

docs/index.rst

-8
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,4 @@ API
1515
url_search_parameters
1616
optional
1717
expected
18-
url_record
19-
url_parse_error
20-
unicode_error
21-
ipv4_address
22-
ipv6_address
23-
unicode
24-
domain
25-
percent_encode
2618
changelog

docs/ipv4_address.rst

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
:members:
66

77
.. doxygenfunction:: skyr::parse_ipv4_address
8+
9+
.. doxygenenum:: skyr::ipv4_address_errc

docs/ipv6_address.rst

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
:members:
66

77
.. doxygenfunction:: skyr::parse_ipv6_address
8+
9+
.. doxygenenum:: skyr::ipv6_address_errc

docs/percent_encode.rst

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ Percent encoding
1010
.. doxygenfunction:: skyr::percent_decode_byte
1111

1212
.. doxygenfunction:: skyr::percent_decode
13+
14+
.. doxygenenum:: skyr::percent_encode_errc

docs/unicode.rst

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ Unicode encoding
1212
.. doxygenfunction:: skyr::utf32_to_bytes
1313

1414
.. doxygenfunction:: skyr::utf32_from_bytes
15+
16+
.. doxygenenum:: skyr::unicode_errc

docs/unicode_error.rst

-5
This file was deleted.

docs/url.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
.. doxygenclass:: skyr::url
55
:members:
66

7+
.. doxygenclass:: skyr::url_parse_error
8+
:members:
9+
710
.. doxygenfunction:: skyr::swap(url&, url&)
811

912
.. doxygenfunction:: skyr::make_url(http://github.com/const%20Source&)
1013

1114
.. doxygenfunction:: skyr::make_url(http://github.com/const%20Source&,%20const%20url&)
12-
13-
.. doxygenfunction:: skyr::make_url(/service/url::string_type&&)
14-
15-
.. doxygenfunction:: skyr::make_url(/service/url::string_type&&, const url&)

docs/url_parse_error.rst

-5
This file was deleted.

docs/url_record.rst

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
.. doxygenfunction:: skyr::parse
1010

1111
.. doxygenfunction:: skyr::serialize
12+
13+
.. doxygenenum:: skyr::url_parse_errc

include/skyr/details/to_bytes.hpp

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
// Copyright (c) Glyn Matthews 2012-2018.
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+
#ifndef SKYR_URL_DETAILS_TRANSLATE_INC
7+
#define SKYR_URL_DETAILS_TRANSLATE_INC
8+
9+
#include <string>
10+
#include <skyr/unicode.hpp>
11+
12+
namespace skyr {
13+
namespace details {
14+
template <typename Source>
15+
struct to_bytes_impl;
16+
17+
template <>
18+
struct to_bytes_impl<std::string> {
19+
expected<std::string, std::error_code> operator()(const std::string &source) const { return source; }
20+
};
21+
22+
template <int N>
23+
struct to_bytes_impl<char[N]> {
24+
expected<std::string, std::error_code> operator()(const char *source) const { return source; }
25+
};
26+
27+
template <>
28+
struct to_bytes_impl<char *> {
29+
expected<std::string, std::error_code> operator()(const char *source) const { return source; }
30+
};
31+
32+
template <>
33+
struct to_bytes_impl<const char *> {
34+
expected<std::string, std::error_code> operator()(const char *source) const { return source; }
35+
};
36+
37+
template <int N>
38+
struct to_bytes_impl<const char[N]> {
39+
expected<std::string, std::error_code> operator()(const char *source) const { return source; }
40+
};
41+
42+
template <>
43+
struct to_bytes_impl<std::wstring> {
44+
expected<std::string, std::error_code> operator()(const std::wstring &source) const {
45+
return wstring_to_bytes(source);
46+
}
47+
};
48+
49+
template <int N>
50+
struct to_bytes_impl<const wchar_t[N]> {
51+
expected<std::string, std::error_code> operator()(const wchar_t *source) const {
52+
to_bytes_impl<std::wstring> to_bytes;
53+
return to_bytes(source);
54+
}
55+
};
56+
57+
template <int N>
58+
struct to_bytes_impl<wchar_t[N]> {
59+
expected<std::string, std::error_code> operator()(const wchar_t *source) const {
60+
to_bytes_impl<std::wstring> to_bytes;
61+
return to_bytes(source);
62+
}
63+
};
64+
65+
template <>
66+
struct to_bytes_impl<wchar_t *> {
67+
expected<std::string, std::error_code> operator()(const wchar_t *source) const {
68+
to_bytes_impl<std::wstring> to_bytes;
69+
return to_bytes(source);
70+
}
71+
};
72+
73+
template <>
74+
struct to_bytes_impl<const wchar_t *> {
75+
expected<std::string, std::error_code> operator()(const wchar_t *source) const {
76+
to_bytes_impl<std::wstring> to_bytes;
77+
return to_bytes(source);
78+
}
79+
};
80+
81+
template <>
82+
struct to_bytes_impl<std::u16string> {
83+
expected<std::string, std::error_code> operator()(const std::u16string &source) const {
84+
return utf16_to_bytes(source);
85+
}
86+
};
87+
88+
template <int N>
89+
struct to_bytes_impl<const char16_t[N]> {
90+
expected<std::string, std::error_code> operator()(const char16_t *source) const {
91+
to_bytes_impl<std::u16string> to_bytes;
92+
return to_bytes(source);
93+
}
94+
};
95+
96+
template <int N>
97+
struct to_bytes_impl<char16_t[N]> {
98+
expected<std::string, std::error_code> operator()(const char16_t *source) const {
99+
to_bytes_impl<std::u16string> to_bytes;
100+
return to_bytes(source);
101+
}
102+
};
103+
104+
template <>
105+
struct to_bytes_impl<char16_t *> {
106+
expected<std::string, std::error_code> operator()(const char16_t *source) const {
107+
to_bytes_impl<std::u16string> to_bytes;
108+
return to_bytes(source);
109+
}
110+
};
111+
112+
template <>
113+
struct to_bytes_impl<const char16_t *> {
114+
expected<std::string, std::error_code> operator()(const char16_t *source) const {
115+
to_bytes_impl<std::u16string> to_bytes;
116+
return to_bytes(source);
117+
}
118+
};
119+
120+
template <>
121+
struct to_bytes_impl<std::u32string> {
122+
expected<std::string, std::error_code> operator()(const std::u32string &source) const {
123+
return utf32_to_bytes(source);
124+
}
125+
};
126+
127+
template <int N>
128+
struct to_bytes_impl<const char32_t[N]> {
129+
expected<std::string, std::error_code> operator()(const char32_t *source) const {
130+
to_bytes_impl<std::u32string> to_bytes;
131+
return to_bytes(source);
132+
}
133+
};
134+
135+
template <int N>
136+
struct to_bytes_impl<char32_t[N]> {
137+
expected<std::string, std::error_code> operator()(const char32_t *source) const {
138+
to_bytes_impl<std::u32string> to_bytes;
139+
return to_bytes(source);
140+
}
141+
};
142+
143+
template <>
144+
struct to_bytes_impl<char32_t *> {
145+
expected<std::string, std::error_code> operator()(const char32_t *source) const {
146+
to_bytes_impl<std::u32string> to_bytes;
147+
return to_bytes(source);
148+
}
149+
};
150+
151+
template <>
152+
struct to_bytes_impl<const char32_t *> {
153+
expected<std::string, std::error_code> operator()(const char32_t *source) const {
154+
to_bytes_impl<std::u32string> to_bytes;
155+
return to_bytes(source);
156+
}
157+
};
158+
159+
template <typename Source>
160+
inline expected<std::string, std::error_code> to_bytes(const Source &source) {
161+
to_bytes_impl<Source> to_bytes;
162+
return to_bytes(source);
163+
}
164+
} // namespace details
165+
} // namespace skyr
166+
167+
#endif // SKYR_URL_DETAILS_TRANSLATE_INC

0 commit comments

Comments
 (0)