1#ifndef SOURCEMETA_CORE_URITEMPLATE_H_
2#define SOURCEMETA_CORE_URITEMPLATE_H_
4#ifndef SOURCEMETA_CORE_URITEMPLATE_EXPORT
5#include <sourcemeta/core/uritemplate_export.h>
9#include <sourcemeta/core/uritemplate_error.h>
10#include <sourcemeta/core/uritemplate_router.h>
11#include <sourcemeta/core/uritemplate_token.h>
33namespace sourcemeta::core {
38 std::tuple<std::string_view, std::optional<std::string_view>,
bool>>;
60 std::optional<std::pair<URITemplateToken, std::size_t>>;
106 [[nodiscard]]
static auto is_literal(
char32_t codepoint)
noexcept -> bool;
109 [[nodiscard]]
auto size() const noexcept -> std::uint64_t;
112 [[nodiscard]] auto
empty() const noexcept ->
bool;
121 [[nodiscard]] auto begin() const noexcept
125 [[nodiscard]] auto end() const noexcept
136 template <typename Container,
137 typename = std::void_t<typename Container::key_type>>
139 const Container &variables,
144 const auto iterator{find_variable(variables, name)};
145 if (iterator == variables.end()) {
148 return std::make_tuple(std::string_view{iterator->second},
149 std::nullopt,
false);
157 template <
typename Container>
158 static auto find_variable(
const Container &variables,
159 const std::string_view name) {
160 if constexpr (
requires { variables.find(name); }) {
161 return variables.find(name);
163 return variables.find(
typename Container::key_type{name});
172#pragma warning(disable : 4251)
174 std::vector<URITemplateToken> tokens_;
auto size() const noexcept -> std::uint64_t
Get the number of tokens in the template.
static auto is_literal(char32_t codepoint) noexcept -> bool
auto empty() const noexcept -> bool
Check if the template is empty.
auto expand(const std::function< URITemplateValue(std::string_view)> &callback, URITemplateExpansionMode mode=URITemplateExpansionMode::URI) const -> std::string
static auto is_uritemplate(std::string_view input) noexcept -> bool
auto at(std::size_t index) const &-> const URITemplateToken &
Get the token at the given index.
URITemplate(const std::string_view source)
std::optional< std::pair< URITemplateToken, std::size_t > > URITemplateParseResult
Definition uritemplate.h:59
std::variant< URITemplateTokenLiteral, URITemplateTokenVariable, URITemplateTokenReservedExpansion, URITemplateTokenFragmentExpansion, URITemplateTokenLabelExpansion, URITemplateTokenPathExpansion, URITemplateTokenPathParameterExpansion, URITemplateTokenQueryExpansion, URITemplateTokenQueryContinuationExpansion > URITemplateToken
Definition uritemplate_token.h:184
std::optional< std::tuple< std::string_view, std::optional< std::string_view >, bool > > URITemplateValue
Definition uritemplate.h:37
URITemplateExpansionMode
Definition uritemplate.h:42
@ IRI
Definition uritemplate.h:53