Use only property tree from boost libraries

北城余情 提交于 2019-12-24 11:15:14

问题


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?


回答1:


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."




回答2:


The direct question is: it's header-only, so no real meaning whatsoever.

What's way more important is this:

I need to parse a large XML file using property tree

You need to pick one:

  1. I need to parse a large XML file
  2. I need to [...] use [red.] property tree

Boost Property Tree is NOT an XML library. If you need to parse general purpose XML, you can't use Boost Property Tree or you'll regret the choice pretty soon. See What XML parser should I use in C++?`



来源:https://stackoverflow.com/questions/51916977/use-only-property-tree-from-boost-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!