• Advertisement
Sign in to follow this  

dynamic creation object hierarchy from xml file

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement