Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve comments after parsing and re-emit them #457

Open
tambry opened this issue Jan 8, 2017 · 1 comment
Open

Preserve comments after parsing and re-emit them #457

tambry opened this issue Jan 8, 2017 · 1 comment

Comments

@tambry
Copy link
Contributor

tambry commented Jan 8, 2017

For example I have the following code:

std::fstream config_file("config.yaml", std::ios::in | std::ios::out);
YAML::Node config_node = YAML::Load(config_file);
config_file.close();

// For example parse over the config, confirm it's correct, maybe correct mistakes, update the config to a new version, etc...

std::fstream config_file_write("config.yaml", std::ios::out | std::ios::trunc);
YAML::Emitter emitter;
emitter << config_node;
config_file_write << emitter.c_str();

Now maybe the user has written some comments in the config file to remind themselves why they set an option to that value. If the config is for example loaded through a GUI and modified or the config is loaded by the application and modified any way and then the config is saved again, the user's comments are lost.

Is there any way to preserve the comments when emitting the original parsed object?

@tambry tambry changed the title Preserve comments through parsing emitting Preserve comments after parsing and re-emit them Jun 22, 2017
@SimplyKnownAsG
Copy link

related to #154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants