tinytoml
tinytoml copied to clipboard
Check state of input stream before parsing
Currently passing failed/bad stream results in successful parsing(which actually parses nothing at all).
Simple case would be pass ifstream to non-existing fail
std::ifstream ifs("foo.toml");
toml::ParseResult pr = toml::parse(ifs);
if (!pr.valid()) {
cout << pr.errorReason << endl;
return;
}
It is a bit tricky as it should be up to user to provide a valid output. But on other hand there is no way it would be possible parse failed/bad stream.
What do you think? Should there be error on such cases?
@DoumanAsh Thanks for reporting... Yeah, I think it's not good. It should be an error. I'll fix it.