Sign in to follow this  
Dragon_Strike

dynamic creation object hierarchy from xml file

Recommended Posts

well im loading an xml file with alot of elements... for each element i create a type/variable and fill its corresponding values... for each element i have to create a loadng function that adds the appropriate type to the hiearchy and load its corresponding attributes... this takes time and isnt very flexible... i was wondering if this could be done dynamically in C++? something like first creating all possible element types/class and "tagging" them with the appropriate element name... and when u read the xml file u get the nam of the element, sreach the tags and create the appropriate object... it would take alot of void and dynamic_casts i guess.. if its not possible in compile time? im unsure how it could be done.. any suggestions?

Share this post


Link to post
Share on other sites
I believe boost::serialize does something like this, they use template metaprogramming to resolve the types, my suggestion would be to check out how they do it:

http://www.boost.org/libs/serialization/doc/index.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this