Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8594545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:13:28+00:00 2026-06-12T00:13:28+00:00

I’m considering creating an input/log file for my code for two main purposes. 1)

  • 0

I’m considering creating an input/log file for my code for two main purposes.

1) Be able to log all key parameters that the code was run with so that I can reproduce the same results in the future if I needed to.
2) Be able to start/resume the code without the need to hard-code the parameters in the code.

I’m interested in a header-only approach so that I could simply carry the header files along with my code thus I have turned into boost.property_tree. From the documentation it seems to serve the purpose. My question is which file-format serves my need the best? I need something that:

1) is easily readable/editable by a human
2) can support nested sections
3) can support comments

By default I have turned to xml but I’m not sure that’s the best option considering parsing capabilities of boost.property_tree. For instance I want to be able to parse something like this:

<Grid Type = "AMR">
    <Domain> -1.0 1.0 -1.0 1.0 </Domain>
    <Levels> 10 5 </Levels>
    <Path> /path/to/data.bin </Path>
</Grid>

I want to be able to read in Type property as well as Domain, Levels, and Path sections correctly and separately (for instance Domain has 4 separate floating points corresponding to the edges of a rectangle). My code looks like this:

using boost::property_tree::ptree;
ptree pt;

double x = pt.get<double>("Grid.Domain");

std::cout << x << std::endl;

but I keep getting conversion of data to type "d" failed. How should I fix it? Also, is xml the best option I have or should I consider changing to another format?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:13:29+00:00Added an answer on June 12, 2026 at 12:13 am

    boost::property_tree also supports serialization/deserialization to and from JSON. JSON allows arrays and thus it is very easy to store multiple values for a section. You can even store structures in JSON (which may be handy if you wanted to persist the state of an object from your program).

    Important caveat: boost::property_tree treats values internally as strings, so if you want valid JSON that might be read outside of your program, you will not be able to read numeric values directly from JSON you create with boost::property_tree without performing some sort of cast (depending on the reading code).

    If retaining the types of numeric values in your persisted file is important to you, I would check out JSONCpp. I have used it myself and it is very easy to get up and running, and it is very lightweight.

    JSONCpp also supports comments. From the SourceForge page:

    Notes: Comments used to be supported in JSON but where removed for
    portability (C like comments are not supported in Python). Since
    comments are useful in configuration/input file, this feature was
    preserved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.