Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>now that you are already using boost with lexical_cast, just parse each line with <a href="http://www.boost.org/doc/libs/1_38_0/doc/html/string_algo/reference.html#header.boost.algorithm.string.split_hpp" rel="nofollow noreferrer">boost::split()</a> and <a href="http://www.boost.org/doc/libs/1_38_0/doc/html/boost/algorithm/is_any_of.html" rel="nofollow noreferrer">boost::is_any_of()</a> into 1 2-element vector, with token_compress turned on. </p> <p>the following code illustrates the parse, but skips the numeric conversion, which could be solved easily with boost lexical_cast. </p> <pre><code>#include &lt;fstream&gt; #include &lt;sstream&gt; #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;boost/algorithm/string/split.hpp&gt; #include &lt;boost/algorithm/string/classification.hpp&gt; #include &lt;boost/foreach.hpp&gt; using std::string; using std::cout; using std::ifstream; using std::stringstream; using std::vector; std::string file_to_string() { ifstream data("data.txt"); stringstream s; s &lt;&lt; data.rdbuf(); return s.str(); } void print_parameter(vector&lt;string&gt;&amp; v) { cout &lt;&lt; v_para[0]; cout &lt;&lt; "="; cout &lt;&lt; v_para[1]; cout &lt;&lt; std::endl; } vector&lt;string&gt; string_to_lines(const string&amp; s) { return v_lines; } int main() { vector&lt;string&gt; v_lines; boost::split(v_lines, file_to_string(), boost::is_any_of("\n"), boost::token_compress_on); vector&lt;string&gt; v_para; BOOST_FOREACH(string&amp; line, v_lines) { if(line.empty()) continue; boost::split(v_para, line, boost::is_any_of(" ="), boost::token_compress_on); // test it print_parameter(v_para); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload