42 #include <range/v3/view/take_while.hpp> 43 #include <range/v3/algorithm/copy.hpp> 78 template <std::ranges::View urng_t,
bool require_eol>
79 class view_take_line :
public ranges::view_interface<view_take_line<urng_t, require_eol>>
91 template <
typename rng_t>
92 class iterator_type :
public inherited_iterator_base<iterator_type<rng_t>, std::ranges::iterator_t<rng_t>>
98 using base_t = inherited_iterator_base<iterator_type, std::ranges::iterator_t<rng_t>>;
107 iterator_type() =
default;
108 constexpr iterator_type(iterator_type
const & rhs) =
default;
109 constexpr iterator_type(iterator_type && rhs) =
default;
110 constexpr iterator_type &
operator=(iterator_type
const & rhs) =
default;
111 constexpr iterator_type &
operator=(iterator_type && rhs) =
default;
112 ~iterator_type() =
default;
115 iterator_type(base_base_t
const & it) : base_t{it} {}
122 using difference_type =
typename std::iterator_traits<base_base_t>::difference_type;
123 using value_type =
typename std::iterator_traits<base_base_t>::value_type;
124 using reference =
typename std::iterator_traits<base_base_t>::reference;
125 using pointer =
typename std::iterator_traits<base_base_t>::pointer;
126 using iterator_category =
typename std::iterator_traits<base_base_t>::iterator_category;
133 iterator_type & operator++()
135 *
this = ++
static_cast<base_base_t
>(*this);
143 *
this = ++
static_cast<base_base_t
>(*this);
149 *
this = ++
static_cast<base_base_t
>(*this);
158 iterator_type operator++(
int)
160 iterator_type cpy{*
this};
170 bool operator==(iterator_type
const & rhs)
const noexcept(!require_eol)
172 return static_cast<base_base_t
>(*this) ==
static_cast<base_base_t
>(rhs);
175 bool operator==(sentinel_type
const & rhs)
const noexcept(!require_eol)
184 if (static_cast<base_base_t>(*
this) == rhs)
186 if constexpr (require_eol)
187 throw unexpected_end_of_input{
"Reached end of input before end-of-line."};
192 return **
this ==
'\r' || **
this ==
'\n';
195 friend bool operator==(sentinel_type
const & lhs, iterator_type
const & rhs) noexcept(!require_eol)
200 bool operator!=(sentinel_type
const & rhs)
const noexcept(!require_eol)
202 return !(*
this == rhs);
205 bool operator!=(iterator_type
const & rhs)
const noexcept(!require_eol)
207 return static_cast<base_base_t
>(*this) !=
static_cast<base_base_t
>(rhs);
210 friend bool operator!=(sentinel_type
const & lhs, iterator_type
const & rhs) noexcept(!require_eol)
221 using reference = reference_t<urng_t>;
224 using const_reference = detail::transformation_trait_or_t<seqan3::reference<urng_t const>,
void>;
226 using value_type = value_type_t<urng_t>;
228 using size_type = void;
230 using difference_type = difference_type_t<urng_t>;
232 using iterator = iterator_type<urng_t>;
234 using const_iterator = detail::transformation_trait_or_t<std::type_identity<iterator_type<urng_t const>>,
void>;
240 view_take_line() =
default;
241 constexpr view_take_line(view_take_line
const & rhs) =
default;
242 constexpr view_take_line(view_take_line && rhs) =
default;
243 constexpr view_take_line &
operator=(view_take_line
const & rhs) =
default;
244 constexpr view_take_line &
operator=(view_take_line && rhs) =
default;
245 ~view_take_line() =
default;
250 view_take_line(urng_t _urange)
251 : urange{std::move(_urange)}
271 iterator
begin() noexcept
273 return {seqan3::begin(urange)};
277 const_iterator
begin() const noexcept
278 requires const_iterable_concept<urng_t>
284 const_iterator
cbegin() const noexcept
285 requires const_iterable_concept<urng_t>
303 sentinel_type
end() noexcept
305 return {seqan3::end(urange)};
309 sentinel_type
end() const noexcept
310 requires const_iterable_concept<urng_t>
316 sentinel_type
cend() const noexcept
317 requires const_iterable_concept<urng_t>
328 template <sequence_container_concept container_t>
329 operator container_t()
331 requires
std::CommonReference<
reference_t<container_t>, reference>
340 template <sequence_container_concept container_t>
341 operator container_t() const
343 requires
std::CommonReference<
reference_t<container_t>, reference> && const_iterable_concept<urng_t>
354 template <
typename urng_t,
bool require_eol = false>
355 view_take_line(urng_t) -> view_take_line<std::remove_reference_t<urng_t>, require_eol>;
364 template <
bool require_eol>
365 class take_line_fn :
public pipable_adaptor_base<take_line_fn<require_eol>>
369 using base_t = pipable_adaptor_base<take_line_fn<require_eol>>;
373 using base_t::base_t;
382 template <std::ranges::View urng_t>
383 static auto impl(urng_t urange)
385 return view_take_line<urng_t, require_eol>{std::move(urange)};
391 template <std::ranges::ViewableRange urng_t>
392 static auto impl(urng_t && urange)
394 return impl(
view::all(std::forward<urng_t>(urange)));
458 inline auto constexpr
take_line = detail::take_line_fn<false>{};
::ranges::cbegin cbegin
Alias for ranges::cbegin. Returns an iterator to the beginning of a range.
Definition: ranges:245
Provides exceptions used in the I/O module.
Provides C++20 additions to the <iterator> header.
Contains various shortcuts for common std::ranges functions.
Provides the seqan3::detail::inherited_iterator_base template.
SeqAn specific customisations in the standard namespace.
Definition: align_result.hpp:221
::ranges::copy copy
Alias for ranges::copy. Copies a range of elements to a new location.
Definition: ranges:200
t & operator=(t1 const &rhs)
Assignment operator.
Additional non-standard concepts for ranges.
auto constexpr take_line_or_throw
A view adaptor that returns a single line from the underlying range (throws if there is no end-of-lin...
Definition: take_line.hpp:471
Auxiliary header for the view submodule .
::ranges::iterator_t iterator_t
Alias for ranges::iterator_t. Obtains the iterator type of a range.
Definition: ranges:225
Adaptations of concepts from the Ranges TS.
::ranges::sentinel_t sentinel_t
Alias for ranges::sentinel_t. Obtains the sentinel type of a range.
Definition: ranges:220
::ranges::begin begin
Alias for ranges::begin. Returns an iterator to the beginning of a range.
Definition: ranges:185
Provides seqan3::view::all.
The SeqAn3 namespace for views.
Specifies requirements of a Range type for which begin returns a type that models std::ForwardIterato...
Definition: aligned_sequence_concept.hpp:288
Provides C++20 additions to the type_traits header.
constexpr auto all
A view that safely wraps a container (you will likely not need to use this unless defining a new view...
Definition: view_all.hpp:95
Provides various metafunctions used by the range module.
Provides various metafunctions for use on iterators.
::ranges::cend cend
Alias for ranges::cend. Returns an iterator to the end of a range.
Definition: ranges:250
Adaptations of concepts from the standard library.
constexpr auto back_inserter(container_t &container)
Create a std::back_insert_iterator for the argument.
Definition: iterator:79
::ranges::end end
Alias for ranges::end. Returns an iterator to the end of a range.
Definition: ranges:190
auto constexpr take_line
A view adaptor that returns a single line from the underlying range or the full range if there is no ...
Definition: take_line.hpp:458