mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-09 14:20:06 +00:00
doc: simplity example code a bit
This commit is contained in:
parent
43183e2ad1
commit
d3de136562
@ -28,6 +28,10 @@ toml11 is a C++11 (or later) header-only toml parser/encoder depending only on C
|
||||
|
||||
int main()
|
||||
{
|
||||
// ```toml
|
||||
// title = "an example toml file"
|
||||
// nums = [3, 1, 4, 1, 5]
|
||||
// ```
|
||||
auto data = toml::parse("example.toml");
|
||||
|
||||
// find a value with the specified type from a table
|
||||
@ -37,9 +41,9 @@ int main()
|
||||
std::vector<int> nums = toml::find<std::vector<int>>(data, "nums");
|
||||
|
||||
// access with STL-like manner
|
||||
if(not data.at("a").contains("b"))
|
||||
if(not data.contains("foo"))
|
||||
{
|
||||
data["a"]["b"] = "c";
|
||||
data["foo"] = "bar";
|
||||
}
|
||||
|
||||
// pass a fallback
|
||||
|
Loading…
Reference in New Issue
Block a user