Struct IRIFactory¶
Defined in File IRIFactory.hpp
Struct Documentation¶
-
struct IRIFactory¶
Stores a base IRI and a prefix map and allows to create IRIs by possibly applying both.
Public Types
-
using prefix_map_type = boost::container::flat_map<std::string, std::string, std::less<>>¶
-
using const_iterator = prefix_map_type::const_iterator¶
-
using const_reverse_iterator = prefix_map_type::const_reverse_iterator¶
Public Functions
-
explicit IRIFactory(std::string_view base = default_base)¶
Creates a IRIFactory with empty prefix map and a given base IRI. Throws if base is invalid.
- Parameters:
base –
-
explicit IRIFactory(prefix_map_type &&prefixes, std::string_view base = default_base)¶
Creates a IRIFactory with a given prefix map and a given base IRI. Throws if base is invalid.
- Parameters:
prefixes –
base –
-
IRIFactory(IRIFactory&&) noexcept = default¶
-
IRIFactory &operator=(IRIFactory&&) noexcept = default¶
-
inline const_iterator begin() const noexcept¶
-
inline const_iterator end() const noexcept¶
-
inline const_reverse_iterator rbegin() const noexcept¶
-
inline const_reverse_iterator rend() const noexcept¶
-
nonstd::expected<IRI, IRIFactoryError> from_relative(std::string_view rel, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) const noexcept¶
Creates a IRI from a relative IRI. Implements https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.
- Parameters:
rel –
storage –
- Returns:
-
nonstd::expected<IRI, IRIFactoryError> from_maybe_relative(std::string_view rel, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) const noexcept¶
Creates a IRI from a possibly relative IRI. if rel is relative, returns the same as from_relative, otherwise returns rel unchanged.
- Parameters:
rel –
storage –
- Returns:
-
nonstd::expected<IRI, IRIFactoryError> from_prefix(std::string_view prefix, std::string_view local, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) const¶
Creates a IRI by looking up a prefix in the prefix map and possibly resolving a relative IRI.
- Parameters:
prefix –
local –
storage –
- Returns:
-
IRIFactoryError assign_prefix(std::string_view prefix, std::string_view expanded)¶
Creates or changes a prefix.
- Parameters:
prefix –
expanded –
-
void assign_prefix_unchecked(std::string_view prefix, std::string_view expanded)¶
Creates or changes a prefix. expects prefix and expanded to be valid (i.e. not contain spaces or other chars that are invalid in an IRI). this is ensured by assign_prefix
- Parameters:
prefix –
expanded –
-
void clear_prefix(std::string_view prefix)¶
Removes a prefix.
- Parameters:
prefix –
-
IRIFactoryError set_base(std::string_view b) noexcept¶
Changes the base IRI. Validates the new base IRI before setting.
- Parameters:
b –
- Returns:
Public Static Functions
-
static nonstd::expected<IRI, IRIFactoryError> create_and_validate(std::string_view iri, storage::DynNodeStoragePtr node_storage = storage::default_node_storage) noexcept¶
validates the given IRI and creates it in the given node storage, if valid.
- Parameters:
iri –
storage –
- Returns:
Public Static Attributes
-
static constexpr std::string_view default_base = "http://example.org/"¶
-
using prefix_map_type = boost::container::flat_map<std::string, std::string, std::less<>>¶