toml::source_position struct

A source document line-and-column pair.

auto table = toml::parse_file("config.toml"sv);
std::cout << "The node 'description' was defined at "sv
    << table.get("description")->source().begin()
    << "\n";
The value 'description' was defined at line 7, column 15

Constructors, destructors, conversion operators

operator bool() const explicit constexpr noexcept
Returns true if both line and column numbers are non-zero.

Public variables

source_index line
The line number.
source_index column
The column number.

Friends

auto operator!=(const source_position& lhs, const source_position& rhs) →  bool constexpr noexcept
Returns true if two source_positions do not represent the same line and column.
auto operator<(const source_position& lhs, const source_position& rhs) →  bool constexpr noexcept
Returns true if the LHS position is before the RHS position.
auto operator<<(std::ostream& lhs, const source_position& rhs) →  std::ostream&
Prints a source_position to a stream.
auto operator<=(const source_position& lhs, const source_position& rhs) →  bool constexpr noexcept
Returns true if the LHS position is before the RHS position or equal to it.
auto operator==(const source_position& lhs, const source_position& rhs) →  bool constexpr noexcept
Returns true if two source_positions represent the same line and column.

Function documentation

std::ostream& operator<<(std::ostream& lhs, const source_position& rhs)

Prints a source_position to a stream.

Parameters
lhs The stream.
rhs The source_position.
Returns The input stream.
auto tbl = toml::parse("bar = 42"sv);

std::cout << "The value for 'bar' was found on "sv
    << tbl.get("bar")->source().begin()
    << "\n";
The value for 'bar' was found on line 1, column 7

Variable documentation

source_index toml::source_position::line

The line number.

source_index toml::source_position::column

The column number.