scn namespace

scnlib namespace, containing the library interface

Classes

template <typename CharT>
struct basic_istream_scanner
template <typename CharT>
class basic_regex_match
template <typename CharT>
class basic_regex_matches
template <typename Context>
class basic_scan_arg
template <typename Context>
class basic_scan_args
template <typename CharT>
class basic_scan_context
template <typename CharT, typename Source, typename... Args>
class basic_scan_format_string
template <typename CharT>
class basic_scan_parse_context
template <typename T>
struct discard
template <typename T, typename E>
class expected
struct invalid_input_range
struct monostate
Placeholder monostate type.
template <typename Context, typename... Args>
class scan_arg_store
class scan_error
template <typename T>
struct scan_expected
template <typename Range, typename... Args>
class scan_result
template <typename T, typename CharT = char, typename Enable = void>
struct scanner
template <typename T, typename CharT>
struct scanner<T, CharT, std::enable_if_t<detail::arg_type_constant<T, CharT>::value !=detail::arg_type::custom_type && !detail::is_type_disabled<T>>>
template <typename T>
class span

Typedefs

template <typename R>
using borrowed_subrange_with_sentinel_t = typename borrowed_subrange_with_sentinel<R>::type
template <typename Source, typename... Args>
using scan_result_type = scan_expected<scan_result<detail::scan_result_value_type<Source>, Args...>>

Functions

template <typename... Args>
auto input(scan_format_string<std::FILE*, Args...> format) →  scan_result_type< std::FILE *, Args... > -> auto
template <typename Context = scan_context, typename... Args>
auto make_scan_args() constexpr
template <typename Context = scan_context, typename... Args>
auto make_scan_args(std::tuple<Args...>&& values) →  auto constexpr
template <typename Result, typename Context, typename... Args>
auto make_scan_result(scan_expected<Result>&& result, scan_arg_store<Context, Args...>&& args) →  scan_expected< scan_result< Result, Args... >> -> auto
template <typename... Args>
auto prompt(const char* msg, scan_format_string<std::FILE*, Args...> format) →  scan_result_type< std::FILE *, Args... > -> auto
auto runtime_format(std::string_view s) →  detail::basic_runtime_format_string<char>
template <typename... Args, typename Source, typename = std::enable_if_t<detail::is_file_or_narrow_range<Source>>>
auto scan(Source&& source, scan_format_string<Source, Args...> format) →  scan_result_type< Source, Args... > -> auto
template <typename... Args, typename Source, typename = std::enable_if_t<detail::is_file_or_narrow_range<Source>>>
auto scan(Source&& source, scan_format_string<Source, Args...> format, std::tuple<Args...>&& default_args) →  scan_result_type< Source, Args... > -> auto
template <typename... Args, typename Locale, typename Source, typename = std::enable_if_t<detail::is_file_or_narrow_range<Source>>, typename = std::void_t<decltype(Locale::classic())>>
auto scan(const Locale& loc, Source&& source, scan_format_string<Source, Args...> format) →  scan_result_type< Source, Args... > -> auto
template <typename... Args, typename Locale, typename Source, typename = std::enable_if_t<detail::is_file_or_narrow_range<Source>>, typename = std::void_t<decltype(Locale::classic())>>
auto scan(const Locale& loc, Source&& source, scan_format_string<Source, Args...> format, std::tuple<Args...>&& default_args) →  scan_result_type< Source, Args... > -> auto
template <typename T, std::enable_if_t<detail::is_scan_int_type<T>>* = nullptr>
auto scan_int(std::string_view source, int base = 10) →  scan_result_type< std::string_view, T > -> auto
template <typename T, std::enable_if_t<detail::is_scan_int_type<T>>* = nullptr>
auto scan_int_exhaustive_valid(std::string_view source) →  T -> auto
template <typename T, typename Source, typename = std::enable_if_t<detail::is_file_or_narrow_range<Source>>>
auto scan_value(Source&& source) →  scan_result_type< Source, T > -> auto
template <typename T, typename Source, std::enable_if_t<detail::is_file_or_narrow_range<Source>>* = nullptr>
auto scan_value(Source&& source, T default_value) →  scan_result_type< Source, T > -> auto
auto vinput(std::string_view format, scan_args args) →  scan_error
template <typename Visitor, typename Ctx>
auto visit_scan_arg(Visitor&& vis, basic_scan_arg<Ctx>& arg) →  decltype(auto) constexpr
template <typename Source>
auto vscan(Source&& source, std::string_view format, scan_args args) →  vscan_result<Source>
template <typename Source, typename Locale, typename = std::void_t<decltype(Locale::classic())>>
auto vscan(const Locale& loc, Source&& source, std::string_view format, scan_args args) →  vscan_result<Source>
template <typename Range>
auto vscan(Range&& range, std::wstring_view format, wscan_args args) →  vscan_result<Range>
template <typename Range, typename Locale, std::void_t<decltype(Locale::classic())>* = nullptr>
auto vscan(const Locale& loc, Range&& range, std::wstring_view format, wscan_args args) →  vscan_result<Range>
template <typename Source>
auto vscan_value(Source&& source, basic_scan_arg<scan_context> arg) →  vscan_result<Source>
template <typename Range>
auto vscan_value(Range&& range, basic_scan_arg<wscan_context> arg) →  vscan_result<Range>

Typedef documentation

template <typename R>
using scn::borrowed_subrange_with_sentinel_t = typename borrowed_subrange_with_sentinel<R>::type

Equivalent to ranges::subrange<ranges::iterator_t<R>, ranges::sentinel_t<R>> if R is a borrowed_range, and ranges::dangling otherwise.

Similar to ranges::borrowed_subrange_t<R>, expect this preserves the range sentinel.

template <typename Source, typename... Args>
using scn::scan_result_type = scan_expected<scan_result<detail::scan_result_value_type<Source>, Args...>>

The return type of scan, based on the type of the source, and the types of the scanned arguments.

Function documentation

template <typename Context = scan_context, typename... Args>
auto scn::make_scan_args() constexpr

Constructs a scan_arg_store object, associated with Context, that contains value-initialized values of types Args....

template <typename Context = scan_context, typename... Args>
auto scn::make_scan_args(std::tuple<Args...>&& values) constexpr

Constructs a scan_arg_store object, associated with Context, that contains values.

template <typename T, std::enable_if_t<detail::is_scan_int_type<T>>* = nullptr>
auto scn::scan_int(std::string_view source, int base = 10) →  scan_result_type< std::string_view, T >

Fast integer reading.

Quickly reads an integer from a std::string_view. Skips preceding whitespace.

Reads in the specified base, allowing a base prefix. Set base to 0 to detect the base from the input. base must either be 0, or in range [2, 36].

template <typename T, std::enable_if_t<detail::is_scan_int_type<T>>* = nullptr>
auto scn::scan_int_exhaustive_valid(std::string_view source) →  T

Very fast integer reading.

Quickly reads an integer from a std::string_view.

Be very careful when using this one! Its speed comes from some very heavy assumptions about the validity of the input:

  • source must not be empty.
  • source contains nothing but the integer: no leading or trailing whitespace, no extra junk. Leading - is allowed for signed types, no + is allowed.
  • The parsed value does not overflow.
  • The input is a valid base-10 integer. Breaking these assumptions will lead to UB.

template <typename Visitor, typename Ctx>
decltype(auto) scn::visit_scan_arg(Visitor&& vis, basic_scan_arg<Ctx>& arg) constexpr

Returns vis(x), where x is either a reference to the value contained in arg, or a basic_scan_arg::handle.

Visit a basic_scan_arg with Visitor. Calls vis with the value stored in arg. If no value is contained in arg, calls vis with a monostate.