Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
uritemplate_token.h
1#ifndef SOURCEMETA_CORE_URITEMPLATE_TOKEN_H_
2#define SOURCEMETA_CORE_URITEMPLATE_TOKEN_H_
3
4#ifndef SOURCEMETA_CORE_URITEMPLATE_EXPORT
5#include <sourcemeta/core/uritemplate_export.h>
6#endif
7
8#include <cstdint> // std::uint16_t
9#include <string_view> // std::string_view
10#include <variant> // std::variant
11#include <vector> // std::vector
12
13namespace sourcemeta::core {
14
15// Exporting symbols that depends on the standard C++ library is considered
16// safe.
17// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
18#if defined(_MSC_VER)
19#pragma warning(push)
20#pragma warning(disable : 4251)
21#endif
22
25struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateTokenLiteral {
27 std::string_view value;
28};
29
32struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateVariableSpecification {
34 std::string_view name;
35 // As per the RFC, the range is 1-9999. 0 means "no prefix length"
37 std::uint16_t length{0};
39 bool explode{false};
40};
41
44struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateTokenVariable {
46 std::vector<URITemplateVariableSpecification> variables;
48 static constexpr char separator = ',';
50 static constexpr bool named = false;
52 static constexpr bool allow_reserved = false;
53};
54
57struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateTokenReservedExpansion {
59 std::vector<URITemplateVariableSpecification> variables;
61 static constexpr char op = '+';
63 static constexpr char separator = ',';
65 static constexpr bool named = false;
67 static constexpr bool allow_reserved = true;
68};
69
72struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateTokenFragmentExpansion {
74 std::vector<URITemplateVariableSpecification> variables;
76 static constexpr char op = '#';
78 static constexpr char separator = ',';
80 static constexpr char prefix = '#';
82 static constexpr bool named = false;
84 static constexpr bool allow_reserved = true;
85};
86
89struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateTokenLabelExpansion {
91 std::vector<URITemplateVariableSpecification> variables;
93 static constexpr char op = '.';
95 static constexpr char separator = '.';
97 static constexpr char prefix = '.';
99 static constexpr bool named = false;
101 static constexpr bool allow_reserved = false;
102};
103
106struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateTokenPathExpansion {
108 std::vector<URITemplateVariableSpecification> variables;
110 static constexpr char op = '/';
112 static constexpr char separator = '/';
114 static constexpr char prefix = '/';
116 static constexpr bool named = false;
118 static constexpr bool allow_reserved = false;
119};
120
123struct SOURCEMETA_CORE_URITEMPLATE_EXPORT
126 std::vector<URITemplateVariableSpecification> variables;
128 static constexpr char op = ';';
130 static constexpr char separator = ';';
132 static constexpr char prefix = ';';
134 static constexpr bool named = true;
136 static constexpr bool allow_reserved = false;
137};
138
141struct SOURCEMETA_CORE_URITEMPLATE_EXPORT URITemplateTokenQueryExpansion {
143 std::vector<URITemplateVariableSpecification> variables;
145 static constexpr char op = '?';
147 static constexpr char separator = '&';
149 static constexpr char prefix = '?';
151 static constexpr bool named = true;
153 static constexpr bool allow_reserved = false;
155 static constexpr char empty_suffix = '=';
156};
157
160struct SOURCEMETA_CORE_URITEMPLATE_EXPORT
163 std::vector<URITemplateVariableSpecification> variables;
165 static constexpr char op = '&';
167 static constexpr char separator = '&';
169 static constexpr char prefix = '&';
171 static constexpr bool named = true;
173 static constexpr bool allow_reserved = false;
175 static constexpr char empty_suffix = '=';
176};
177
178#if defined(_MSC_VER)
179#pragma warning(pop)
180#endif
181
184using URITemplateToken = std::variant<
190
191} // namespace sourcemeta::core
192
193#endif
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:84
static constexpr char op
The operator character that introduces the expression.
Definition uritemplate_token.h:110
static constexpr char prefix
The character prepended to the expansion output.
Definition uritemplate_token.h:114
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:171
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:167
static constexpr char empty_suffix
The character appended to names with empty values.
Definition uritemplate_token.h:175
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:151
static constexpr char prefix
The character prepended to the expansion output.
Definition uritemplate_token.h:169
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:74
static constexpr char op
The operator character that introduces the expression.
Definition uritemplate_token.h:128
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:108
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:65
static constexpr char op
The operator character that introduces the expression.
Definition uritemplate_token.h:145
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:173
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:78
static constexpr char prefix
The character prepended to the expansion output.
Definition uritemplate_token.h:132
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:63
std::string_view value
The literal string content.
Definition uritemplate_token.h:27
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:153
static constexpr char op
The operator character that introduces the expression.
Definition uritemplate_token.h:61
static constexpr char prefix
The character prepended to the expansion output.
Definition uritemplate_token.h:97
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:116
static constexpr char prefix
The character prepended to the expansion output.
Definition uritemplate_token.h:149
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:91
static constexpr char op
The operator character that introduces the expression.
Definition uritemplate_token.h:76
static constexpr char op
The operator character that introduces the expression.
Definition uritemplate_token.h:165
std::uint16_t length
The maximum prefix length to apply to the value.
Definition uritemplate_token.h:37
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:48
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:134
static constexpr char op
The operator character that introduces the expression.
Definition uritemplate_token.h:93
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:101
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:82
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:126
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:147
bool explode
Whether the variable is exploded into multiple values.
Definition uritemplate_token.h:39
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:130
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:50
static constexpr bool named
Whether the expansion includes variable names.
Definition uritemplate_token.h:99
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:118
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:112
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:136
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:163
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:52
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:143
static constexpr char separator
The character that separates expanded values.
Definition uritemplate_token.h:95
static constexpr char prefix
The character prepended to the expansion output.
Definition uritemplate_token.h:80
static constexpr char empty_suffix
The character appended to names with empty values.
Definition uritemplate_token.h:155
std::string_view name
The variable name.
Definition uritemplate_token.h:34
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:59
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:46
static constexpr bool allow_reserved
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:67
std::variant< URITemplateTokenLiteral, URITemplateTokenVariable, URITemplateTokenReservedExpansion, URITemplateTokenFragmentExpansion, URITemplateTokenLabelExpansion, URITemplateTokenPathExpansion, URITemplateTokenPathParameterExpansion, URITemplateTokenQueryExpansion, URITemplateTokenQueryContinuationExpansion > URITemplateToken
Definition uritemplate_token.h:184
Definition uritemplate_token.h:89
Definition uritemplate_token.h:25
Definition uritemplate_token.h:106
Definition uritemplate_token.h:141
Definition uritemplate_token.h:44