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

Replacing Values in a toml::array #109

Closed
LebJe opened this issue Jun 15, 2021 · 5 comments
Closed

Replacing Values in a toml::array #109

LebJe opened this issue Jun 15, 2021 · 5 comments
Assignees
Labels
feature New feature or enhancement request implemented in v3 Fixes + features which were implemented in v3 release.

Comments

@LebJe
Copy link

LebJe commented Jun 15, 2021

Is your feature request related to a problem? Please describe.
It seems that there's no way to replace a value in a toml::array. Currently, I'm using this code:

auto array = toml::array { 0, 1, 2, 3 };

if (array.get(0)) {
	array.erase(array.cbegin());
}

array.insert(array.cbegin(), 5);

Describe the solution you'd like
I would like a way to easily replace a value, something like operator[] in std::vector:

auto stdVector = std::vector { 0, 1, 2, 3 };
stdVector[0] = 5;

Additional context
None

@LebJe LebJe added the feature New feature or enhancement request label Jun 15, 2021
@marzer
Copy link
Owner

marzer commented Jun 15, 2021

Thanks for the suggestion. I can't implement this as operator[] because of the polymorphic nature of the data (well, I can, but not in the current design, and it necessitates a big rewrite), but I can implement it using a member function, e.g. array::replace(iterator, value)

@LebJe
Copy link
Author

LebJe commented Jun 15, 2021

@marzer Thank you for the proposed solution. I look forward to using array::replace(iterator, value) in the future.

@marzer marzer added the v3 label Oct 25, 2021
@marzer marzer added implemented in v3 Fixes + features which were implemented in v3 release. and removed v3 labels Nov 6, 2021
@marzer
Copy link
Owner

marzer commented Nov 6, 2021

@LebJe If you're still interested in this feature I've pushed an implementation of it to the v3 branch.

I won't merge v3 into master for a while yet since there's more work to be done before I cook a new release, but I welcome you to try it before then. (Do note that the v3 branch will be a massive ABI break so I'm not promising it will just work out-of-the-box without requiring a code change or two)

The full list of changes in the v3 branch can be found here.

@LebJe
Copy link
Author

LebJe commented Nov 8, 2021

@marzer Thank you very much! I've tested some of the features in the v3 branch (including array::replace) and they work perfectly!

@marzer
Copy link
Owner

marzer commented Nov 9, 2021

@LebJe Awesome, good to hear.

Somewhat related: I happened to notice you have a couple TOML parser+serializer projects in other languages that use toml++ as the native backend, meaning you're probably more sensitive to API and ABI changes than most. I'll try to keep CHANGELOG.md as up-to-date and detailed as I possibly can so you can get out in front of those breaks early. Please let me know if you see something I've missed.

@marzer marzer closed this as completed in aa645dd Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement request implemented in v3 Fixes + features which were implemented in v3 release.
Projects
None yet
Development

No branches or pull requests

2 participants