-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Is it possible to add support for custom types? #175
Comments
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. I am used to JSON for Modern C++ and this interface is quite familiar. |
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.
The text was updated successfully, but these errors were encountered: