SeqAn3
3.4.0
The Modern C++ library for sequence analysis.
Toggle main menu visibility
Loading...
Searching...
No Matches
transform.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3
// SPDX-License-Identifier: BSD-3-Clause
4
9
10
#pragma once
11
12
#include <
array
>
13
14
#include <
seqan3/utility/concept.hpp
>
15
#include <
seqan3/utility/detail/integer_traits.hpp
>
16
17
namespace
seqan3::detail
18
{
19
22
template
<
typename
char
_type>
23
inline
constexpr
std::array<char_type, detail::size_in_values_v<char_type>> to_lower_table{
24
[]()
constexpr
25
{
26
std::array<char_type, detail::size_in_values_v<char_type>> ret{};
27
28
for
(
size_t
i = 0; i < detail::size_in_values_v<char_type>; ++i)
29
ret[i] = i;
30
31
for
(
size_t
i = char_type{
'A'
}; i <= char_type{
'Z'
}; ++i)
32
ret[i] = ret[i] - char_type{
'A'
} + char_type{
'a'
};
33
34
return
ret;
35
}()};
36
39
template
<
typename
char
_type>
40
inline
constexpr
std::array<char_type, detail::size_in_values_v<char_type>> to_upper_table{
41
[]()
constexpr
42
{
43
std::array<char_type, detail::size_in_values_v<char_type>> ret{};
44
45
for
(
size_t
i = 0; i < detail::size_in_values_v<char_type>; ++i)
46
ret[i] = i;
47
48
for
(
size_t
i = char_type{
'a'
}; i <= char_type{
'z'
}; ++i)
49
ret[i] = ret[i] - char_type{
'a'
} + char_type{
'A'
};
50
51
return
ret;
52
}()};
53
54
}
// namespace seqan3::detail
55
56
namespace
seqan3
57
{
58
63
73
template
<builtin_
char
acter
char
_type>
74
constexpr
char_type
to_lower
(char_type
const
c)
noexcept
75
{
76
using
u_t =
std::make_unsigned_t<char_type>
;
77
return
detail::to_lower_table<char_type>[
static_cast<
u_t
>
(c)];
78
}
79
89
template
<builtin_
char
acter
char
_type>
90
constexpr
char_type
to_upper
(char_type
const
c)
noexcept
91
{
92
using
u_t =
std::make_unsigned_t<char_type>
;
93
return
detail::to_upper_table<char_type>[
static_cast<
u_t
>
(c)];
94
}
95
96
97
}
// namespace seqan3
array
integer_traits.hpp
Provides metaprogramming utilities for integer types.
std::make_unsigned_t
seqan3
The main SeqAn3 namespace.
Definition
aligned_sequence_concept.hpp:26
seqan3::to_upper
constexpr char_type to_upper(char_type const c) noexcept
Converts 'a'-'z' to 'A'-'Z' respectively; other characters are returned as is.
Definition
transform.hpp:90
seqan3::to_lower
constexpr char_type to_lower(char_type const c) noexcept
Converts 'A'-'Z' to 'a'-'z' respectively; other characters are returned as is.
Definition
transform.hpp:74
concept.hpp
Provides concepts that do not have equivalents in C++20.
Hide me
Version:
seqan3
utility
char_operations
transform.hpp
Generated on
for SeqAn3 by
1.17.0