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>>;
93 [[nodiscard]]
auto size() const noexcept -> std::uint64_t;
96 [[nodiscard]] auto
empty() const noexcept ->
bool;
105 [[nodiscard]] auto begin() const noexcept
109 [[nodiscard]] auto end() const noexcept
120 template <typename Container,
121 typename = std::void_t<typename Container::key_type>>
123 const Container &variables,
128 const auto iterator{find_variable(variables, name)};
129 if (iterator == variables.end()) {
132 return std::make_tuple(std::string_view{iterator->second},
133 std::nullopt,
false);
142 template <
typename Container>
143 static auto find_variable(
const Container &variables,
144 const std::string_view name) {
145 if constexpr (
requires { variables.find(name); }) {
146 return variables.find(name);
148 return variables.find(
typename Container::key_type{name});
156#pragma warning(disable : 4251)
158 std::vector<URITemplateToken> tokens_;
160#pragma warning(default : 4251)
auto size() const noexcept -> std::uint64_t
Get the number of tokens in the template.
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