mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-16 16:28:09 +08:00
doc: simplity example code a bit
This commit is contained in:
@@ -28,6 +28,10 @@ toml11 is a C++11 (or later) header-only toml parser/encoder depending only on C
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
// ```toml
|
||||||
|
// title = "an example toml file"
|
||||||
|
// nums = [3, 1, 4, 1, 5]
|
||||||
|
// ```
|
||||||
auto data = toml::parse("example.toml");
|
auto data = toml::parse("example.toml");
|
||||||
|
|
||||||
// find a value with the specified type from a table
|
// 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");
|
std::vector<int> nums = toml::find<std::vector<int>>(data, "nums");
|
||||||
|
|
||||||
// access with STL-like manner
|
// 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
|
// pass a fallback
|
||||||
|
Reference in New Issue
Block a user