Skip to content

Commit

Permalink
Remove istream_view, add stdin_view
Browse files Browse the repository at this point in the history
  • Loading branch information
eliaskosunen committed Nov 26, 2023
1 parent 9130739 commit 8afba35
Show file tree
Hide file tree
Showing 29 changed files with 542 additions and 1,211 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ set(SCN_PUBLIC_HEADERS
include/scn/detail/format_string.h
include/scn/detail/format_string_parser.h
include/scn/detail/input_map.h
include/scn/detail/istream_range.h
include/scn/detail/istream_scanner.h
include/scn/detail/locale_ref.h
include/scn/detail/parse_context.h
Expand All @@ -59,6 +58,7 @@ set(SCN_PUBLIC_HEADERS
include/scn/detail/scan.h
include/scn/detail/scanner.h
include/scn/detail/scanner_builtin.h
include/scn/detail/stdin_view.h
include/scn/detail/unicode.h
include/scn/detail/visitor.h
include/scn/detail/vscan.h
Expand Down Expand Up @@ -103,10 +103,9 @@ set(SCN_PRIVATE_HEADERS
)
set(SCN_PRIVATE_SOURCES
src/scn/scan.cpp
src/scn/istream_range.cpp
src/scn/istream_scanner.cpp

src/scn/scanner.cpp
src/scn/stdin_view.cpp
src/scn/vscan.cpp

src/scn/impl/locale.cpp
Expand Down
1 change: 0 additions & 1 deletion include/scn/detail/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#pragma once

#include <scn/detail/args.h>
#include <scn/detail/istream_range.h>
#include <scn/detail/locale_ref.h>
#include <scn/detail/ranges.h>
#include <scn/util/string_view.h>
Expand Down
59 changes: 8 additions & 51 deletions include/scn/detail/input_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// https://github.com/eliaskosunen/scnlib

#include <scn/detail/erased_range.h>
#include <scn/detail/istream_range.h>
#include <scn/detail/stdin_view.h>
#include <scn/util/meta.h>
#include <scn/util/span.h>
#include <scn/util/string_view.h>
Expand Down Expand Up @@ -64,19 +64,11 @@ namespace scn {
return {r, N - 1};
}

#if !SCN_DISABLE_IOSTREAM
// istreambuf_view& -> istreambuf_subrange
template <typename CharT>
static std::enable_if_t<is_valid_char_type<CharT>,
basic_istreambuf_subrange<CharT>>
impl(const basic_istreambuf_view<CharT>& r, priority_tag<4>)
SCN_NOEXCEPT_P(std::is_nothrow_constructible_v<
basic_istreambuf_subrange<CharT>,
basic_istreambuf_view<CharT>&>)
static stdin_subrange impl(const stdin_view& v, priority_tag<4>)
{
return {r};
SCN_EXPECT(v.is_this_locked());
return {v};
}
#endif

#if !SCN_DISABLE_ERASED_RANGE
// erased_range& -> erased_subrange
Expand All @@ -92,39 +84,10 @@ namespace scn {
}
#endif

#if !SCN_DISABLE_IOSTREAM
// istreambuf_subrange -> self
template <typename CharT>
static std::enable_if_t<is_valid_char_type<CharT>,
basic_istreambuf_subrange<CharT>>
impl(basic_istreambuf_subrange<CharT> r, priority_tag<3>)
SCN_NOEXCEPT_P(std::is_nothrow_move_constructible_v<
basic_istreambuf_subrange<CharT>>)
{
return r;
}
template <typename Iterator,
typename Sentinel,
ranges::subrange_kind Kind,
typename CharT = ranges_std::iter_value_t<Iterator>>
static std::enable_if_t<
is_valid_char_type<CharT> &&
std::is_same_v<
Iterator,
typename basic_istreambuf_view<CharT>::iterator> &&
std::is_same_v<
Sentinel,
typename basic_istreambuf_view<CharT>::sentinel>,
basic_istreambuf_subrange<CharT>>
impl(ranges::subrange<Iterator, Sentinel, Kind> r, priority_tag<3>)
SCN_NOEXCEPT_P(std::is_nothrow_constructible_v<
basic_istreambuf_subrange<CharT>,
Iterator,
Sentinel>)
static stdin_subrange impl(stdin_subrange v, priority_tag<3>)
{
return {r.begin(), r.end()};
return v;
}
#endif

#if !SCN_DISABLE_ERASED_RANGE
// erased_subrange -> self
Expand Down Expand Up @@ -259,14 +222,8 @@ namespace scn {
std::basic_string_view<CharT> decay_source_range(
std::basic_string_view<CharT>);

#if !SCN_DISABLE_IOSTREAM
template <typename CharT>
basic_istreambuf_subrange<CharT> decay_source_range(
basic_istreambuf_subrange<CharT>);
template <typename CharT>
basic_istreambuf_subrange<CharT> decay_source_range(
const basic_istreambuf_view<CharT>&);
#endif
stdin_subrange decay_source_range(stdin_subrange);
stdin_subrange decay_source_range(const stdin_view&);

#if !SCN_DISABLE_ERASED_RANGE
template <typename CharT>
Expand Down
Loading

0 comments on commit 8afba35

Please sign in to comment.