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
2
votes
2 answers

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?
Alaa Agwa
  • 162
  • 1
  • 12
2
votes
1 answer

Recursively adding subtrees to boost property tree

I want to write a parameter server in C++ where I can recursively dump a tree of parameters into a property tree and then write it to a JSON file. The dump function looks like this: void Params::dump(string filename) { // Create a root …
EE-Student
  • 85
  • 1
  • 10
2
votes
1 answer

Adding subtrees with xml attributes to a boost property tree

I'm using boost::ptree for creating an xml file ptree tree; ptree & subtree = tree.add("sometag", ""); ptree & subsubtree = tree.add("someothertag", ""); ... write_xml(stfilename, declarationTree, std::locale(), …
Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
2
votes
2 answers

Boost property tree getting element from unamed array

I have the following json file [ { "a":5855925.424944928, "b":0, "c":96, "d":2096640, "e":0 } ] I do this, boost::property_tree::ptree jsontree; std::stringstream ss; ss << "[{\"a\":…
LeMoussel
  • 5,290
  • 12
  • 69
  • 122
2
votes
1 answer

How to use boost property tree to parse elements from array in json string using boost?

I have a json string that looks like this: [ "some text", 648547, 94.0, 111.0267520223, 10 ] so I need to assign a variable to each value like: std::string value1 = "some text"; int value2 = 648547; float…
LeMoussel
  • 5,290
  • 12
  • 69
  • 122
2
votes
3 answers

Read/Write inifiles with boost::{program_options,property_tree}

Utilizing boost, I would like to read options from an inifile, abort if an unknown option is encountered in the inifile and save them later in another inifile. The first part can be done with boost::program_options: try{ …
Oscillon
  • 165
  • 3
  • 13
2
votes
1 answer

Emit YAML iterating through boost property tree (recursively)

I have a small but complex tree structure. Using, boost property tree as a container i am trying to iterate through the tree and subsequently emit it to the yaml file using yaml-cpp library. For instance, i have a small nested property…
MarKS
  • 494
  • 6
  • 22
2
votes
1 answer

Workaround for Warning C4512 From Boost's JSON Parser

So I'm trying to use boost::property_tree::read_json. For this I need to: #include When I try though I get: warning C4512: boost::property_tree::json_parser::detail::source :…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
2
votes
1 answer

Read a hexadecimal value starting with \x from a text file

I am sending data to a serial device using the function write() in boost::asio In the code, I have hardcoded a string, which is detected by the serial device in hexadecimal format. string test = "\x0C"; write(port, buffer(test.c_str(),…
grouser
  • 618
  • 8
  • 23
2
votes
1 answer

How to manually create a boost ptree with different XML attributes?

I am using boost libraries to parse XML files and I have to create a ptree manually. I want to create below xml file using boost ptree. xyz Information
Sandip Patidar
  • 157
  • 1
  • 14
2
votes
2 answers

Iterate through multilevel boost tree

With my tree looking like this: { "Library": { "L_ID": "1", "Book": { "B_ID": "1", "Title": "Moby Dick" }, "Book": { "B_ID": "2", "Title": "Jurassic Park" } }, "Library": { …
Jason
  • 2,147
  • 6
  • 32
  • 40
2
votes
1 answer

boost::property_tree passing subtree including

I'm trying to pass elements of a boost::property_tree::ptree to a function. In detail, I have to following XML code from which a ptree is initialised: 0. 1
hansgans
  • 307
  • 4
  • 12
2
votes
1 answer

In Boost Property tree library, how I can handle file not found error in custom way (C++)

I want to read a json data from a file in C++ using boost libraries. Using property tree. I am new to programming, very new to c++ and its the first time i use boost library. I had some history in C many years ago. And i have a weeks experience in…
2
votes
1 answer

Boost ptree array of numbers

I use the following code to create an array of the numbers. After running the following code, I reveive the following results: { "": "1.100000", "": "2.200000", "": "3.300000" } It is good except for my desired result has to be an array…
ar2015
  • 5,558
  • 8
  • 53
  • 110
2
votes
1 answer

boost::property_tree::read_xml segfaults in an asio handler spawned using boost::asio::spawn

The following code crashes with a seg fault at boost::property_tree::read_xml() call. This happens only if it's called inside of an io_service handler spawned using boost::asio::spawn(). If the handler is just posted, it works ok. Is there a fix or…
amosk
  • 385
  • 1
  • 11