Skip to content

Commit 91ed5c3

Browse files
authored
Marks as private several functions in our header files. (#600)
* Marks as private several functions in our header files. * format
1 parent 201dd98 commit 91ed5c3

File tree

6 files changed

+57
-0
lines changed

6 files changed

+57
-0
lines changed

include/ada/character_sets-inl.h

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
#include "ada/character_sets.h"
1111

12+
/**
13+
* These functions are not part of our public API and may
14+
* change at any time.
15+
* @private
16+
*/
1217
namespace ada::character_sets {
1318

1419
constexpr char hex[1024] =

include/ada/character_sets.h

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <cstdint>
1212

1313
/**
14+
* These functions are not part of our public API and may
15+
* change at any time.
16+
* @private
1417
* @namespace ada::character_sets
1518
* @brief Includes the definitions for unicode character sets.
1619
*/

include/ada/checkers.h

+14
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@
1111
#include <cstring>
1212

1313
/**
14+
* These functions are not part of our public API and may
15+
* change at any time.
16+
* @private
1417
* @namespace ada::checkers
1518
* @brief Includes the definitions for validation functions
1619
*/
1720
namespace ada::checkers {
1821

1922
/**
23+
* @private
2024
* Assuming that x is an ASCII letter, this function returns the lower case
2125
* equivalent.
2226
* @details More likely to be inlined by the compiler and constexpr.
2327
*/
2428
constexpr char to_lower(char x) noexcept;
2529

2630
/**
31+
* @private
2732
* Returns true if the character is an ASCII letter. Equivalent to std::isalpha
2833
* but more likely to be inlined by the compiler.
2934
*
@@ -32,24 +37,28 @@ constexpr char to_lower(char x) noexcept;
3237
constexpr bool is_alpha(char x) noexcept;
3338

3439
/**
40+
* @private
3541
* Check whether a string starts with 0x or 0X. The function is only
3642
* safe if input.size() >=2.
3743
*
3844
* @see has_hex_prefix
3945
*/
4046
inline bool has_hex_prefix_unsafe(std::string_view input);
4147
/**
48+
* @private
4249
* Check whether a string starts with 0x or 0X.
4350
*/
4451
inline bool has_hex_prefix(std::string_view input);
4552

4653
/**
54+
* @private
4755
* Check whether x is an ASCII digit. More likely to be inlined than
4856
* std::isdigit.
4957
*/
5058
constexpr bool is_digit(char x) noexcept;
5159

5260
/**
61+
* @private
5362
* @details A string starts with a Windows drive letter if all of the following
5463
* are true:
5564
*
@@ -63,26 +72,30 @@ constexpr bool is_digit(char x) noexcept;
6372
inline constexpr bool is_windows_drive_letter(std::string_view input) noexcept;
6473

6574
/**
75+
* @private
6676
* @details A normalized Windows drive letter is a Windows drive letter of which
6777
* the second code point is U+003A (:).
6878
*/
6979
inline constexpr bool is_normalized_windows_drive_letter(
7080
std::string_view input) noexcept;
7181

7282
/**
83+
* @private
7384
* @warning Will be removed when Ada requires C++20.
7485
*/
7586
ada_really_inline bool begins_with(std::string_view view,
7687
std::string_view prefix);
7788

7889
/**
90+
* @private
7991
* Returns true if an input is an ipv4 address. It is assumed that the string
8092
* does not contain uppercase ASCII characters (the input should have been
8193
* lowered cased before calling this function) and is not empty.
8294
*/
8395
ada_really_inline ada_constexpr bool is_ipv4(std::string_view view) noexcept;
8496

8597
/**
98+
* @private
8699
* Returns a bitset. If the first bit is set, then at least one character needs
87100
* percent encoding. If the second bit is set, a \\ is found. If the third bit
88101
* is set then we have a dot. If the fourth bit is set, then we have a percent
@@ -92,6 +105,7 @@ ada_really_inline constexpr uint8_t path_signature(
92105
std::string_view input) noexcept;
93106

94107
/**
108+
* @private
95109
* Returns true if the length of the domain name and its labels are according to
96110
* the specifications. The length of the domain must be 255 octets (253
97111
* characters not including the last 2 which are the empty label reserved at the

include/ada/helpers.h

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <optional>
1414

1515
/**
16+
* These functions are not part of our public API and may
17+
* change at any time.
18+
*
1619
* @private
1720
* @namespace ada::helpers
1821
* @brief Includes the definitions for helper functions
@@ -175,6 +178,7 @@ inline void inner_concat(std::string& buffer, T t, Args... args) {
175178
}
176179

177180
/**
181+
* @private
178182
* Concatenate the arguments and return a string.
179183
* @returns a string
180184
*/
@@ -186,6 +190,7 @@ std::string concat(Args... args) {
186190
}
187191

188192
/**
193+
* @private
189194
* @return Number of leading zeroes.
190195
*/
191196
inline int leading_zeroes(uint32_t input_num) noexcept {
@@ -199,6 +204,7 @@ inline int leading_zeroes(uint32_t input_num) noexcept {
199204
}
200205

201206
/**
207+
* @private
202208
* Counts the number of decimal digits necessary to represent x.
203209
* faster than std::to_string(x).size().
204210
* @return digit count

include/ada/unicode-inl.h

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include "ada/unicode.h"
99

1010
/**
11+
* Unicode operations. These functions are not part of our public API and may
12+
* change at any time.
13+
*
14+
* private
1115
* @namespace ada::unicode
1216
* @brief Includes the declarations for unicode operations
1317
*/

include/ada/unicode.h

+25
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
#include <optional>
1313

1414
/**
15+
* Unicode operations. These functions are not part of our public API and may
16+
* change at any time.
17+
*
18+
* @private
1519
* @namespace ada::unicode
1620
* @brief Includes the definitions for unicode operations
1721
*/
1822
namespace ada::unicode {
1923

2024
/**
25+
* @private
2126
* We receive a UTF-8 string representing a domain name.
2227
* If the string is percent encoded, we apply percent decoding.
2328
*
@@ -61,11 +66,13 @@ bool to_ascii(std::optional<std::string>& out, std::string_view plain,
6166
size_t first_percent);
6267

6368
/**
69+
* @private
6470
* @see https://www.unicode.org/reports/tr46/#ToUnicode
6571
*/
6672
std::string to_unicode(std::string_view input);
6773

6874
/**
75+
* @private
6976
* Checks if the input has tab or newline characters.
7077
*
7178
* @attention The has_tabs_or_newline function is a bottleneck and it is simple
@@ -75,19 +82,22 @@ ada_really_inline bool has_tabs_or_newline(
7582
std::string_view user_input) noexcept;
7683

7784
/**
85+
* @private
7886
* Checks if the input is a forbidden host code point.
7987
* @see https://url.spec.whatwg.org/#forbidden-host-code-point
8088
*/
8189
ada_really_inline constexpr bool is_forbidden_host_code_point(char c) noexcept;
8290

8391
/**
92+
* @private
8493
* Checks if the input contains a forbidden domain code point.
8594
* @see https://url.spec.whatwg.org/#forbidden-domain-code-point
8695
*/
8796
ada_really_inline constexpr bool contains_forbidden_domain_code_point(
8897
const char* input, size_t length) noexcept;
8998

9099
/**
100+
* @private
91101
* Checks if the input contains a forbidden domain code point in which case
92102
* the first bit is set to 1. If the input contains an upper case ASCII letter,
93103
* then the second bit is set to 1.
@@ -98,18 +108,21 @@ contains_forbidden_domain_code_point_or_upper(const char* input,
98108
size_t length) noexcept;
99109

100110
/**
111+
* @private
101112
* Checks if the input is a forbidden domain code point.
102113
* @see https://url.spec.whatwg.org/#forbidden-domain-code-point
103114
*/
104115
ada_really_inline constexpr bool is_forbidden_domain_code_point(
105116
char c) noexcept;
106117

107118
/**
119+
* @private
108120
* Checks if the input is alphanumeric, '+', '-' or '.'
109121
*/
110122
ada_really_inline constexpr bool is_alnum_plus(char c) noexcept;
111123

112124
/**
125+
* @private
113126
* @details An ASCII hex digit is an ASCII upper hex digit or ASCII lower hex
114127
* digit. An ASCII upper hex digit is an ASCII digit or a code point in the
115128
* range U+0041 (A) to U+0046 (F), inclusive. An ASCII lower hex digit is an
@@ -118,6 +131,7 @@ ada_really_inline constexpr bool is_alnum_plus(char c) noexcept;
118131
ada_really_inline constexpr bool is_ascii_hex_digit(char c) noexcept;
119132

120133
/**
134+
* @private
121135
* Checks if the input is a C0 control or space character.
122136
*
123137
* @details A C0 control or space is a C0 control or U+0020 SPACE.
@@ -127,38 +141,44 @@ ada_really_inline constexpr bool is_ascii_hex_digit(char c) noexcept;
127141
ada_really_inline constexpr bool is_c0_control_or_space(char c) noexcept;
128142

129143
/**
144+
* @private
130145
* Checks if the input is a ASCII tab or newline character.
131146
*
132147
* @details An ASCII tab or newline is U+0009 TAB, U+000A LF, or U+000D CR.
133148
*/
134149
ada_really_inline constexpr bool is_ascii_tab_or_newline(char c) noexcept;
135150

136151
/**
152+
* @private
137153
* @details A double-dot path segment must be ".." or an ASCII case-insensitive
138154
* match for ".%2e", "%2e.", or "%2e%2e".
139155
*/
140156
ada_really_inline ada_constexpr bool is_double_dot_path_segment(
141157
std::string_view input) noexcept;
142158

143159
/**
160+
* @private
144161
* @details A single-dot path segment must be "." or an ASCII case-insensitive
145162
* match for "%2e".
146163
*/
147164
ada_really_inline constexpr bool is_single_dot_path_segment(
148165
std::string_view input) noexcept;
149166

150167
/**
168+
* @private
151169
* @details ipv4 character might contain 0-9 or a-f character ranges.
152170
*/
153171
ada_really_inline constexpr bool is_lowercase_hex(char c) noexcept;
154172

155173
/**
174+
* @private
156175
* @details Convert hex to binary. Caller is responsible to ensure that
157176
* the parameter is an hexadecimal digit (0-9, A-F, a-f).
158177
*/
159178
ada_really_inline unsigned constexpr convert_hex_to_binary(char c) noexcept;
160179

161180
/**
181+
* @private
162182
* first_percent should be = input.find('%')
163183
*
164184
* @todo It would be faster as noexcept maybe, but it could be unsafe since.
@@ -169,19 +189,22 @@ ada_really_inline unsigned constexpr convert_hex_to_binary(char c) noexcept;
169189
std::string percent_decode(std::string_view input, size_t first_percent);
170190

171191
/**
192+
* @private
172193
* Returns a percent-encoding string whether percent encoding was needed or not.
173194
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
174195
*/
175196
std::string percent_encode(std::string_view input,
176197
const uint8_t character_set[]);
177198
/**
199+
* @private
178200
* Returns a percent-encoded string version of input, while starting the percent
179201
* encoding at the provided index.
180202
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
181203
*/
182204
std::string percent_encode(std::string_view input,
183205
const uint8_t character_set[], size_t index);
184206
/**
207+
* @private
185208
* Returns true if percent encoding was needed, in which case, we store
186209
* the percent-encoded content in 'out'. If the boolean 'append' is set to
187210
* true, the content is appended to 'out'.
@@ -192,12 +215,14 @@ template <bool append>
192215
bool percent_encode(std::string_view input, const uint8_t character_set[],
193216
std::string& out);
194217
/**
218+
* @private
195219
* Returns the index at which percent encoding should start, or (equivalently),
196220
* the length of the prefix that does not require percent encoding.
197221
*/
198222
ada_really_inline size_t percent_encode_index(std::string_view input,
199223
const uint8_t character_set[]);
200224
/**
225+
* @private
201226
* Lowers the string in-place, assuming that the content is ASCII.
202227
* Return true if the content was ASCII.
203228
*/

0 commit comments

Comments
 (0)