title: How to parse ini file with Boost
body: <p>I have a ini file which contains some sample values like:</p>
  
  <pre><code>[Section1]
  Value1 = 10
  Value2 = a_text_string
  </code></pre>
  
  <p>I'm trying to load these values and print them in my application with Boost but I don't understand how to do this in C++.</p>
  
  <p>I searched in this forum in order to find some examples (I always used C and so I'm not very good in C++) but I found only examples about how to read values from file all at once.</p>
  
  <p>I need to load just a single value when I want, like <code>string = Section1.Value2</code> because I don't need to read all the values, but just few of them.</p>
  
  <p>I'd like to load single values and to store them in variable in order to use them when I want in my application.</p>
  
  <p>It is possible to do this with Boost?</p>
  
  <p>At the moment, I'm using this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;set&gt;
  #include &lt;sstream&gt;
  #include &lt;exception&gt;
  #include &lt;fstream&gt;
  #include &lt;boost/config.hpp&gt;
  #include &lt;boost/program_options/detail/config_file.hpp&gt;
  #include &lt;boost/program_options/parsers.hpp&gt;
  
  namespace pod = boost::program_options::detail;
  
  int main()
  {
     std::ifstream s("file.ini");
      if(!s)
      {
          std::cerr&lt;&lt;"error"&lt;&lt;std::endl;
          return 1;
      }
  
      std::set&lt;std::string&gt; options;
      options.insert("Test.a");
      options.insert("Test.b");
      options.insert("Test.c");
  
      for (boost::program_options::detail::config_file_iterator i(s, options), e ; i != e; ++i)
          std::cout &lt;&lt; i-&gt;value[0] &lt;&lt; std::endl;
     }
  </code></pre>
  
  <p>But this just read all the values in a <code>for</code> loop; at the contrary I just want to read single values when I want and I don't need to insert values in the file, because it is already written with all the values which I need in my program.</p>