scnlib  0.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scn Namespace Reference

Namespaces

 _make_view
 
 detail
 

Classes

class  basic_arg
 Type-erased scanning argument. More...
 
class  basic_args
 
struct  scanner
 
struct  temporary
 Allows reading an rvalue. More...
 
class  arg_store
 
class  basic_context
 
class  basic_mapped_file
 
class  basic_file
 
class  basic_file_view
 
struct  scanner< CharT, T, typename std::enable_if< detail::is_std_streamable< CharT, T >::value >::type >
 
class  basic_default_locale_ref
 
class  basic_locale_ref
 
class  basic_parse_context
 
class  basic_scanf_parse_context
 
class  basic_empty_parse_context
 
struct  empty_parser
 
struct  scanner< CharT, CharT >
 
struct  scanner< CharT, span< CharT > >
 
struct  scanner< CharT, bool >
 
struct  scanner< CharT, short >
 
struct  scanner< CharT, int >
 
struct  scanner< CharT, long >
 
struct  scanner< CharT, long long >
 
struct  scanner< CharT, unsigned short >
 
struct  scanner< CharT, unsigned int >
 
struct  scanner< CharT, unsigned long >
 
struct  scanner< CharT, unsigned long long >
 
struct  scanner< CharT, float >
 
struct  scanner< CharT, double >
 
struct  scanner< CharT, long double >
 
struct  scanner< CharT, std::basic_string< CharT > >
 
struct  scanner< CharT, basic_string_view< CharT > >
 
class  error
 Error class. More...
 
class  result
 
class  expected
 expected-like type. More...
 
class  expected< T, Error, typename std::enable_if< std::is_default_constructible< T >::value >::type >
 expected-like type for default-constructible success values. More...
 
class  expected< T, Error, typename std::enable_if< !std::is_default_constructible< T >::value >::type >
 expected-like type for non-default-constructible success values. More...
 
struct  discard_type
 
struct  scanner< CharT, discard_type< T > >
 
class  span
 A view over a contiguous range. More...
 
class  basic_string_view
 A view over a (sub)string. More...
 
class  wrap_default
 
class  basic_visitor
 
class  scan_result
 
struct  scan_result_for
 
struct  wrapped_error
 

Typedefs

using mapped_file = basic_mapped_file< char >
 
using wmapped_file = basic_mapped_file< wchar_t >
 
using file = basic_file< char >
 
using wfile = basic_file< wchar_t >
 
using file_view = basic_file_view< char >
 
using wfile_view = basic_file_view< wchar_t >
 
using string_view = basic_string_view< char >
 
using wstring_view = basic_string_view< wchar_t >
 
using u16string_view = basic_string_view< char >
 
using u32wstring_view = basic_string_view< wchar_t >
 
template<typename Context >
using scan_result_for_t = typename scan_result_for< Context >::type
 

Functions

template<typename T >
temporary< T > temp (T &&val)
 Factory function for temporary. More...
 
template<typename Context , typename Visitor >
SCN_CLANG_POP SCN_CONSTEXPR14 error visit_arg (Visitor &&vis, typename Context::arg_type &arg)
 
template<typename Context , typename ParseCtx , typename... Args>
Context::template
arg_store_type< Args...> 
make_args (Args &...args)
 
template<typename Context >
auto get_arg (const basic_args< Context > &args, std::ptrdiff_t id) -> expected< basic_arg< Context >>
 
template<typename Context , typename ParseCtx >
auto get_arg (const basic_args< Context > &args, ParseCtx &pctx, std::ptrdiff_t id) -> expected< basic_arg< Context >>
 
template<typename Context , typename ParseCtx >
auto get_arg (const basic_args< Context > &, ParseCtx &, basic_string_view< typename Context::char_type >) -> expected< basic_arg< Context >>
 
template<typename Context , typename ParseCtx >
auto next_arg (const basic_args< Context > &args, ParseCtx &pctx) -> expected< basic_arg< Context >>
 
template<typename CharT >
SCN_CLANG_PUSH basic_file_view
< CharT > & 
stdin_range ()
 
file_viewcstdin ()
 
wfile_viewwcstdin ()
 
template<typename WrappedRange , typename std::enable_if< WrappedRange::is_direct >::type * = nullptr>
expected
< detail::ranges::range_value_t
< WrappedRange > > 
read_char (WrappedRange &r)
 Reads a single character from the range. More...
 
template<typename WrappedRange , typename std::enable_if<!WrappedRange::is_direct >::type * = nullptr>
detail::ranges::range_value_t
< WrappedRange > 
read_char (WrappedRange &r)
 
constexpr bool operator== (error a, error b) noexcept
 
constexpr bool operator!= (error a, error b) noexcept
 
template<typename T , typename U = typename std::remove_cv< typename std::remove_reference<T>::type>::type>
SCN_CLANG_POP expected< U > make_expected (T &&val)
 
template<typename Range , typename Format , typename... Args>
auto scan (Range &&r, const Format &f, Args &...a) -> detail::scan_result_for_range_t< Range >
 The most fundamental part of the scanning API. More...
 
template<typename Locale , typename Range , typename Format , typename... Args>
auto scan_localized (const Locale &loc, Range &&r, const Format &f, Args &...a) -> detail::scan_result_for_range_t< Range >
 Read from the range in r using the locale in loc. More...
 
template<typename Range , typename... Args>
auto scan (Range &&r, detail::default_t, Args &...a) -> detail::scan_result_for_range_t< Range >
 Equivalent to scan, but with a format string with the appropriate amount of space-separated "{}"s for the number of arguments. More...
 
template<typename T , typename Range >
auto scan_value (Range &&r) -> detail::scan_result_for_range_t< Range, expected< T >>
 Scans a single value with the default options, returning it instead of using an output parameter. More...
 
template<typename Range , typename Format , typename... Args>
auto scanf (Range &&r, const Format &f, Args &...a) -> detail::scan_result_for_range_t< Range >
 Otherwise equivalent to scan, except it uses scanf-like format string syntax, instead of the Python-like default one. More...
 
template<typename Format , typename... Args, typename CharT = detail::ranges::range_value_t<Format>>
auto input (const Format &f, Args &...a) -> detail::scan_result_for_range_t< decltype(stdin_range< CharT >())>
 Otherwise equivalent to scan, expect reads from stdin. More...
 
template<typename Format , typename... Args, typename CharT = detail::ranges::range_value_t<Format>>
auto prompt (const CharT *p, const Format &f, Args &...a) -> detail::scan_result_for_range_t< decltype(stdin_range< CharT >())>
 Equivalent to input, except writes what's in p to stdout. More...
 
template<typename T , typename CharT >
expected< const CharT * > parse_integer (basic_string_view< CharT > str, T &val, int base=10)
 Parses an integer into val in base base from str. More...
 
template<typename Range , typename String , typename CharT >
auto getline (Range &&r, String &str, CharT until) -> decltype(detail::getline_impl(std::declval< decltype(detail::wrap(std::forward< Range >(r)))& >(), str, until))
 Read the range in r into str until until is found. More...
 
template<typename Range , typename String , typename CharT = typename detail::extract_char_type<detail::ranges::iterator_t< detail::range_wrapper_for_t<Range>>>::type>
auto getline (Range &&r, String &str) -> decltype(getline(std::forward< Range >(r), str, detail::ascii_widen< CharT >('\n')))
 Equivalent to getline with the last parameter set to '\n' with the appropriate character type. More...
 
template<typename Range , typename CharT >
auto ignore_until (Range &&r, CharT until) -> decltype(detail::ignore_until_impl(std::declval< decltype(detail::wrap(std::forward< Range >(r)))& >(), until))
 Advances the beginning of r until until is found. More...
 
template<typename Range , typename CharT >
auto ignore_until_n (Range &&r, detail::ranges::range_difference_t< Range > n, CharT until) -> decltype(detail::ignore_until_n_impl(std::declval< decltype(detail::wrap(std::forward< Range >(r)))& >(), n, until))
 Advances the beginning of r until until is found, or the beginning has been advanced n times. More...
 
template<typename Range , typename Container , typename CharT >
auto scan_list (Range &&r, Container &c, CharT separator) -> detail::scan_result_for_range_t< Range, wrapped_error >
 Reads values repeatedly from r and writes them into c. More...
 
template<typename T >
discard_type< T > & discard ()
 Scans an instance of T, but doesn't store it anywhere. More...
 
template<typename T >
constexpr span< T > make_span (T *ptr, std::size_t count) noexcept
 
template<typename T >
constexpr span< T > make_span (T *first, T *last) noexcept
 
template<typename T >
constexpr span< typename
T::value_type > 
make_span (T &container) noexcept
 
template<typename... Args, typename Range , typename Format >
SCN_NODISCARD auto scan_tuple (const Range &r, Format f) -> std::tuple< detail::scan_result_for_range_t< const Range & >, Args...>
 
template<typename... Args, typename Range , typename Format >
SCN_NODISCARD auto scan_tuple (Range &&r, Format f) -> typename std::enable_if< !std::is_reference< Range >::value, std::tuple< detail::scan_result_for_range_t< Range >, Args...>>::type
 
template<typename... Args, typename Range >
SCN_NODISCARD auto scan_tuple (const Range &r, detail::default_t) -> std::tuple< detail::scan_result_for_range_t< const Range & >, Args...>
 
template<typename... Args, typename Range >
SCN_NODISCARD auto scan_tuple (Range &&r, detail::default_t) -> typename std::enable_if< !std::is_reference< Range >::value, std::tuple< detail::scan_result_for_range_t< Range >, Args...>>::type
 
template<typename Context , typename ParseCtx >
scan_result_for_t< Context > visit (Context &ctx, ParseCtx &pctx, basic_args< Context > args)
 
template<typename Context , typename ParseCtx >
scan_result_for_t< Context > vscan (Context &ctx, ParseCtx &pctx, basic_args< Context > args)
 
template<typename WrappedRange , typename std::enable_if< WrappedRange::is_contiguous >::type * = nullptr>
expected< span< const typename
detail::extract_char_type
< typename
WrappedRange::iterator >::type > > 
read_zero_copy (WrappedRange &r, detail::ranges::range_difference_t< WrappedRange > n)
 Reads up to n characters from r, and returns a span into the range. More...
 
template<typename WrappedRange , typename std::enable_if< WrappedRange::is_contiguous >::type * = nullptr>
expected< span< const typename
detail::extract_char_type
< typename
WrappedRange::iterator >::type > > 
read_all_zero_copy (WrappedRange &r)
 Reads every character from r, and returns a span into the range. More...
 
template<typename WrappedRange , typename OutputIterator , typename std::enable_if< WrappedRange::is_contiguous >::type * = nullptr>
error read_into (WrappedRange &r, OutputIterator &it, detail::ranges::range_difference_t< WrappedRange > n)
 Reads n characters from r into it. More...
 
template<typename WrappedRange , typename Predicate , typename std::enable_if< WrappedRange::is_contiguous >::type * = nullptr>
expected< span< const typename
detail::extract_char_type
< typename
WrappedRange::iterator >::type > > 
read_until_space_zero_copy (WrappedRange &r, Predicate is_space, bool keep_final_space)
 Reads characters from r until a space is found (as determined by is_space), and returns a span into the range. More...
 
template<typename WrappedRange , typename OutputIterator , typename Predicate , typename std::enable_if< WrappedRange::is_contiguous >::type * = nullptr>
error read_until_space (WrappedRange &r, OutputIterator &out, Predicate is_space, bool keep_final_space)
 Reads characters from r until a space is found (as determined by is_space) and writes them into out. More...
 
template<typename WrappedRange , typename OutputIterator , typename Sentinel , typename Predicate , typename std::enable_if< WrappedRange::is_direct >::type * = nullptr>
error read_until_space_ranged (WrappedRange &r, OutputIterator &out, Sentinel end, Predicate is_space, bool keep_final_space)
 Reads characters from r until a space is found (as determined by is_space), or out reaches end, and writes them into out. More...
 
template<typename WrappedRange , typename std::enable_if< WrappedRange::is_contiguous >::type * = nullptr>
error putback_n (WrappedRange &r, detail::ranges::range_difference_t< WrappedRange > n)
 Puts back n characters into r as if by repeatedly calling r.advance(-1) . More...
 
template<typename Context , typename std::enable_if< !Context::range_type::is_contiguous >::type * = nullptr>
error skip_range_whitespace (Context &ctx) noexcept
 Reads from the range in ctx as if by repeatedly calling read_char(), until a non-space character is found (as determined by ctx.locale()), or EOF is reached. More...
 

Typedef Documentation

using scn::file = typedef basic_file<char>

Definition at line 398 of file file.h.

using scn::file_view = typedef basic_file_view<char>

Definition at line 459 of file file.h.

using scn::mapped_file = typedef basic_mapped_file<char>

Definition at line 137 of file file.h.

template<typename Context >
using scn::scan_result_for_t = typedef typename scan_result_for<Context>::type

Definition at line 206 of file visitor.h.

using scn::string_view = typedef basic_string_view<char>

Definition at line 273 of file string_view.h.

using scn::u16string_view = typedef basic_string_view<char>

Definition at line 275 of file string_view.h.

using scn::u32wstring_view = typedef basic_string_view<wchar_t>

Definition at line 276 of file string_view.h.

using scn::wfile = typedef basic_file<wchar_t>

Definition at line 399 of file file.h.

using scn::wfile_view = typedef basic_file_view<wchar_t>

Definition at line 460 of file file.h.

using scn::wmapped_file = typedef basic_mapped_file<wchar_t>

Definition at line 138 of file file.h.

using scn::wstring_view = typedef basic_string_view<wchar_t>

Definition at line 274 of file string_view.h.

Function Documentation

file_view& scn::cstdin ( )
inline

Definition at line 477 of file file.h.

template<typename Context >
auto scn::get_arg ( const basic_args< Context > &  args,
std::ptrdiff_t  id 
) -> expected<basic_arg<Context>>

Definition at line 88 of file context.h.

template<typename Context , typename ParseCtx >
auto scn::get_arg ( const basic_args< Context > &  args,
ParseCtx &  pctx,
std::ptrdiff_t  id 
) -> expected<basic_arg<Context>>

Definition at line 99 of file context.h.

template<typename Context , typename ParseCtx >
auto scn::get_arg ( const basic_args< Context > &  ,
ParseCtx &  ,
basic_string_view< typename Context::char_type >   
) -> expected<basic_arg<Context>>

Definition at line 108 of file context.h.

template<typename Context , typename ParseCtx , typename... Args>
Context::template arg_store_type<Args...> scn::make_args ( Args &...  args)

Definition at line 502 of file args.h.

template<typename T , typename U = typename std::remove_cv< typename std::remove_reference<T>::type>::type>
SCN_CLANG_POP expected<U> scn::make_expected ( T &&  val)

Definition at line 300 of file result.h.

template<typename T >
constexpr span<T> scn::make_span ( T *  ptr,
std::size_t  count 
)
noexcept

Definition at line 383 of file span.h.

template<typename T >
constexpr span<T> scn::make_span ( T *  first,
T *  last 
)
noexcept

Definition at line 388 of file span.h.

template<typename T >
constexpr span<typename T::value_type> scn::make_span ( T &  container)
noexcept

Definition at line 393 of file span.h.

template<typename Context , typename ParseCtx >
auto scn::next_arg ( const basic_args< Context > &  args,
ParseCtx &  pctx 
) -> expected<basic_arg<Context>>

Definition at line 117 of file context.h.

constexpr bool scn::operator!= ( error  a,
error  b 
)
inlinenoexcept

Definition at line 117 of file result.h.

constexpr bool scn::operator== ( error  a,
error  b 
)
inlinenoexcept

Definition at line 113 of file result.h.

template<typename WrappedRange , typename std::enable_if<!WrappedRange::is_direct >::type * = nullptr>
detail::ranges::range_value_t<WrappedRange> scn::read_char ( WrappedRange &  r)

Definition at line 66 of file reader.h.

template<typename... Args, typename Range , typename Format >
SCN_NODISCARD auto scn::scan_tuple ( const Range &  r,
Format  f 
) -> std::tuple<detail::scan_result_for_range_t<const Range&>, Args...>

Definition at line 174 of file tuple_return.h.

template<typename... Args, typename Range , typename Format >
SCN_NODISCARD auto scn::scan_tuple ( Range &&  r,
Format  f 
) -> typename std::enable_if< !std::is_reference<Range>::value, std::tuple<detail::scan_result_for_range_t<Range>, Args...>>::type

Definition at line 185 of file tuple_return.h.

template<typename... Args, typename Range >
SCN_NODISCARD auto scn::scan_tuple ( const Range &  r,
detail::default_t   
) -> std::tuple<detail::scan_result_for_range_t<const Range&>, Args...>

Definition at line 201 of file tuple_return.h.

template<typename... Args, typename Range >
SCN_NODISCARD auto scn::scan_tuple ( Range &&  r,
detail::default_t   
) -> typename std::enable_if< !std::is_reference<Range>::value, std::tuple<detail::scan_result_for_range_t<Range>, Args...>>::type

Definition at line 214 of file tuple_return.h.

template<typename CharT >
SCN_CLANG_PUSH basic_file_view<CharT>& scn::stdin_range ( )

Definition at line 471 of file file.h.

template<typename Context , typename ParseCtx >
scan_result_for_t<Context> scn::visit ( Context &  ctx,
ParseCtx &  pctx,
basic_args< Context >  args 
)

Definition at line 226 of file visitor.h.

template<typename Context , typename Visitor >
SCN_CLANG_POP SCN_CONSTEXPR14 error scn::visit_arg ( Visitor &&  vis,
typename Context::arg_type &  arg 
)

Definition at line 353 of file args.h.

wfile_view& scn::wcstdin ( )
inline

Definition at line 481 of file file.h.