toml::source_region struct

A source document region.

auto tbl = toml::parse_file("config.toml"sv);
if (auto server = tbl.get("server"))
{
    std::cout << "begin: "sv << server->source().begin << "\n";
    std::cout << "end: "sv << server->source().end << "\n";
    std::cout << "path: "sv << *server->source().path << "\n";
}
begin: line 3, column 1
end: line 3, column 22
path: config.toml

Public functions

auto wide_path() const -> optional<std::wstring>
The path to the corresponding source document as a wide-string.

Public variables

source_position begin
The beginning of the region (inclusive).
source_position end
The end of the region (exclusive).
source_path_ptr path
The path to the corresponding source document.

Friends

auto operator<<(std::ostream& lhs, const source_region& rhs) -> std::ostream&
Prints a source_region to a stream.

Function documentation

optional<std::wstring> toml::source_region::wide_path() const

The path to the corresponding source document as a wide-string.

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

Prints a source_region to a stream.

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

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

Variable documentation

source_path_ptr toml::source_region::path

The path to the corresponding source document.