marzer / tomlplusplus

Header-only TOML config file parser and serializer for C++17.
https://marzer.github.io/tomlplusplus/
MIT License
1.53k stars 146 forks source link

Provide a method to write value from absolute path #162

Closed laper32 closed 2 years ago

laper32 commented 2 years ago

Is your feature request related to a problem? Please describe.

We have at_path() which can provide us to use absolute path to get value. How about we also provide similar method to set value?

Describe the solution you'd like

Here, assuming we want to retrieve: base.derived[0].key, for get we have: table.at_path("base.derived[0].key"); for set, seems we could do something like this: table.set_path("base.derived[0].key", 42);, or table.emplace(toml::absolute_path("base.derived[0].key"), 42);

Additional context

JSON has JSON path to access data, see here: Here, and this does simplify the development. I think if provide similar feature, developing with toml will get much easier :)

laper32 commented 2 years ago

Seems duplicated at #153 , so close it