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

  • Home
  • SEARCH
  • 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 6112709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:46:34+00:00 2026-05-23T14:46:34+00:00

So this is official Boost PropertyTree example , I try to compile it on

  • 0

So this is official Boost PropertyTree example, I try to compile it on my visual studio 2008 and same on VS2010 get Error C2228: left of '.put_value' must have class/struct/union c:\program files (x86)\boost-1.46.1\include\boost\property_tree\detail\ptree_implementation.hpp 795 1

Here is code I use:

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <set>
#include <sstream>
#include <boost/foreach.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

using namespace std;

std::string m_file;          // log filename
int m_level;                 // debug level
std::set<string> m_modules;  // modules where logging is enabled

// Loads debug_settings structure from the specified XML file
void load( std::ifstream &file)
{
    // Create an empty property tree object
    using boost::property_tree::ptree;
    ptree pt;

    // Load the XML file into the property tree. If reading fails
    // (cannot open file, parse error), an exception is thrown.
    read_xml(file, pt);

    // Get the filename and store it in the m_file variable.
    // Note that we construct the path to the value by separating
    // the individual keys with dots. If dots appear in the keys,
    // a path type with a different separator can be used.
    // If the debug.filename key is not found, an exception is thrown.
    m_file = pt.get<std::string>("debug.filename");

    // Get the debug level and store it in the m_level variable.
    // This is another version of the get method: if the value is
    // not found, the default value (specified by the second
    // parameter) is returned instead. The type of the value
    // extracted is determined by the type of the second parameter,
    // so we can simply write get(...) instead of get<int>(...).
    m_level = pt.get("debug.level", 0);

    // Iterate over the debug.modules section and store all found
    // modules in the m_modules set. The get_child() function
    // returns a reference to the child at the specified path; if
    // there is no such child, it throws. Property tree iterators
    // are models of BidirectionalIterator.
    BOOST_FOREACH(ptree::value_type &v,
        pt.get_child("debug.modules"))
        m_modules.insert(v.second.data());
}

// Saves the debug_settings structure to the specified XML file
void save(const std::string &filename)
{
    // Create an empty property tree object
    using boost::property_tree::ptree;
    ptree pt;

    // Put log filename in property tree
    pt.put("debug.filename", m_file);

    // Put debug level in property tree
    pt.put("debug.level", m_level);

    // Iterate over the modules in the set and put them in the
    // property tree. Note that the put function places the new
    // key at the end of the list of keys. This is fine most of
    // the time. If you want to place an item at some other place
    // (i.e. at the front or somewhere in the middle), this can
    // be achieved using a combination of the insert and put_own
    // functions.
    BOOST_FOREACH(const std::string &name, m_modules)
        pt.put("debug.modules.module", name, true);

    // Write the property tree to the XML file.
    write_xml(filename, pt);
}

int main()
{
    std::ifstream script( "<debug>\n   <filename>debug.log</filename>\n    <modules>\n        <module>Finance</module>\n       <module>Admin</module>\n        <module>HR</module>\n    </modules>\n    <level>2</level>\n</debug>\n");
    load(script);
    save("j.js");
    cout << "parse complete" << endl;
    cin.get();
}

I have not changed my boost distribution in any way but it does not compile. Why?

  • 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-05-23T14:46:35+00:00Added an answer on May 23, 2026 at 2:46 pm

    The sample code for 1.46.1 has changed:

    http://www.boost.org/doc/libs/1_46_1/libs/property_tree/examples/debug_settings.cpp

    The relevant change is

    BOOST_FOREACH(const std::string &name, m_modules)
    pt.add(“debug.modules.module”, name);

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

Sidebar

Related Questions

The official oauth guide makes this recommendation: It is important not to try and
The below is from the official BOOST docs. Why do I always get size
I'm a bit confused as to the status of Boost.Log. Is this an official
This snippet from official website works as expected: $treeObject = Doctrine::getTable('Category')->getTree(); $rootColumnName = $treeObject->getAttribute('rootColumnName');
I'm a newbie on Ant so instead of posting this on the official buglist(because
At this time Textmate's official Python bundle is really bare bones, especially in comparison
In this question , I mentioned my assumption that rubyforge gems are more official,
I've seen this questions here . I'm wondering if there exists an official name
I found this tutorial about ffmpeg the thing i do not get is how
I followed this tutorial (official documentation for symfony 1.4). The project is created but

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.