SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::record< field_types, field_ids > Struct Template Reference

The class template that file records are based on; behaves like a std::tuple. More...

#include <seqan3/io/record.hpp>

+ Inheritance diagram for seqan3::record< field_types, field_ids >:

Public Types

using base_type = detail::transfer_template_args_onto_t< field_types, std::tuple >
 A specialisation of std::tuple.
 

Public Member Functions

void clear () noexcept(noexcept(std::apply(expander, std::declval< record & >().as_base())))
 Clears containers that provide .clear() and (re-)initialises all other elements with = {}.
 
Constructors, destructor and assignment
 record ()=default
 Defaulted.
 
 record (record const &)=default
 Defaulted.
 
recordoperator= (record const &)=default
 Defaulted.
 
 record (record &&)=default
 Defaulted.
 
recordoperator= (record &&)=default
 Defaulted.
 
 ~record ()=default
 Defaulted.
 

Private Types

template<field f>
using field_constant = std::integral_constant< field, f >
 A type alias for std::integral_constant.
 

Private Member Functions

base_typeas_base () noexcept
 Returns the tuple as the underlying std::tuple type.
 

Static Private Member Functions

template<typename t >
static constexpr void clear_element (t &v) noexcept(noexcept(std::declval< t & >()=t{}))
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename t >
requires requires (t & v) { v.clear(); }
static constexpr void clear_element (t &v) noexcept(noexcept(v.clear()))
 Auxiliary functions for clear().
 
template<field f, typename tuple_t >
static decltype(auto) get_impl (field_constant< f >, tuple_t &&record_as_tuple)
 This is basically the seqan3::get<f>(static_cast<tuple>(record)) implementation.
 

Static Private Attributes

static constexpr auto expander
 A lambda function that expands a pack and calls clear_element on every argument in the pack.
 

Additional Inherited Members

Detailed Description

template<typename field_types, typename field_ids>
struct seqan3::record< field_types, field_ids >

The class template that file records are based on; behaves like a std::tuple.

Template Parameters
field_typesThe types of the fields in this record as a seqan3::type_list.
field_idsA seqan3::fields type with seqan3::field IDs corresponding to field_types.

This class template behaves just like a std::tuple, with the exception that it provides an additional get-interface that takes a seqan3::field identifier. The traditional get interfaces (via index and via type) are also supported, but discouraged, because accessing via seqan3::field is unambiguous and better readable.

Example

For input files this template is specialised automatically and provided by the file via its record_type member. For output files you my define it locally and pass instances of this to the output file's push_back().

This is how it works:

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <string>
#include <vector>
int main()
{
using namespace seqan3::literals;
// The order of the types below represent a mapping between the type and the key.
// record_type now mimics std::tuple<std::string, dna4_vector, std::vector<phred42>>,
// the order also depends on selected_ids
record_type my_record{};
std::get<1>(my_record) = "the most important sequence in the database"; // access via index
std::get<std::string>(my_record) = "the least important sequence in the database"; // access via type
}
Provides seqan3::dna4, container aliases and string literals.
The SeqAn namespace for literals.
Provides seqan3::phred42 quality scores.
Provides the seqan3::record template and the seqan3::field enum.
A class template that holds a choice of seqan3::field.
Definition record.hpp:125
The class template that file records are based on; behaves like a std::tuple.
Definition record.hpp:190
Type that contains multiple types.
Definition type_list.hpp:26
Provides seqan3::type_list.

Member Data Documentation

◆ expander

template<typename field_types , typename field_ids >
constexpr auto seqan3::record< field_types, field_ids >::expander
staticconstexprprivate
Initial value:
= [](auto &... args)
{
(clear_element(args), ...);
}
static constexpr void clear_element(t &v) noexcept(noexcept(v.clear()))
Auxiliary functions for clear().
Definition record.hpp:199

A lambda function that expands a pack and calls clear_element on every argument in the pack.


The documentation for this struct was generated from the following file:
Hide me