2016-01
This commit is contained in:
@@ -66,6 +66,15 @@ auto operator-=(Coord &, Coord) -> Coord &;
|
||||
/// Write a coordinate to a string "(x,y)"
|
||||
auto operator<<(std::ostream &, Coord) -> std::ostream &;
|
||||
|
||||
/// Scale a coordinate
|
||||
auto operator*(std::int64_t, Coord) -> Coord;
|
||||
|
||||
/// Scale a coordinate
|
||||
auto operator*(Coord, std::int64_t) -> Coord;
|
||||
|
||||
/// Scale a coordinate
|
||||
auto operator*=(Coord &, std::int64_t) -> Coord &;
|
||||
|
||||
} // namespace
|
||||
|
||||
template<>
|
||||
|
@@ -30,6 +30,22 @@ auto ParseGrammar(G const& grammar, std::istream & in) -> typename G::start_type
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename G>
|
||||
auto ParseGrammar_(G const& grammar, std::istream & in) -> typename G::start_type::attr_type
|
||||
{
|
||||
namespace qi = boost::spirit::qi;
|
||||
auto result = typename G::start_type::attr_type {};
|
||||
auto const content = std::string{std::istreambuf_iterator{in}, {}};
|
||||
auto b = content.begin(); // updated on successful parse
|
||||
auto const e = content.end();
|
||||
|
||||
if (!qi::phrase_parse(b, e, grammar, qi::ascii::space, result) || b != e) {
|
||||
throw std::runtime_error{"Bad input file: " + content};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user