SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
out_file_iterator.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <cassert>
13#include <ranges>
14
16
17namespace seqan3::detail
18{
19
42template <typename file_type>
44{
45 static_assert(!std::is_const_v<file_type>,
46 "You cannot iterate over const files, because the iterator changes the file.");
47
48public:
55 using value_type = void;
57 using reference = void;
59 using const_reference = void;
61 using size_type = void;
65 using pointer = void *;
69
74 constexpr out_file_iterator() = default;
76 constexpr out_file_iterator(out_file_iterator const &) = default;
78 constexpr out_file_iterator & operator=(out_file_iterator const &) = default;
80 constexpr out_file_iterator(out_file_iterator &&) = default;
84 ~out_file_iterator() = default;
85
87 constexpr out_file_iterator(file_type & _host) noexcept : host{&_host}
88 {}
90
96 {
97 return *this;
98 }
99
102 {
103 return *this;
104 }
105
107
109 {
110 return *this;
111 }
112
117 template <typename arg_t>
119 {
120 assert(host != nullptr);
121 host->push_back(std::forward<arg_t>(arg));
122 return *this;
123 }
125
132 constexpr bool operator==(std::default_sentinel_t const &) const noexcept
133 {
134 return false;
135 }
136
138 constexpr bool operator!=(std::default_sentinel_t const &) const noexcept
139 {
140 return true;
141 }
142
144 constexpr friend bool operator==(std::default_sentinel_t const &, out_file_iterator const & it) noexcept
145 {
146 return (it == std::default_sentinel);
147 }
148
150 constexpr friend bool operator!=(std::default_sentinel_t const &, out_file_iterator const & it) noexcept
151 {
152 return (it != std::default_sentinel);
153 }
155
156private:
158 file_type * host{};
159};
160
161} // namespace seqan3::detail
Output iterator necessary for providing a range-like interface in output file.
Definition out_file_iterator.hpp:44
~out_file_iterator()=default
Use default deconstructor.
constexpr out_file_iterator & operator=(out_file_iterator const &)=default
Copy construction via assignment.
out_file_iterator operator++(int)
This is a no-op, returns copy of self. In contrast to input iterators, the return type is required.
Definition out_file_iterator.hpp:101
out_file_iterator & operator++()
This is a no-op, returns reference to self.
Definition out_file_iterator.hpp:95
constexpr friend bool operator!=(std::default_sentinel_t const &, out_file_iterator const &it) noexcept
Checks whether it is not equal to the sentinel.
Definition out_file_iterator.hpp:150
constexpr friend bool operator==(std::default_sentinel_t const &, out_file_iterator const &it) noexcept
Checks whether it is equal to the sentinel.
Definition out_file_iterator.hpp:144
constexpr out_file_iterator(out_file_iterator const &)=default
Copy constructor.
out_file_iterator & operator=(arg_t &&arg)
Insert the given value into the file, via the file's push_back() member.
Definition out_file_iterator.hpp:118
constexpr out_file_iterator()=default
Default constructor.
constexpr out_file_iterator & operator=(out_file_iterator &&)=default
Move assignment.
void size_type
The size type (void).
Definition out_file_iterator.hpp:61
void * pointer
The pointer type.
Definition out_file_iterator.hpp:65
file_type * host
Pointer to file host.
Definition out_file_iterator.hpp:158
constexpr out_file_iterator(out_file_iterator &&)=default
Move constructor.
out_file_iterator & operator*() noexcept
Return reference to self.
Definition out_file_iterator.hpp:108
constexpr out_file_iterator(file_type &_host) noexcept
Construct with reference to host.
Definition out_file_iterator.hpp:87
constexpr bool operator!=(std::default_sentinel_t const &) const noexcept
Checks whether *this is not equal to the sentinel (always true).
Definition out_file_iterator.hpp:138
void reference
The reference type (void).
Definition out_file_iterator.hpp:57
void value_type
The value type (void).
Definition out_file_iterator.hpp:55
constexpr bool operator==(std::default_sentinel_t const &) const noexcept
Checks whether *this is equal to the sentinel (always false).
Definition out_file_iterator.hpp:132
void const_reference
The const reference type (void).
Definition out_file_iterator.hpp:59
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides platform and dependency checks.
Hide me