SeqAn3
seqan3::parse_asserter< condition_type > Struct Template Reference

A condition checker, that wraps a parse condition and throws a specified exception if the condition was not met. More...

#include <seqan3/io/stream/parse_condition.hpp>

Public Member Functions

template<char_adaptation_concept char_type>
void operator() (char_type const c) const
 Checks if the given character satisfies the associated parse condition. More...
 
constexpr parse_asserter (condition_type const &) noexcept
 Allow type deduction from constructor argument.
 

Static Public Attributes

static condition_type constexpr cond {}
 Stores an instance of the stateless condition.
 

Detailed Description

template<typename condition_type>
struct seqan3::parse_asserter< condition_type >

A condition checker, that wraps a parse condition and throws a specified exception if the condition was not met.

Template Parameters
condition_typeThe wrapped parse condition type to be use for testing.

The parse_asserter type is used to enforce that a parsed character satisfies certain conditions. For example, when reading an input fasta file and the expected alphabet is a dna4 but the actual data contained in the file is based on amino acids. Thus, the condition would not be satisfied, causing the exception to be thrown.

std::istringstream istr{"ATZE"};
std::istream_iterator<char> it{istr};
parse_asserter asserter{is_in_alphabet<dna5>};
while (it != std::istream_iterator<char>{})
{
SEQAN3_DOXYGEN_ONLY(asserter(*it)); // will throw when reading `Z` from the input stream.
++it;
}

Member Function Documentation

◆ operator()()

template<typename condition_type >
template<char_adaptation_concept char_type>
void seqan3::parse_asserter< condition_type >::operator() ( char_type const  c) const
inline

Checks if the given character satisfies the associated parse condition.

Parameters
[in]cThe character to be checked. Must satisfy the seqan3::char_adaptation_concept.

Complexity

Depends on the underlying condition to be checked. In the regular case it is constant.

Exception

Throws seqan3::parse_error if the associated condition is not met.

Concurrency

Thread-safe.


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