toml::path_component class

Represents a single component of a complete 'TOML-path': either a key or an array index.

Constructors, destructors, conversion operators

path_component()
Default constructor (creates an empty key).
path_component(size_t index) noexcept
Constructor for a path component that is an array index.
path_component(std::string_view key)
Constructor for a path component that is a key string.
path_component(std::wstring_view key)
Constructor for a path component that is a key string.
path_component(const path_component& pc)
Copy constructor.
path_component(path_component&& pc) noexcept
Move constructor.
~path_component() noexcept
Destructor.

Public functions

auto operator=(const path_component& rhs) -> path_component&
Copy-assignment operator.
auto operator=(path_component&& rhs) -> path_component& noexcept
Move-assignment operator.
auto operator=(size_t new_index) -> path_component& noexcept
Assigns an array index to this path component.
auto operator=(std::string_view new_key) -> path_component&
Assigns a path key to this path component.
auto operator=(std::wstring_view new_key) -> path_component&
Assigns a path key to this path component.
auto type() const -> path_component_type noexcept
Retrieve the type of this path component, either path_component::key or path_component::array_index.

Array index accessors

auto index() const -> size_t noexcept
Returns the array index (const lvalue overload).
operator size_t() const explicit noexcept
Returns the array index (const lvalue).

Equality

auto operator!=(const path_component& lhs, const path_component& rhs) -> bool noexcept
Returns true if two path components do not represent the same key or array index.
auto operator==(const path_component& lhs, const path_component& rhs) -> bool noexcept
Returns true if two path components represent the same key or array index.

Key accessors

auto key() const -> const std::string& noexcept
Returns the key string.
operator const std::string&() const explicit noexcept
Returns the key string.

Function documentation

toml::path_component::path_component(std::wstring_view key)

Constructor for a path component that is a key string.

path_component& toml::path_component::operator=(std::wstring_view new_key)

Assigns a path key to this path component.