scnlib
scnlib copied to clipboard
Using a contiguous range from context range inside a custom scanner
I'm trying to create a tokenizer/parser for an existing protocol, and I don't find any documentation on how to correctly use the context range as a contiguous range:
struct token {
std::string_view value;
};
template<>
struct scanner< token > {
std::size_t max_length;
char separator = ';';
char fill = ' ';
template<typename ParseContext>
constexpr auto parse(ParseContext &pctx) -> typename ParseContext::iterator {
return pctx.begin();
}
template <typename Context>
auto scan( token &value, Context &ctx ) const -> scan_expected< typename Context::iterator > {
auto r = scn::scan< std::string_view >( ctx.range(), "{}" );
if( r ) {
return r->begin();
}
else {
...
}
}
};
How to "cast" or to check the context range to use it as a contiguous range?
Is there a solution for this yet?