Loading...
Searching...
No Matches
range.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <functional>
#include <ranges>
#include <seqan3/alphabet/adaptation/char.hpp>
#include <seqan3/alphabet/adaptation/uint.hpp>
#include <seqan3/alphabet/range/sequence.hpp>
#include <seqan3/core/debug_stream/debug_stream_type.hpp>
#include <seqan3/core/range/type_traits.hpp>
namespace seqan3
{
template <typename rng_t>
concept nonrecursive_range =
!std::same_as<std::remove_cvref_t<std::ranges::range_reference_t<rng_t>>, std::remove_cvref_t<rng_t>>;
template <typename rng_t>
requires std::ranges::input_range<rng_t> && nonrecursive_range<rng_t>
struct input_range_printer<rng_t>
{
template <typename stream_t, typename arg_t>
constexpr void operator()(stream_t & stream, arg_t && arg) const
{
stream << '[';
auto first = std::ranges::begin(arg);
auto last = std::ranges::end(arg);
if (first != last)
{
stream << *first;
++first;
}
while (first != last)
{
stream << ',';
stream << *first;
++first;
}
stream << ']';
}
};
template <sequence sequence_t>
struct sequence_printer<sequence_t>
{
template <typename stream_t, typename arg_t>
constexpr void operator()(stream_t & stream, arg_t && arg) const
{
for (auto && chr : arg)
stream << chr;
}
};
template <typename char_sequence_t>
requires std::ranges::input_range<char_sequence_t>
&& (detail::is_char_adaptation_v<std::remove_cvref_t<std::ranges::range_reference_t<char_sequence_t>>>)
struct char_sequence_printer<char_sequence_t>
{
template <typename stream_t, typename arg_t>
constexpr void operator()(stream_t & stream, arg_t && arg) const
{
// null-terminated string
if constexpr (std::is_pointer_v<std::decay_t<char_sequence_t>>)
return std::invoke(std_printer<char_sequence_t>{}, stream, std::forward<arg_t>(arg));
for (auto && chr : arg)
stream << chr;
}
};
template <typename integer_sequence_t>
requires std::ranges::input_range<integer_sequence_t>
&& std::integral<std::remove_cvref_t<std::ranges::range_reference_t<integer_sequence_t>>>
struct integer_sequence_printer<integer_sequence_t> : public input_range_printer<integer_sequence_t>
{};
} // namespace seqan3
char.hpp
Provides alphabet adaptations for standard char types.
seqan3::nonrecursive_range
Definition range.hpp:34
type_traits.hpp
Provides various transformation traits used by the range module.
debug_stream_type.hpp
Provides seqan3::debug_stream and related types.
std::forward
T forward(T... args)
functional
std::invoke
T invoke(T... args)
std::is_pointer_v
T is_pointer_v
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
sequence.hpp
Additional non-standard concepts for ranges.
seqan3::char_sequence_printer< char_sequence_t >::operator()
constexpr void operator()(stream_t &stream, arg_t &&arg) const
Prints the character sequence to the given stream.
Definition range.hpp:133
seqan3::char_sequence_printer
Definition default_printer.hpp:49
seqan3::input_range_printer< rng_t >::operator()
constexpr void operator()(stream_t &stream, arg_t &&arg) const
Prints the elements of a sequence to an output stream.
Definition range.hpp:64
seqan3::input_range_printer
Definition default_printer.hpp:36
seqan3::integer_sequence_printer
Definition default_printer.hpp:37
seqan3::sequence_printer< sequence_t >::operator()
constexpr void operator()(stream_t &stream, arg_t &&arg) const
Prints the elements of a sequence to an output stream.
Definition range.hpp:104
seqan3::sequence_printer
Definition default_printer.hpp:42
seqan3::std_printer
Definition default_printer.hpp:47
uint.hpp
Provides alphabet adaptations for standard uint types.
Hide me