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

Reflection-capable YAML parsing? #45

Closed
cesss opened this issue Mar 1, 2020 · 2 comments
Closed

Reflection-capable YAML parsing? #45

cesss opened this issue Mar 1, 2020 · 2 comments

Comments

@cesss
Copy link

cesss commented Mar 1, 2020

Hi!

I'm considering adopting the YAML format as the serialization format in my apps, and I've been searching for all the C/C++ YAML libraries available, but... to my surprise, all of them assume your program knows -or decides- the "schema" (data types, data structures, etc.)

However, I want that the "schema" and the data types and structures are owned by the YAML file, and not by the program (of course I agree programs are written with some certain data structures, but I want them to be able to read the YAML file and then later check if the YAML schema matches the program structures or not).

In other words, I was hoping to find a YAML library that handled the data types for you, so that you would tell it data=load("thisfile.yaml"); and then the library could tell you something like "data contains 3 objects of structure car and 2 objects of structure bike. Structure car has fields for brand (string), model (string), price (float), available (boolean)... etc".

Can this be done with your library? Do you have any example/demo that does this?

Thanks a lot!

@cesss
Copy link
Author

cesss commented Mar 1, 2020

BTW, as a related question, can class inheritance be written in some way into a YAML file? I mean, is it possible to create a YAML file where structures triangle, quad, and line are derived from shape, and therefore all of them share exactly the same fields for their common shape base class? Would your YAML parser be able to detect that triangle, quad, and line have a common part (their shape "base class") ?

@cesss
Copy link
Author

cesss commented Mar 1, 2020

Nevermind, after writing this I realized that actually what I need is not YAML, but my own serialization format. Many formats exist, but none of them offer the kind of OOP awareness that I need.

@cesss cesss closed this as completed Mar 1, 2020
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

1 participant