Search code examples
c++boostqt-creatorboost-propertytree

Use only property tree from boost libraries


I need to parse a large XML file using property tree in boost libraries. How to use them ONLY instead of including the whole boost libraries?


Solution

  • There's no need for you whatsoever to include the whole boost libraries. For example, if you look in the quick tutorial in the appropriate boost documentation page for XML Property Trees, you see that you only need to include the following:

    #include <boost/property_tree/ptree.hpp>
    #include <boost/property_tree/xml_parser.hpp>
    

    In order to get the fully functional tutorial code compile error-free.

    So, this answers your question:

    How to use them ONLY instead of including the whole boost libraries?

    But, in case you actually meant having to package/deploy the whole boost libraries in contrast to including the whole boost libraries, then you have the bcp tool, itself a part of boost (also mentioned this post) to aid you sift through the entire ordeal and know exactly what parts of the library are needed to use the property_tree library.

    I have run this for you:

    bcp --list property_tree
    

    and the results are well... way to long to put in this answer. As in, the property_tree library itself is dependent on quite a large portion out of the entire boost libraries.

    So, there won't be such a noticeable difference between packaging the entire boost as part of your project, and shipping only whats needed for property_tree to build.

    Bottom line: If all you need is XML parsing capabilities and all of boost is too big for you then I suggest checking out one of the many XML libraries out there such as TinyXML-2 -- it is a "simple, small, efficient, C++ XML parser that can be easily integrated into other programs."