SeqAn3 3.1.0-rc.2
The Modern C++ library for sequence analysis.
out_file_iterator.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <cassert>
16#include <seqan3/std/ranges>
17
19
20namespace seqan3::detail
21{
22
45template <typename file_type>
47{
48 static_assert(!std::is_const_v<file_type>,
49 "You cannot iterate over const files, because the iterator changes the file.");
50public:
57 using value_type = void;
59 using reference = void;
61 using const_reference = void;
63 using size_type = void;
67 using pointer = void *;
71
76 constexpr out_file_iterator() = default;
78 constexpr out_file_iterator(out_file_iterator const &) = default;
80 constexpr out_file_iterator & operator=(out_file_iterator const &) = default;
82 constexpr out_file_iterator (out_file_iterator &&) = default;
86 ~out_file_iterator() = default;
87
89 constexpr out_file_iterator(file_type & _host) noexcept :
90 host{&_host}
91 {}
93
99 {
100 return *this;
101 }
102
105 {
106 return *this;
107 }
108
110
112 {
113 return *this;
114 }
115
120 template <typename arg_t>
122 {
123 assert(host != nullptr);
124 host->push_back(std::forward<arg_t>(arg));
125 return *this;
126 }
128
135 constexpr bool operator==(std::default_sentinel_t const &) const noexcept
136 {
137 return false;
138 }
139
141 constexpr bool operator!=(std::default_sentinel_t const &) const noexcept
142 {
143 return true;
144 }
145
147 constexpr friend bool operator==(std::default_sentinel_t const &,
148 out_file_iterator const & it) noexcept
149 {
150 return (it == std::default_sentinel);
151 }
152
154 constexpr friend bool operator!=(std::default_sentinel_t const &,
155 out_file_iterator const & it) noexcept
156 {
157 return (it != std::default_sentinel);
158 }
160
161private:
163 file_type * host{};
164};
165
166} // namespace seqan3::detail
Output iterator necessary for providing a range-like interface in output file.
Definition: out_file_iterator.hpp:47
~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:104
out_file_iterator & operator++()
This is a no-op, returns reference to self.
Definition: out_file_iterator.hpp:98
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:154
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:147
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:121
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:63
void * pointer
The pointer type.
Definition: out_file_iterator.hpp:67
file_type * host
Pointer to file host.
Definition: out_file_iterator.hpp:163
constexpr out_file_iterator(out_file_iterator &&)=default
Move constructor.
out_file_iterator & operator*() noexcept
Return reference to self.
Definition: out_file_iterator.hpp:111
constexpr out_file_iterator(file_type &_host) noexcept
Construct with reference to host.
Definition: out_file_iterator.hpp:89
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:141
void reference
The reference type (void).
Definition: out_file_iterator.hpp:59
void value_type
The value type (void).
Definition: out_file_iterator.hpp:57
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:135
void const_reference
The const reference type (void).
Definition: out_file_iterator.hpp:61
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides platform and dependency checks.
Adaptations of concepts from the Ranges TS.