|
A library for working with phylogenetic and population genetic data.
v0.27.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_IO_PARSER_H_
2 #define GENESIS_UTILS_IO_PARSER_H_
62 throw std::runtime_error(
63 "Expecting digit in " + source.
source_name() +
" at " + source.
at() +
"."
70 if( x > ( std::numeric_limits<T>::max() - y ) / 10 ) {
71 throw std::overflow_error(
72 "Numerical overflow in " + source.
source_name() +
" at " + source.
at() +
"."
95 throw std::runtime_error(
96 "Expecting number in " + source.
source_name() +
" at " + source.
at() +
"."
100 if( *source ==
'-' ) {
104 throw std::runtime_error(
105 "Expecting digit in " + source.
source_name() +
" at " + source.
at() +
"."
113 if( x < ( std::numeric_limits<T>::min() + y ) / 10 ) {
114 throw std::underflow_error(
115 "Numerical underflow in " + source.
source_name() +
" at " + source.
at() +
"."
125 if( *source ==
'+' ) {
128 return parse_unsigned_integer<T>(source);
137 return parse_signed_integer<T>(source);
161 throw std::runtime_error(
162 "Expecting float number in " + source.
source_name() +
" at " + source.
at() +
"."
168 if( *source ==
'-' ){
171 }
else if( *source ==
'+' ) {
176 bool found_mantisse =
false;
178 int y = *source -
'0';
182 found_mantisse =
true;
186 if( source && *source ==
'.' ) {
190 throw std::runtime_error(
191 "Invalid float number in " + source.
source_name() +
" at " + source.
at() +
"."
198 int y = *source -
'0';
201 found_mantisse =
true;
206 if( ! found_mantisse ) {
207 throw std::runtime_error(
208 "Invalid float number in " + source.
source_name() +
" at " + source.
at() +
"."
217 int e = parse_signed_integer<int>( source );
229 if( ( e & 1 ) == 0 ) {
298 bool use_escapes =
true,
299 bool use_twin_quotes =
false,
300 bool include_qmarks =
false
306 #endif // include guard
T parse_integer(utils::InputStream &source)
Alias for parse_signed_integer().
T parse_float(utils::InputStream &source)
Read a floating point number from a stream and return it.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
T parse_unsigned_integer(utils::InputStream &source)
Read an unsigned integer from a stream and return it.
constexpr bool is_digit(char c) noexcept
Return whether a char is a digit (0-9), ASCII-only.
T parse_signed_integer(utils::InputStream &source)
Read a signed integer from a stream and return it.
constexpr char to_lower(char c) noexcept
Return the lower case version of a letter, ASCII-only.
std::string parse_quoted_string(utils::InputStream &source, bool use_escapes, bool use_twin_quotes, bool include_qmarks)
Read a string in quotation marks from a stream and return it.
std::string parse_number_string(utils::InputStream &source)
Read a general number string from an input stream.