Created
April 17, 2011 22:30
-
-
Save hadronized/924541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/spirit/include/qi.hpp> | |
#include <boost/spirit/include/qi_grammar.hpp> | |
#include <boost/spirit/include/phoenix_core.hpp> | |
#include <boost/spirit/include/phoenix_operator.hpp> | |
#include <boost/fusion/include/adapt_struct.hpp> | |
#include <algorithm> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
namespace spirit = boost::spirit; | |
namespace qi = spirit::qi; | |
struct mesh { | |
std::vector<float> positions; | |
std::vector<float> normals; | |
}; | |
BOOST_FUSION_ADAPT_STRUCT( | |
mesh, | |
(std::vector<float>, positions) | |
(std::vector<float>, normals) | |
) | |
template <class InputIterator> | |
class mesh_grammar : public qi::grammar<InputIterator, mesh(), spirit::ascii::space_type> { | |
qi::rule<InputIterator, mesh(), spirit::ascii::space_type> _start; | |
qi::rule<InputIterator, size_t(), spirit::ascii::space_type> _verticesHeader; | |
qi::rule<InputIterator, std::vector<float>(), spirit::ascii::space_type> _positionData; | |
qi::rule<InputIterator, std::vector<float>(), spirit::ascii::space_type> _normalData; | |
public : | |
mesh_grammar() : mesh_grammar::base_type(_start) { | |
_verticesHeader %= qi::lit("hv") >> qi::uint_ >> qi::eol; | |
_positionData %= qi::lit("vp") >> qi::repeat(3)[qi::float_] >> qi::eol; | |
_normalData %= qi::lit("vn") >> qi::repeat(3)[qi::float_] >> qi::eol; | |
_start %= | |
} | |
~mesh_grammar() {} | |
}; | |
int main() { | |
bool r; | |
/*if (!r || first != str.end()) { | |
cout << "echec :(" << endl; | |
} else { | |
cout << "réussite lol !" << endl; | |
cout << name << endl; | |
}*/ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment