1

I am using boost library to parse .ini file that looks like:

[head]
type1=val1
type2=cal2
...

My code is this:

#include <iostream>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
using namespace std;

int main()
{
    using boost::property_tree::ptree;

    boost::property_tree::ptree pt;
    boost::property_tree::ini_parser::read_ini("test.ini", pt);

    boost::property_tree::ptree::iterator pos1,pos2;

    for(pos1 = pt.begin(); pos1 != pt.end() ; ++pos1)
    {
        cout << pos1->first << endl;

        for(pos2 = pos1->second.begin() ; pos2 != pos1->second.end() ; ++pos2)
        {
            cout << "    " << pos2->first << "=" << pos2->second.get_value<string>() << endl;
        }
        cout << endl;
    }

    return 0;
}

everything works and the program output is as expected but eclipse marks all pos1 and pos2 "->" as errors... the intelli sense doesn't load the "first" or "second" options and mark all uses of them as error... yet everything compiles...

any ideas ??

here is how it looks:

enter image description here

jww
  • 97,681
  • 90
  • 411
  • 885

1 Answers1

0

pos1 and pos2 are not pointers, you should use the . instead of ->

dashtinejad
  • 6,193
  • 4
  • 28
  • 44
Eric
  • 19,525
  • 19
  • 84
  • 147
  • hi Eric, maybe i dont understand the itrator consept well but as i see it pos1 and pos2 are kind of pointers to the same type they are iterating (at least this is how its works for me for arrays and vector iterators). anyway, when i just use "pos1." i get lots of iterator properties and methods but not any of the ptree's.... – doron-BGU bgu Nov 17 '14 at 07:59