toml::key class

A key parsed from a TOML document.

These are used as the internal keys for a toml::table:

const toml::table tbl = R"(
    a = 1
      b = 2
        c = 3
)"_toml;

for (auto&& [k, v] : tbl)
    std::cout << "key '"sv << k << "' defined at "sv << k.source() << "\n";
key 'a' defined at line 2, column 5
key 'b' defined at line 3, column 7
key 'c' defined at line 4, column 9

Constructors, destructors, conversion operators

key() defaulted noexcept
Default constructor.
key(std::string_view k, source_region&& src = {}) explicit
Constructs a key from a string view and source region.
key(std::string_view k, const source_region& src) explicit
Constructs a key from a string view and source region.
key(std::string&& k, source_region&& src = {}) explicit noexcept
Constructs a key from a string and source region.
key(std::string&& k, const source_region& src) explicit noexcept
Constructs a key from a string and source region.
key(const char* k, source_region&& src = {}) explicit
Constructs a key from a c-string and source region.
key(const char* k, const source_region& src) explicit
Constructs a key from a c-string view and source region.
key(std::wstring_view k, source_region&& src = {}) explicit
Constructs a key from a wide string view and source region.
key(std::wstring_view k, const source_region& src) explicit
Constructs a key from a wide string and source region.

Equality and Comparison

auto operator!=(const key& lhs, const key& rhs) →  bool noexcept
Returns true if lhs.str() != rhs.str().
auto operator!=(const key& lhs, std::string_view rhs) →  bool noexcept
Returns true if lhs.str() != rhs.
auto operator!=(std::string_view lhs, const key& rhs) →  bool noexcept
Returns true if lhs != rhs.str().
auto operator<(const key& lhs, const key& rhs) →  bool noexcept
Returns true if lhs.str() < rhs.str().
auto operator<(const key& lhs, std::string_view rhs) →  bool noexcept
Returns true if lhs.str() < rhs.
auto operator<(std::string_view lhs, const key& rhs) →  bool noexcept
Returns true if lhs < rhs.str().
auto operator<=(const key& lhs, const key& rhs) →  bool noexcept
Returns true if lhs.str() <= rhs.str().
auto operator<=(const key& lhs, std::string_view rhs) →  bool noexcept
Returns true if lhs.str() <= rhs.
auto operator<=(std::string_view lhs, const key& rhs) →  bool noexcept
Returns true if lhs <= rhs.str().
auto operator==(const key& lhs, const key& rhs) →  bool noexcept
Returns true if lhs.str() == rhs.str().
auto operator==(const key& lhs, std::string_view rhs) →  bool noexcept
Returns true if lhs.str() == rhs.
auto operator==(std::string_view lhs, const key& rhs) →  bool noexcept
Returns true if lhs == rhs.str().
auto operator>(const key& lhs, const key& rhs) →  bool noexcept
Returns true if lhs.str() > rhs.str().
auto operator>(const key& lhs, std::string_view rhs) →  bool noexcept
Returns true if lhs.str() > rhs.
auto operator>(std::string_view lhs, const key& rhs) →  bool noexcept
Returns true if lhs > rhs.str().
auto operator>=(const key& lhs, const key& rhs) →  bool noexcept
Returns true if lhs.str() >= rhs.str().
auto operator>=(const key& lhs, std::string_view rhs) →  bool noexcept
Returns true if lhs.str() >= rhs.
auto operator>=(std::string_view lhs, const key& rhs) →  bool noexcept
Returns true if lhs >= rhs.str().

Iteration

using const_iterator = const char*
A const iterator for iterating over the characters in the key.
using iterator = const_iterator
A const iterator for iterating over the characters in the key.
auto begin() const →  const_iterator noexcept
Returns an iterator to the first character in the key's backing string.
auto end() const →  const_iterator noexcept
Returns an iterator to one-past-the-last character in the key's backing string.

Metadata

auto source() const →  const source_region& noexcept
Returns the source region responsible for specifying this key during parsing.

String operations

auto data() const →  const char* noexcept
Returns a pointer to the start of the key's underlying string.
auto empty() const →  bool noexcept
Returns true if the key's underlying string is empty.
auto length() const →  size_t noexcept
Returns the length of the key's underlying string.
operator std::string_view() const noexcept
Returns a view of the key's underlying string.
auto str() const →  std::string_view noexcept
Returns a view of the key's underlying string.

Friends

auto operator<<(std::ostream& lhs, const key& rhs) →  std::ostream&
Prints the key's underlying string out to the stream.

Function documentation

toml::key::key(std::wstring_view k, source_region&& src = {}) explicit

Constructs a key from a wide string view and source region.

toml::key::key(std::wstring_view k, const source_region& src) explicit

Constructs a key from a wide string and source region.