SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
trace_directions.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 <array>
13#include <string_view>
14
18
19namespace seqan3::detail
20{
21
29enum struct trace_directions : uint8_t
30{
32 none = 0b0'0000,
34 diagonal = 0b0'0001,
36 up_open = 0b0'0110,
38 up = 0b0'0100,
40 left_open = 0b1'1000,
42 left = 0b1'0000,
44 carry_up_open = 0b0'0010,
46 carry_left_open = 0b0'1000
47};
48
49} // namespace seqan3::detail
50
51namespace seqan3
52{
57template <>
58inline constexpr bool add_enum_bitwise_operators<seqan3::detail::trace_directions> = true;
60
76template <>
77struct trace_directions_printer<detail::trace_directions>
78{
79private:
81 static constexpr std::array<std::string_view, 32> unicode{
82 "↺", "↖", "↑", "↖↑", "⇡", "↖⇡", "↑⇡", "↖↑⇡", "←", "↖←", "↑←", "↖↑←", "⇡←", "↖⇡←", "↑⇡←", "↖↑⇡←",
83 "⇠", "↖⇠", "↑⇠", "↖↑⇠", "⇡⇠", "↖⇡⇠", "↑⇡⇠", "↖↑⇡⇠", "←⇠", "↖←⇠", "↑←⇠", "↖↑←⇠", "⇡←⇠", "↖⇡←⇠", "↑⇡←⇠", "↖↑⇡←⇠"};
84
86 static constexpr std::array<std::string_view, 32> csv{
87 "N", "D", "U", "DU", "u", "Du", "Uu", "DUu", "L", "DL", "UL", "DUL", "uL", "DuL", "UuL", "DUuL",
88 "l", "Dl", "Ul", "DUl", "ul", "Dul", "Uul", "DUul", "Ll", "DLl", "ULl", "DULl", "uLl", "DuLl", "UuLl", "DUuLl"};
89
90public:
101 template <typename stream_t>
102 requires detail::is_type_specialisation_of_v<stream_t, debug_stream_type>
103 constexpr void operator()(stream_t & stream, detail::trace_directions const trace) const
104 {
105 print_impl(stream, stream.flags2(), trace);
106 }
107
117 template <typename stream_t>
118 constexpr void operator()(stream_t & stream, detail::trace_directions const trace) const
119 {
120 print_impl(stream, fmtflags2::none, trace);
121 }
122
123private:
130 template <typename stream_t>
131 constexpr void print_impl(stream_t & stream, fmtflags2 const flag, detail::trace_directions const trace) const
132 {
133 bool const is_unicode = (flag & fmtflags2::utf8) == fmtflags2::utf8;
134 auto const & trace_dir = is_unicode ? unicode : csv;
135
136 stream << trace_dir[static_cast<size_t>(trace)];
137 }
138};
139
140} // namespace seqan3
Provides seqan3::add_enum_bitwise_operators.
Provides seqan3::debug_stream and related types.
fmtflags2
Flags that change the behaviour of the seqan3::debug_stream.
Definition debug_stream_type.hpp:32
@ utf8
Enables use of non-ASCII UTF8 characters in formatted output.
Definition debug_stream_type.hpp:34
@ none
No flag is set.
Definition debug_stream_type.hpp:33
@ flag
The alignment flag (bit information), uint16_t value.
T left(T... args)
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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
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
Definition default_printer.hpp:50
Provides type traits for working with templates.
Hide me