doc(WIP): add source_location to README

This commit is contained in:
ToruNiina 2019-06-15 20:34:20 +09:00
parent 8665272bab
commit fec4e1db9a

View File

@ -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