Open CJCombrink opened 2 years ago
Nope, there's no way to do that currently. It has been vaguely on my to-do list for a while, but I'm unlikely to get time to add the plumbing for this any time soon. I believe toml11 has something for that though; if you're deserializing a lot of different struct types you may find that library a bit more flexible in this area.
Thanks for the pointer. I have looked at toml11. But, I like the API of this library a lot more. I can probably get around this "limitation" for the sake of the cleaner API and then hope in future I can throw away boilerplate code when this gets added.
I am used to JSON for Modern C++ and this interface is quite familiar. Perhaps there are some lessens to be learned from their support for Custom data sources in my code or this library. (I am guessing you are familiar with this nlohmann-json)
(I am guessing you are familiar with this nlohmann-json)
Yup, the way that library handles this particular bit of functionality is very nice. One thing to be mindful of though is that TOML is chiefly a config language, whereas JSON is also aimed at serialization, so being able to convert between TOML and structs of arbitrary complexity isn't stricly a design goal I'm ever going to work towards.
Having said that, I would still like to make it easier for obvious common cases like points, vectors et cetera - I've had to come up with my own workarounds for that in my own code that uses this library 😅
I wonder how this is possible without proper reflection support in C++.
It's not in the general case; it always boils down to manually-written operator overloads or ADL tricks. You can use template machinery (e.g. SFINAE, partial specialisation) to cover some predefined cases pretty easily, though.
Is your feature request related to a problem? Please describe.
Is it possible to add TOML support for custom types, example:
Which would probably look like the following in TOML
Describe the solution you'd like
I would like to use it as follow:
Additional context
I am not yet using the library but working thought the API docs I don't see any mention of such options.