Skip to content

Commit e13c5c0

Browse files
committed
WIP
1 parent 21b6a45 commit e13c5c0

17 files changed

+3313
-11
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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+
8+
/*!\file
9+
* \brief Provides seqan3::add_enum_bitwise_operators.
10+
* \author Hannes Hauswedell <hannes.hauswedell AT fu-berlin.de>
11+
*/
12+
13+
#pragma once
14+
15+
#include <type_traits>
16+
17+
#include <seqan3/core/platform.hpp>
18+
19+
namespace bio::map_io
20+
{
21+
/*!\interface seqan3::enum_bitwise_operators
22+
* \brief You can expect these functions on all types that overload seqan3::add_enum_bitwise_operators.
23+
*/
24+
/*!\name Requirements for seqan3::enum_bitwise_operators
25+
* \relates seqan3::enum_bitwise_operators
26+
* \brief You can expect these member functions.
27+
* \{
28+
* \fn operator&(t lhs, t rhs)
29+
* \brief Returns the binary `&` operator of lhs and rhs.
30+
* \param lhs First enum.
31+
* \param rhs Second enum.
32+
*
33+
* \returns the binary conjunction of `lhs` and `rhs`.
34+
*
35+
* \fn operator|(t lhs, t rhs)
36+
* \brief Returns the binary `|` operator of lhs and rhs.
37+
* \param lhs First enum.
38+
* \param rhs Second enum.
39+
*
40+
* \returns the binary disjunction of `lhs` and `rhs`.
41+
*
42+
* \fn operator^(t lhs, t rhs)
43+
* \brief Returns the binary `^` operator of lhs and rhs.
44+
* \param lhs First enum.
45+
* \param rhs Second enum.
46+
*
47+
* \returns the binary XOR operation on `lhs` and `rhs`.
48+
*
49+
* \fn operator~(t lhs)
50+
* \brief Returns the binary `~` operator of lhs.
51+
* \param lhs First enum.
52+
*
53+
* \returns the binary NOT operation on `lhs`.
54+
*
55+
* \fn operator&=(t & lhs, t rhs)
56+
* \brief Returns the binary `&=` operator of lhs and rhs.
57+
* \param lhs First enum.
58+
* \param rhs Second enum.
59+
*
60+
* \returns the binary AND assigment on `lhs`.
61+
*
62+
* \fn operator|=(t & lhs, t rhs)
63+
* \brief Returns the binary `|=` operator of lhs and rhs.
64+
* \param lhs First enum.
65+
* \param rhs Second enum.
66+
*
67+
* \returns the binary OR assignment on `lhs`.
68+
*
69+
* \fn operator^=(t & lhs, t rhs)
70+
* \brief Returns the binary `^=` operator of lhs and rhs.
71+
* \param lhs First enum.
72+
* \param rhs Second enum.
73+
*
74+
* \returns the binary XOR assignment on `lhs`.
75+
* \}
76+
*/
77+
78+
//!\cond DEV
79+
/*!\brief Set to true for a scoped enum to have binary operators overloaded.
80+
* \ingroup core
81+
*
82+
* \details
83+
*
84+
* If this type trait is specialised for an enum, the binary operators `&`, `|`, `^`, `~`, `&=`, `|=`, `^=` will be
85+
* added and behave just like for ints or unscoped enums.
86+
*
87+
* ### Example
88+
*
89+
* \include test/snippet/core/add_enum_bitwise_operators.cpp
90+
*/
91+
template <typename t>
92+
constexpr bool add_enum_bitwise_operators = false;
93+
94+
/*!\name Binary operators for scoped enums
95+
* \brief Perform binary operations like on ints or weak enums. These overloads are available if
96+
* seqan3::add_enum_bitwise_operators is defined for your type.
97+
* \ingroup core
98+
*
99+
* \details
100+
*
101+
* \see seqan3::add_enum_bitwise_operators
102+
* \{
103+
*/
104+
template <typename t>
105+
constexpr t operator& (t lhs, t rhs) noexcept
106+
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
107+
{
108+
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) & static_cast<std::underlying_type_t<t>>(rhs));
109+
}
110+
111+
template <typename t>
112+
constexpr t operator| (t lhs, t rhs) noexcept
113+
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
114+
{
115+
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) | static_cast<std::underlying_type_t<t>>(rhs));
116+
}
117+
118+
template <typename t>
119+
constexpr t operator^ (t lhs, t rhs) noexcept
120+
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
121+
{
122+
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) ^ static_cast<std::underlying_type_t<t>>(rhs));
123+
}
124+
125+
template <typename t>
126+
constexpr t operator~ (t lhs) noexcept
127+
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
128+
{
129+
return static_cast<t>(~static_cast<std::underlying_type_t<t>>(lhs));
130+
}
131+
132+
template <typename t>
133+
constexpr t & operator&= (t & lhs, t rhs) noexcept
134+
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
135+
{
136+
lhs = lhs & rhs;
137+
return lhs;
138+
}
139+
140+
template <typename t>
141+
constexpr t & operator|= (t & lhs, t rhs) noexcept
142+
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
143+
{
144+
lhs = lhs | rhs;
145+
return lhs;
146+
}
147+
148+
template <typename t>
149+
constexpr t & operator^= (t & lhs, t rhs) noexcept
150+
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
151+
{
152+
lhs = lhs ^ rhs;
153+
return lhs;
154+
}
155+
//!\}
156+
//!\endcond
157+
158+
} // namespace bio::map_io

include/bio/format/sam.hpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
// Copyright (c) 2020-2021, deCODE Genetics
5+
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6+
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
7+
// -----------------------------------------------------------------------------------------------------
8+
9+
/*!\file
10+
* brief Provides the seqan3::format_sam.
11+
* \author Hannes Hauswedell <hannes.hauswedell AT decode.is>
12+
*/
13+
14+
#pragma once
15+
16+
#include <string>
17+
#include <vector>
18+
19+
#include <bio/platform.hpp>
20+
21+
namespace bio
22+
{
23+
24+
/*!\brief The sam format.
25+
* \ingroup format
26+
*
27+
* \details
28+
*
29+
* This is the sam format tag. If you want to read sam files, use bio::map_io::reader, and if you want
30+
* to write sam files, use bio::map_io::writer.
31+
*
32+
* ### Introduction
33+
*
34+
* sam is the de-facto-standard for mapping storage in bionformatics. See the
35+
* [article on wikipedia](todo) for a an in-depth description of the format.
36+
*
37+
* ### Fields
38+
*
39+
* todo
40+
*
41+
* ### Implementation notes
42+
*
43+
* todo
44+
*
45+
*/
46+
struct sam
47+
{
48+
//!\brief The valid file extensions for this format; note that you can modify this value.
49+
static inline std::vector<std::string> file_extensions{
50+
{"sam"}
51+
};
52+
};
53+
54+
} // namespace bio

0 commit comments

Comments
 (0)