A library for working with phylogenetic and population genetic data.
v0.27.0
scanner.hpp File Reference
#include "genesis/utils/text/char.hpp"
#include <cassert>
#include <cctype>
#include <functional>
#include <stdexcept>

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::utils
 

Enumerations

enum  SkipWhitespace : unsigned char { kNone = 0, kLeading = 1, kTrailing = 2, kSurrounding = 3 }
 Option to determine how to treat surrounding whitespace when scanning an input stream. More...
 

Functions

template<typename InputStream >
void affirm_char_or_throw (InputStream &source, char criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone)
 Lexing function that checks whether the current char from the stream equals the provided one. More...
 
template<typename InputStream >
void affirm_char_or_throw (InputStream &source, std::function< bool(char)> criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone)
 Lexing function that checks whether the current char from the stream fulfills the provided criterion. More...
 
constexpr bool operator& (SkipWhitespace lhs, SkipWhitespace rhs) noexcept
 And-operator to check whether a SkipWhitespace is set. More...
 
template<typename InputStream >
char read_char_or_throw (InputStream &source, char criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone)
 Lexing function that reads a single char from the stream and checks whether it equals the provided one. More...
 
template<typename InputStream >
char read_char_or_throw (InputStream &source, std::function< bool(char)> criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone)
 Lexing function that reads a single char from the stream and checks whether it fulfills the provided criterion. More...
 
template<typename InputStream >
std::string read_to_end_of_line (InputStream &source)
 Lexing function that reads until the end of the line (i.e., to the new line char), and returns the read chars (excluding the new line char). More...
 
template<typename InputStream >
std::string read_until (InputStream &source, char criterion)
 Lexing function that reads from the stream until its current char equals the provided one. The read chars are returned. More...
 
template<typename InputStream >
std::string read_until (InputStream &source, std::function< bool(char)> criterion)
 Lexing function that reads from the stream until its current char fulfills the provided criterion. The read chars are returned. More...
 
template<typename InputStream >
std::string read_while (InputStream &source, char criterion)
 Lexing function that reads from the stream while its current char equals the provided one. The read chars are returned. More...
 
template<typename InputStream >
std::string read_while (InputStream &source, std::function< bool(char)> criterion)
 Lexing function that reads from the stream while its current char fulfills the provided criterion. The read chars are returned. More...
 
template<typename InputStream >
void skip_to_end_of_line (InputStream &source)
 Lexing function that advances the stream to the end of the line, i.e., to the new line char. More...
 
template<typename InputStream >
void skip_until (InputStream &source, char criterion)
 Lexing function that advances the stream until its current char equals the provided one. More...
 
template<typename InputStream >
void skip_until (InputStream &source, std::function< bool(char)> criterion)
 Lexing function that advances the stream until its current char fulfills the provided criterion. More...
 
template<typename InputStream >
void skip_while (InputStream &source, char criterion)
 Lexing function that advances the stream while its current char equals the provided one. More...
 
template<typename InputStream >
void skip_while (InputStream &source, std::function< bool(char)> criterion)
 Lexing function that advances the stream while its current char fulfills the provided criterion. More...