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 9023689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:49:16+00:00 2026-06-16T05:49:16+00:00

I need to read properties from a file to affect program behavior. Looks like

  • 0

I need to read properties from a file to affect program behavior. Looks like boost::property_tree will do quite nicely. But, I’m wondering if when fetching different kinds of values that the library may reads the file multiple times?

For performance reason I’d like it to only be once. Most of the properties will be simple values like numbers, and strings. But occasionally there will be lists of numbers and lists strings.

I figure the it parses the file only once, but you never know and hence the question.

thanks.

  • 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-16T05:49:17+00:00Added an answer on June 16, 2026 at 5:49 am

    You control it, and it reads only once:

    //
    // All that is required to read an xml file into the tree
    //
    
    std::ifstream in("region.xml");
    boost::property_tree::ptree result_tree;
    boost::property_tree::read_xml(in,result_tree);
    

    Include the correct header and read ini, json or xml files into the tree using the corresponding read_XXX method.

    You then use a “path” to access elements from the tree, or you can iterate over subtrees

    BOOST_FOREACH(boost::property_tree::ptree::value_type &v,result_tree.get_child("gpx.rte"))
    {
          if( v.first == "rtept" ) //current node/element name
          {
               boost::property_tree::ptree subtree = v.second ;
               //A path to the element is required to access the value
              const int lat = sub_tree.get<double>( "<xmlattr>.lat")*10000.0;
              const int lon = sub_tree.get<double>( "<xmlattr>.lon")*10000.0;
          }
    }
    

    or direct access via a path:

      // Here is simplistic access of the data, again rewritten for flexibility and 
      // exception safety in real code (nodes shortened too)
      const int distVal = 
           result_tree.get<int>
            ( "Envelope.Body.MatrixResponse.Matrix.Route.<xmlattr>.distance")/1000;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read from a properties file a parameter like this {TA;TD;TE;TG;TI;TN;TNG;TP;TR;TS;TT}, and I need
I need to read and filter a properties file from a location outside my
I need to read in a Properties object from a file, however I need
I need my Java app to read the config properties from a file and
I am using spring. I need to read values from properties file. This is
I need to read 16 bits from the binary file as std::string or char
I need to read data from XML to a List<>. The XML file contains
I need to read in an expression from a file using a string stream
I need to know that how to read the directory path from a .properties
My web application performs some of its behavior by reading from a properties file.

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.