dynamic creation object hierarchy from xml file
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?
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
http://www.boost.org/libs/serialization/doc/index.html
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement