Loading...
Searching...
No Matches
trace_directions.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 <array>
#include <string_view>
#include <seqan3/core/add_enum_bitwise_operators.hpp>
#include <seqan3/core/debug_stream/debug_stream_type.hpp>
#include <seqan3/core/detail/template_inspection.hpp>
namespace seqan3::detail
{
enum struct trace_directions : uint8_t
{
none = 0b0'0000,
diagonal = 0b0'0001,
up_open = 0b0'0110,
up = 0b0'0100,
left_open = 0b1'1000,
left = 0b1'0000,
carry_up_open = 0b0'0010,
carry_left_open = 0b0'1000
};
} // namespace seqan3::detail
namespace seqan3
{
template <>
inline constexpr bool add_enum_bitwise_operators<seqan3::detail::trace_directions> = true;
template <>
struct trace_directions_printer<detail::trace_directions>
{
private:
static constexpr std::array<std::string_view, 32> unicode{
"↺", "↖", "↑", "↖↑", "⇡", "↖⇡", "↑⇡", "↖↑⇡", "←", "↖←", "↑←", "↖↑←", "⇡←", "↖⇡←", "↑⇡←", "↖↑⇡←",
"⇠", "↖⇠", "↑⇠", "↖↑⇠", "⇡⇠", "↖⇡⇠", "↑⇡⇠", "↖↑⇡⇠", "←⇠", "↖←⇠", "↑←⇠", "↖↑←⇠", "⇡←⇠", "↖⇡←⇠", "↑⇡←⇠", "↖↑⇡←⇠"};
static constexpr std::array<std::string_view, 32> csv{
"N", "D", "U", "DU", "u", "Du", "Uu", "DUu", "L", "DL", "UL", "DUL", "uL", "DuL", "UuL", "DUuL",
"l", "Dl", "Ul", "DUl", "ul", "Dul", "Uul", "DUul", "Ll", "DLl", "ULl", "DULl", "uLl", "DuLl", "UuLl", "DUuLl"};
public:
template <typename stream_t>
requires detail::is_type_specialisation_of_v<stream_t, debug_stream_type>
constexpr void operator()(stream_t & stream, detail::trace_directions const trace) const
{
print_impl(stream, stream.flags2(), trace);
}
template <typename stream_t>
constexpr void operator()(stream_t & stream, detail::trace_directions const trace) const
{
print_impl(stream, fmtflags2::none, trace);
}
private:
template <typename stream_t>
constexpr void print_impl(stream_t & stream, fmtflags2 const flag, detail::trace_directions const trace) const
{
bool const is_unicode = (flag & fmtflags2::utf8) == fmtflags2::utf8;
auto const & trace_dir = is_unicode ? unicode : csv;
stream << trace_dir[static_cast<size_t>(trace)];
}
};
} // namespace seqan3
add_enum_bitwise_operators.hpp
Provides seqan3::add_enum_bitwise_operators.
array
debug_stream_type.hpp
Provides seqan3::debug_stream and related types.
seqan3::fmtflags2
fmtflags2
Flags that change the behaviour of the seqan3::debug_stream.
Definition debug_stream_type.hpp:32
seqan3::fmtflags2::utf8
@ utf8
Enables use of non-ASCII UTF8 characters in formatted output.
Definition debug_stream_type.hpp:34
seqan3::fmtflags2::none
@ none
No flag is set.
Definition debug_stream_type.hpp:33
seqan3::field::flag
@ flag
The alignment flag (bit information), uint16_t value.
Definition record.hpp:84
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
string_view
seqan3::trace_directions_printer< detail::trace_directions >::operator()
constexpr void operator()(stream_t &stream, detail::trace_directions const trace) const
Prints the trace directions into the given stream.
Definition trace_directions.hpp:103
seqan3::trace_directions_printer< detail::trace_directions >::operator()
constexpr void operator()(stream_t &stream, detail::trace_directions const trace) const
Prints the trace directions into the given stream.
Definition trace_directions.hpp:118
seqan3::trace_directions_printer
Definition default_printer.hpp:50
template_inspection.hpp
Provides type traits for working with templates.
Hide me