Contexts and scanners module
Lower-level APIs used for scanning individual values.
Scanning user-defined types
User-defined types can be scanned by specializing the class template scn::
.
struct mytype { int key; std::string value; }; template <> struct scn::scanner<mytype> { template <typename ParseContext> constexpr auto parse(ParseCtx& pctx) -> scan_expected<typename ParseContext::iterator> { // parse() implementation just returning begin(): // only permits empty format specifiers return pctx.begin(); } template <typename Context> auto scan(mytype& val, Context& ctx) -> scan_expected<typename Context::iterator> { return scn::scan<int, std::string>(ctx.range(), "{}: {}") .transform([&](auto result) { std::tie(val.key, val.value) = std::move(result->values()); return result.begin(); }); } };
See also User types
Classes
-
template <typename CharT>class scn::basic_scan_context
-
template <typename CharT>class scn::basic_scan_parse_context
-
template <typename T, typename CharT = char, typename Enable = void>struct scn::scanner
-
template <typename T, typename CharT>struct scn::scanner<T, CharT, std::enable_if_t<detail::arg_type_constant<T, CharT>::value !=detail::arg_type::custom_type && !detail::is_type_disabled<T>>>