You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After parsing this, I'd like to be able to print an error message like:
[error] Key `bar` is not allowed
--> example.toml
2 | bar = 2
| ~~~ here
And I... can't seem to figure out how to make this happen. toml::key is an alias to std::string and not toml::string, so it loses (and the parser doesn't seem to track) the region information. I tried to get something close by using toml::get_region( toml::find( data, "bar" ) ) to get the value's region and trying to work backwards in the line from there, but base_region doesn't give me something like location::retrace nor can I construct a new location covering [line_begin(), begin()).
How can I get a source_location describing the location of a key in a table?
The text was updated successfully, but these errors were encountered:
Sorry, currently, it does not have the feature you said. To do that, as you pointed out, we need to define toml::key as a struct and add region information in parser. So far, I personally did not need to do that and no one craimed it. That is why it does not have the feature.
I'm now refactoring region related stuff to reduce complexity around it and once I've done it, maybe we would have full control on it. But since the region is an internal component, essentially interface might be changed without anouncement even in a minor release.
Since region of a key seems to be useful feature, so I will consider implementing it in the future release.
Suppose I have the following
example.toml
file:After parsing this, I'd like to be able to print an error message like:
And I... can't seem to figure out how to make this happen.
toml::key
is an alias tostd::string
and nottoml::string
, so it loses (and the parser doesn't seem to track) the region information. I tried to get something close by usingtoml::get_region( toml::find( data, "bar" ) )
to get the value's region and trying to work backwards in the line from there, butbase_region
doesn't give me something likelocation::retrace
nor can I construct a newlocation
covering[line_begin(), begin())
.How can I get a
source_location
describing the location of a key in a table?The text was updated successfully, but these errors were encountered: