The cigar semialphabet pairs a counter with a bio::alphabet::cigar_op letter. More...
#include <bio/alphabet/cigar/cigar.hpp>
Public Member Functions | |
Constructors, destructor and assignment | |
constexpr | cigar () noexcept=default |
Defaulted. | |
constexpr | cigar (cigar const &) noexcept=default |
Defaulted. | |
constexpr | cigar (cigar &&) noexcept=default |
Defaulted. | |
constexpr cigar & | operator= (cigar const &) noexcept=default |
Defaulted. | |
constexpr cigar & | operator= (cigar &&) noexcept=default |
Defaulted. | |
~cigar () noexcept=default | |
Defaulted. | |
constexpr | cigar (uint32_t const count, cigar_op op) noexcept |
Construct from component types. | |
constexpr | cigar (uint32_t const count) noexcept |
Construct from one component. | |
constexpr | cigar (cigar_op const op) noexcept |
Construct from one component. | |
constexpr cigar & | operator= (uint32_t const count) noexcept |
Assign from one component. | |
constexpr cigar & | operator= (cigar_op const op) noexcept |
Assign from one component. | |
Read functions | |
constexpr uint32_t | to_rank () const noexcept |
Return the letter's numeric value (rank in the alphabet). | |
constexpr | operator uint32_t () const |
Convert to number-component. | |
constexpr | operator cigar_op () const |
Convert to bio::alphabet::cigar_op component. | |
std::string_view | to_string (std::span< char > buffer) const noexcept |
Convert to string representation. | |
ranges::small_string< 10 > | to_string () const noexcept |
Convert to string representation. | |
Write functions | |
constexpr cigar & | assign_rank (uint32_t const r) noexcept |
Assign from a numeric value. | |
cigar & | assign_string (std::string_view const s) |
Assign from the string representation. | |
Friends | |
Get functions | |
template<meta::one_of< uint32_t, cigar_op > type> | |
constexpr type | get (cigar const &l) noexcept |
Get one of the two components from the cigar element (by type). | |
template<meta::one_of< uint32_t, cigar_op > type> | |
constexpr auto | get (cigar &l) noexcept |
Get one of the two components from the cigar element (by type). | |
template<size_t index> requires (index == 0 || index == 1) | |
constexpr auto | get (cigar const &l) noexcept |
Get one of the two components from the cigar element (by index). | |
template<size_t index> requires (index == 0 || index == 1) | |
constexpr auto | get (cigar &l) noexcept |
Get one of the two components from the cigar element (by index). | |
The cigar semialphabet pairs a counter with a bio::alphabet::cigar_op letter.
This semialphabet represents a unit in a CIGAR string, typically found in the SAM and BAM formats. It consists of two components, representing a number and symbol. These components are implemented as uint32_t and bio::alphabet::cigar_op, however, only values [0, 2^28)
are valid for the number component.
It has a "visual representation", but since this is a string and not a char, the type only models bio::alphabet::writable_semialphabet and not bio::alphabet::writable_alphabet. Members for reading/writing the string are provided.
To avoid confusion between string and char literal, this alphabet has no user defined literal operators. Always assign from a pair of uint32_t and bio::alphabet::cigar_op.
Objects of this type always occupy exactly 32bits of memory.
On little-endian CPU architectures (all platforms officially supported by BioC++), objects of this type are guaranteed to have the same binary representation as CIGAR elements in BAM files.
|
inlineconstexprnoexcept |
Assign from a numeric value.
r | The rank to be assigned. |
This overload overrides the base class's function to ensure correct binary layout.
Constant.
Guaranteed not to throw.
|
inline |
Assign from the string representation.
s | The string to assign from. |
std::invalid_argument | If the string does not begin with an integer. |
bio::alphabet::invalid_char_assignment | If the string does not end on a valid character for bio::alphabet::cigar_op. |
|
inlineconstexprnoexcept |
Return the letter's numeric value (rank in the alphabet).
This overload overrides the base class's function to ensure correct binary layout.
Constant.
In contrast to most alphabets, this function has more overhead than just returning the stored value.
Guaranteed not to throw.
|
inlinenoexcept |
Convert to string representation.
[in,out] | buffer | The place the string will be created in. |
This overload takes a character buffer that the string will be created in. The buffer is required to be large enough to hold the string representation; it is recommended to always pass a buffer of at least 10 characters! This is the maximum width of the string.
A string_view into the buffer is returned. This is the only way to know the size of the "string", so you should not discard the return-result. No 0-terminator is written into the buffer.
Get one of the two components from the cigar element (by type).
type | Return the element of specified type; eith uint32_t or bio::alphabet::cigar_op. |
|
friend |
Get one of the two components from the cigar element (by index).
index | Return the element of specified index; either 0 or 1 . |
Get one of the two components from the cigar element (by type).
type | Return the element of specified type; eith uint32_t or bio::alphabet::cigar_op. |
|
friend |
Get one of the two components from the cigar element (by index).
index | Return the element of specified index; either 0 or 1 . |