Questions tagged [boost-propertytree]

The Boost PropertyTree library provides a data structure that stores an arbitrarily deeply nested tree of values, indexed at each level by some key. It serializes and emulates XML, JSON and INI file structures.

The Boost PropertyTree library provides a data structure that stores an arbitrarily deeply nested tree of values, indexed at each level by some key. It serializes and emulates XML, JSON and INI file structures.

Note: Boost.PropertyTree is not a generic XML parser. It is not intended to be used as a fast-and-dirty way to load arbitrary XML files into memory. It's XML serialization capabilities are for serialization. It is intended to read the XML that it has written.

Please stop using Boost.PropertyTree as a generic XML parser.

354 questions
3
votes
3 answers

Boost property tree: Remove a nested node

Suppose I have the following tree: boost::property_tree::ptree tree; tree.add("1.2.3", "value-1"); tree.add("1.2.3.4", "nested-value"); tree.add("1.2.3", "value-2"); tree.add("1.2.33", "other-value"); which has the following serialized INFO…
Alex Che
  • 6,659
  • 4
  • 44
  • 53
3
votes
2 answers

Writing Unicode string to XML with Boost Property Tree

#include #include #include using namespace std; int main() { wstring s(L"Alex"); boost::property_tree::wptree mainTree; boost::property_tree::wptree…
Alex F
  • 42,307
  • 41
  • 144
  • 212
3
votes
1 answer

Boost read_json and write_json are not equipollent for property tree

If I create a property tree from a stringstream with read_json, and I write it back to the stream with write_json, tryng to load it again with read_json fails with "terminate called after throwing an instance of 'boost::exception_detail::clone_impl…
Alar
  • 760
  • 4
  • 11
3
votes
1 answer

boost::property_tree xml pretty printing, formatting

I'm following the Five Minute Tutorial and I get as output (unsurprisingly) the file debug_settings_out.xml. But my problem is, that it isn't well formatted. It looks like this:
Rico-E
  • 1,806
  • 2
  • 28
  • 47
3
votes
1 answer

How do we insert a boost ptree as a node in another boost ptree?

I would like to serialize a hierarchical data structure in C++. The project I'm working on uses boost so I'm using boost::property_tree::ptree as my data node structure. We have higher level structures like Person which contain instances of lower…
kjoppy
  • 457
  • 3
  • 12
3
votes
2 answers

How to expand environment variables in .ini files using Boost

I have a INI file like [Section1] Value1 = /home/%USER%/Desktop Value2 = /home/%USER%/%SOME_ENV%/Test and want to parse it using Boost. I tried using Boost property_tree like boost::property_tree::ptree…
Maverick
  • 366
  • 1
  • 5
  • 11
3
votes
1 answer

C++ boost property tree getting values

I've been trying the past 2 days to find out how do I do the following thing in C++: I have a json string: [ { "pid" : 0, "nick":"Foo", "score":12, "ping":50 }, { "pid":1, "nick":"Bar", …
Tom Jenkins
  • 33
  • 1
  • 1
  • 3
3
votes
1 answer

how to get properties within subsections of a ini file with boost property tree?

I am trying to use the Boost property trees to read INIfiles containing properties within sections have a "composed" path name. For example my INIfile looks like this: [my.section.subsection1] someProp1=0 [my.section.subsection2] anotherProp=1 I…
greydet
  • 5,509
  • 3
  • 31
  • 51
3
votes
2 answers

Boost c++ property - if key does not exist then set to false

I am new to json parsing with boost using the property tree. If I have this hash: foo = {'test1',true} ptree pt; bool v = pt.get("test2"); I need to check a key exists and if not set it to false. How do I do that gracefully? Thanks
Tampa
  • 75,446
  • 119
  • 278
  • 425
3
votes
1 answer

boost property tree put/get DBL_MAX

I'm programming a ptree and at some point I need to put DBL_MAX in (as a default value). I see the right number when I open the generated xml-file. But when I use ptree.get to get the number an exception is thrown:conversion of data to type "d"…
Annah
  • 41
  • 1
  • 2
3
votes
1 answer

Boost property write_json incorrect behaviour

I am coding a JSON wrapper for Boost property tree. Currently the focus is on writing the resulting JSON into a string or a file. Using boost::property_tree::json_parser::write_json(ss, *pt) the resulting property tree is written in a string. But…
mariolpantunes
  • 1,114
  • 2
  • 15
  • 28
3
votes
1 answer

Parsing SVG (XML) with Boost Property Tree

I'm attempting to parse the following SVG (XML) markup with Boost C++'s ptree... The SVG (XML)
Jordan Arsenault
  • 7,100
  • 8
  • 53
  • 96
3
votes
1 answer

Boost property_tree: multiple values per key

Boost property tree seems like an excellent library to use for parsing config files. However, I can't figure out how to handle situations where there are multiple values per key. For example, let's say I was specifying a box like this: box { x…
Fadecomic
  • 1,220
  • 1
  • 10
  • 23
3
votes
2 answers

Add xml-stylesheet processing instructions to boost property_tree

I am using boost/property_tree to create an XML file. Unfortunately I cannot figure out how to add xml-stylesheet processing instructions to the file. Desirable output: <-- This is added…
Anatoly
  • 125
  • 7
2
votes
1 answer

Foward declaration of boost::interprocess::ptree

I want to use the forward declaration for the ptree class of boost::property_tree. I use Visual Studio 2010 and boost version 1.48.0. I do the forward declaration in the following way, in my .h #ifndef OPTIONS_H_ #define OPTIONS_H_ namespace…
Jepessen
  • 11,744
  • 14
  • 82
  • 149