Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your rule declares the wrong exposed attribute. Change it:</p> <pre><code>qi::rule&lt;std::string::const_iterator, std::vector&lt;float&gt;(), iso8859::space_type&gt; vertex; </code></pre> <p>However, since you don't template your grammar struct on anything (like iterator/skipper type), it makes no sense to have a grammar struct. Instead, let <code>phrase_parse</code> simply deduce the iterator, skipper and rule types all at once and write:</p> <pre><code>bool parseObj(std::string const&amp; data, std::vector&lt;float&gt; &amp;v ) { return qi::phrase_parse( data.cbegin(), data.cend(), 'v' &gt;&gt; qi::float_ &gt;&gt; qi::float_ &gt;&gt; qi::float_, qi::space, v); } </code></pre> <p>I think you'll agree that's more to the point. And as a bonus, it "just works"(TM) because of the awesomeness that is <em>automatic attribute propagation</em> rules.</p> <p>However, seeing your grammar, you'll certainly want to see these:</p> <ul> <li><p><a href="https://stackoverflow.com/questions/17465061/how-to-parse-space-separated-floats-in-c-quickly/17479702#17479702">How to parse space-separated floats in C++ quickly?</a> showing how to parse into a vector of structs </p> <pre><code>struct float3 { float x,y,z; }; typedef std::vector&lt;float3&gt; data_t; </code></pre> <p>with little or no extra work. Oh and it benchmarks the spirit approach reading a 500Mb file against the competing <code>fscanf</code> and <code>atod</code> calls. So, it parses multiple lines at once :)</p></li> <li><p>Use the <code>qi::double_</code> parser instead of <code>qi::float_</code> <em>even if you're ultimately assigning to single-precision <code>float</code> variables</em>. See <a href="https://stackoverflow.com/questions/17391348/boost-spirit-floating-number-parser-precision/17393048#17393048">Boost spirit floating number parser precision</a></p></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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