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 OPERATOR = '+';
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 OPERATOR = '#';
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 OPERATOR = '.';
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 OPERATOR = '/';
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 OPERATOR = ';';
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 OPERATOR = '?';
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 OPERATOR = '&';
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 char OPERATOR
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:118
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:116
static constexpr char SEPARATOR
The character that separates expanded values.
Definition uritemplate_token.h:48
static constexpr char PREFIX
The character prepended to the expansion output.
Definition uritemplate_token.h:97
static constexpr bool ALLOW_RESERVED
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:84
static constexpr char SEPARATOR
The character that separates expanded values.
Definition uritemplate_token.h:63
static constexpr bool NAMED
Whether the expansion includes variable names.
Definition uritemplate_token.h:82
static constexpr char PREFIX
The character prepended to the expansion output.
Definition uritemplate_token.h:132
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:74
static constexpr bool NAMED
Whether the expansion includes variable names.
Definition uritemplate_token.h:65
static constexpr char PREFIX
The character prepended to the expansion output.
Definition uritemplate_token.h:114
static constexpr char SEPARATOR
The character that separates expanded values.
Definition uritemplate_token.h:78
static constexpr char SEPARATOR
The character that separates expanded values.
Definition uritemplate_token.h:95
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:108
static constexpr char SEPARATOR
The character that separates expanded values.
Definition uritemplate_token.h:167
std::string_view value
The literal string content.
Definition uritemplate_token.h:27
static constexpr char OPERATOR
The operator character that introduces the expression.
Definition uritemplate_token.h:61
static constexpr char OPERATOR
The operator character that introduces the expression.
Definition uritemplate_token.h:76
static constexpr bool ALLOW_RESERVED
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:52
static constexpr char OPERATOR
The operator character that introduces the expression.
Definition uritemplate_token.h:165
static constexpr char PREFIX
The character prepended to the expansion output.
Definition uritemplate_token.h:80
static constexpr bool ALLOW_RESERVED
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:153
static constexpr bool NAMED
Whether the expansion includes variable names.
Definition uritemplate_token.h:171
static constexpr char OPERATOR
The operator character that introduces the expression.
Definition uritemplate_token.h:145
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:91
std::uint16_t length
The maximum prefix length to apply to the value.
Definition uritemplate_token.h:37
static constexpr bool NAMED
Whether the expansion includes variable names.
Definition uritemplate_token.h:134
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
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:126
static constexpr bool ALLOW_RESERVED
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:67
static constexpr bool NAMED
Whether the expansion includes variable names.
Definition uritemplate_token.h:151
static constexpr char OPERATOR
The operator character that introduces the expression.
Definition uritemplate_token.h:128
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 bool ALLOW_RESERVED
Whether reserved characters are preserved unencoded.
Definition uritemplate_token.h:173
static constexpr char OPERATOR
The operator character that introduces the expression.
Definition uritemplate_token.h:110
static constexpr char EMPTY_SUFFIX
The character appended to names with empty values.
Definition uritemplate_token.h:155
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:163
static constexpr bool NAMED
Whether the expansion includes variable names.
Definition uritemplate_token.h:99
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:112
static constexpr char PREFIX
The character prepended to the expansion output.
Definition uritemplate_token.h:169
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
static constexpr char EMPTY_SUFFIX
The character appended to names with empty values.
Definition uritemplate_token.h:175
std::vector< URITemplateVariableSpecification > variables
The variable specifications to expand.
Definition uritemplate_token.h:46
static constexpr char PREFIX
The character prepended to the expansion output.
Definition uritemplate_token.h:149
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