Alaa Agwa
Alaa Agwa

Reputation: 162

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?

Upvotes: 2

Views: 4269

Answers (2)

Geezer
Geezer

Reputation: 5710

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

Upvotes: 2

sehe
sehe

Reputation: 393174

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++?`

Upvotes: 2

Related Questions