[gmx-developers] XML and std::map?
David van der Spoel
spoel at xray.bmc.uu.se
Tue Sep 29 23:59:26 CEST 2015
On 29/09/15 13:20, Vedran Miletić wrote:
> Hi,
>
> sorry for the delay, I started replying and then got carried away by
> something else that was more urgent.
>
> Anyway, if you are still considering std::map, my thoughts are below.
>
> 2015-09-23 10:23 GMT+02:00 David van der Spoel <spoel at xray.bmc.uu.se>:
>> I guess the routine parsing the std::map has to interpret what is there,
>> right? And as such this routine has to have the information that is needed.
>> The idea would be just to have a generic tree structure to parse, and to
>> have just one routine deal with libxml2 rather than directly interfacing to
>> libxml2 from every file that has to be read.
>>
>
> In dynamic typing languages, yes. In C++, you can not do that; you
> have to predict the number of levels of nesting in advance. E.g. for
> XML with two levels of nesting you have:
>
> std::map<std::string, std::map<std::string, std::string> >
>
> With three levels of nesting you would have:
>
> std::map<std::string, std::map<std::string, std::map<std::string,
> std::string> > >
>
> I don't see how can you overload the function and return the right
> type. The best you can do is make parsers for specific XML files which
> always have the same number of nesting levels.
OK, thanks for that. It seems this is not the way to go then.
There is the Boost graph library but the website looks ancient:
http://www.boost.org/doc/libs/1_36_0/libs/graph/doc/index.html
>
>> The question is therefore mainly whether std::map is the right structure?
>>
>
> Would be interesting to try, nevertheless.
>
> Regards,
> Vedran
>
--
David van der Spoel, Ph.D., Professor of Biology
Dept. of Cell & Molec. Biol., Uppsala University.
Box 596, 75124 Uppsala, Sweden. Phone: +46184714205.
spoel at xray.bmc.uu.se http://folding.bmc.uu.se
More information about the gromacs.org_gmx-developers
mailing list