0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::spirit: Add template with exception translation wrapping qi::parse().

This commit is contained in:
Jason Volk 2019-10-14 13:38:34 -07:00
parent 5909f9ab64
commit 83bdee822a

View file

@ -39,6 +39,14 @@ namespace ircd::spirit
extern thread_local char rulebuf[64]; // parse.cc
}
namespace ircd
{
template<class parent_error,
class it = const char *,
class... args>
bool parse(args&&...);
}
namespace ircd {
namespace spirit
__attribute__((visibility("hidden")))
@ -158,4 +166,18 @@ ircd::spirit::expectation_failure<parent>::expectation_failure(const qi::expecta
}
{}
template<class parent_error,
class it,
class... args>
inline bool
ircd::parse(args&&... a)
try
{
return spirit::qi::parse(std::forward<args>(a)...);
}
catch(const spirit::qi::expectation_failure<it> &e)
{
throw spirit::expectation_failure<parent_error>(e);
}
#endif // HAVE_IRCD_SPIRIT_H