From fec4e1db9a25862429b314a9b7097ec053900387 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sat, 15 Jun 2019 20:34:20 +0900 Subject: [PATCH] doc(WIP): add source_location to README --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7163a8d..c1d50ec 100644 --- a/README.md +++ b/README.md @@ -995,9 +995,34 @@ you will get an error message like this. ### Obtaining location information -`source_location` +You can get `source_location` by calling `toml::value::location()`. -TODO +```cpp +const toml::value v = /**/; +const toml::source_location sl = v.location(); +``` + +You can use it to format your own error message. + +```cpp +class source_location { + public: + +// +-- line() +-- region of interest (region() == 9) +// v .---+---. +// 12 | value = "foo bar" +// ^ +// +-- column() + + std::uint_least32_t line() const noexcept; + std::uint_least32_t column() const noexcept; + std::uint_least32_t region() const noexcept; + + std::string const& file_name() const noexcept; + std::string const& line_str() const noexcept; // the line itself +// ... +}; +``` ## Serializing TOML data