title: iterate over ini file on c++, probably using boost::property_tree::ptree?
body: <p>My task is trivial - i just need to parse such file:</p>
  
  <pre><code>Apple = 1
  Orange = 2
  XYZ = 3950
  </code></pre>
  
  <p>But i do not know the set of available keys. I was parsing this file relatively easy using C#, let me demonstrate source code:</p>
  
  <pre><code>    public static Dictionary&lt;string, string&gt; ReadParametersFromFile(string path)
      {
          string[] linesDirty = File.ReadAllLines(path);
          string[] lines = linesDirty.Where(
              str =&gt; !String.IsNullOrWhiteSpace(str) &amp;&amp; !str.StartsWith("//")).ToArray();
  
          var dict = lines.Select(s =&gt; s.Split(new char[] { '=' }))
                          .ToDictionary(s =&gt; s[0].Trim(), s =&gt; s[1].Trim());
          return dict;
      }
  </code></pre>
  
  <p>Now I just need to do the same thing using c++. I was thinking to use <code>boost::property_tree::ptree</code> however it seems I just can not iterate over ini file. It's easy to read ini file:</p>
  
  <pre><code>boost::property_tree::ptree pt;
  boost::property_tree::ini_parser::read_ini(path, pt);
  </code></pre>
  
  <p>But it is not possible to iterate over it, refer to this question <a href="https://stackoverflow.com/questions/11065938/boost-program-options-get-all-entries-in-section">Boost program options - get all entries in section</a></p>
  
  <p>The question is - what is the easiest way to write analog of C# code above on C++ ?</p>