cyanskies / another-toml-cpp

MIT License
1 stars 0 forks source link

Add a way to append or update parsed toml files #14

Open cyanskies opened 3 months ago

cyanskies commented 3 months ago

In order for users to parse a file and then update it, we'll need a way to convert parsed nodes into a writer.

Either a free function that returns a writer or a new constructor on the writer class. This would need to accept a valid node as a parameter, copy the backend data into the new writer.

auto root_table = toml::parse(path);

// writer constructor
auto writer = toml::writer{ root_table };

// free func
auto writer = toml::convert_to_writer(root_table);

This would produce a writer that was prefilled, as though the user had filled in the parsed data using the writer API.

The next issue would be allowing the writer to re-open and append previously closed tables, as well as replace previously defined keys and values.