Imagine I have xml data :
<tag> value</tag> etc ....
<othertag> value value2 value_n </othertag>
etc ....
What is the best container to manage this informaction ?
A simple vector, a list, other ?
I'm going to do simple insertions, searchings, deletions.
Of course the code are going to be 'some rude'.
I know that there will be xml specific utilities, but I'd want to know your opinion.
Thanks
Last edited on
Considering:
<tag1>
<tag2 param="text" stuff="things">value stuff</tag2>
<tag2>err</tag2>
<tag3 exists="true"></tag3>
</tag1> |
You have two options:
#1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
std::multimap //tags
<
std::multimap //each tag
<
std::string, //the tag name, ex: "tag1\tag2"
std::vector //the params
<
std::map //each param
<
std::string, //param name, ex: "stuff"
std::string //param value, ex: "things"
>
>,
std::string //tag value, ex: "value stuff"
>;
|
This is obviously a nightmare to deal with, and it has some issues you will have to manually account for.
#2:
Polymorphism. Have an abstract 'element' base class, then have a tag class extend it (ex tag2) and a tag group class extend it (ex tag1).
Last edited on