SeqAn3
gap.hpp
Go to the documentation of this file.
1 // ==========================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert, FU Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ==========================================================================
34 
41 #pragma once
42 
43 #include <cassert>
44 
45 #include <seqan3/core/platform.hpp>
46 
47 namespace seqan3
48 {
49 
62 struct gap
63 {
65  using char_type = char;
67  using rank_type = bool;
68 
70  bool _bug_workaround; // See GCC Bug-Report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87113
72 
76  static const gap GAP;
79 
83  constexpr char_type to_char() const noexcept
85  {
86  return '-';
87  }
88 
90  constexpr rank_type to_rank() const noexcept
91  {
92  return 0;
93  }
95 
99  constexpr gap & assign_char([[maybe_unused]] char_type const c) noexcept
102  {
103  return *this;
104  }
105 
108  constexpr gap & assign_rank([[maybe_unused]] rank_type const i) noexcept
109  {
110  assert(i == 0);
111  return *this;
112  }
114 
116  static constexpr rank_type value_size{1};
117 
120  friend constexpr bool operator==(gap const &, gap const &) noexcept
121  {
122  return true;
123  }
124 
125  friend constexpr bool operator!=(gap const &, gap const &) noexcept
126  {
127  return false;
128  }
129 
130  friend constexpr bool operator<(gap const &, gap const &) noexcept
131  {
132  return false;
133  }
134 
135  friend constexpr bool operator>(gap const &, gap const &) noexcept
136  {
137  return false;
138  }
139 
140  friend constexpr bool operator<=(gap const &, gap const &) noexcept
141  {
142  return true;
143  }
144 
145  friend constexpr bool operator>=(gap const &, gap const &) noexcept
146  {
147  return true;
148  }
150 };
151 
152 constexpr gap gap::GAP{};
153 
154 }
Contains platform and dependency checks.
char char_type
The type of the alphabet when converted to char (e.g. via to_char()).
Definition: gap.hpp:65
The alphabet of a gap character &#39;-&#39;.
Definition: gap.hpp:62
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
bool rank_type
The type of the alphabet when represented as a number (e.g. via to_rank()).
Definition: gap.hpp:67
constexpr rank_type to_rank() const noexcept
Return the letter&#39;s numeric value or rank in the alphabet. (returns always 0)
Definition: gap.hpp:90
constexpr gap & assign_rank([[maybe_unused]] rank_type const i) noexcept
Assign from a numeric value (no-op, since gap has only one character).
Definition: gap.hpp:108
static constexpr rank_type value_size
The size of the alphabet, i.e. the number of different values it can take.
Definition: gap.hpp:116
constexpr gap & assign_char([[maybe_unused]] char_type const c) noexcept
Assign from a character (no-op, since gap has only one character).
Definition: gap.hpp:101
constexpr char_type to_char() const noexcept
Return the letter as a character of char_type (returns always &#39;-&#39;).
Definition: gap.hpp:84