|
ʻOhana
Population structure, admixture history, and selection using learning methods.
|
7 #ifndef JADE_SCANNER_HPP__
8 #define JADE_SCANNER_HPP__
10 #include "jade.error.hpp"
17 template <
typename TChar>
83 const auto actual = _in.peek();
86 <<
"expected symbol '" <<
char_type(ch) <<
"' "
87 <<
"but encountered end of stream";
100 <<
"expected symbol '" <<
char_type(ch) <<
"' "
101 <<
"but encountered symbol '"
105 <<
"expected symbol '" <<
char_type(ch) <<
"' "
106 <<
"but encountered ASCII code " << actual;
114 return _in.peek() < 0;
125 while (::isdigit(_in.peek()))
141 return read_real<double>();
156 return read_real<float>();
169 template <
typename TValue>
172 static const auto hyphen =
char_type(
'-');
173 static const auto period =
char_type(
'.');
205 const auto length_str = out.str();
206 if (length_str.empty())
208 "expected a floating-point value but "
209 "did not encounter any digits");
217 if (length_in >> length)
220 <<
"expected a length but encountered '"
221 << length_str <<
"'";
245 const auto delims = delimeters ==
nullptr ? fallback : delimeters;
246 const auto length = char_traits_type::length(delims);
252 auto ch = _in.peek();
254 if (ch < 0 ||
nullptr != char_traits_type::find(
269 while (::isspace(_in.peek()))
293 if (ch != _in.peek())
307 std::unique_ptr<istream_type> _ptr;
312 typedef basic_scanner<char> scanner;
315 #endif // JADE_SCANNER_HPP__
std::basic_istringstream< char_type > istringstream_type
The input stream type.
std::basic_ostream< char_type > ostream_type
The output stream type.
string_type read_token(char_type const *const delimeters=nullptr)
Reads and returns a series of characters terminated by the end of the input stream or a specified del...
void expect(const char_type ch)
Skips whitespace and validates the next symbol in the stream matches the specified character....
double read_double()
Skips whitespace and then parses and returns a floating-point value from the specified stream....
bool is_end_of_data() const
float read_float()
Skips whitespace and then parses and returns a floating-point value from the specified stream....
TChar char_type
The character type.
basic_scanner(istream_type &in)
Initializes a new instance of the class to scan the specified stream.
void read_digits(ostream_type &out)
Reads a series of digits from the stream and copies them to the specified output stream....
std::char_traits< char_type > char_traits_type
The character traits type.
A template class that parses text and throws meaningful error messages.
std::basic_ostringstream< char_type > ostringstream_type
The output stream type.
TValue read_real()
Skips whitespace and then parses and returns a floating-point value from the specified stream....
void skip_whitespace()
Skips whitespace from the input stream. If the input stream indicates the end of the stream,...
bool try_char(const char_type ch)
Skips whitespace and then checks if the next character from the stream matches the specified characte...
A template for a class representing an exception thrown from this namespace.
std::basic_string< char_type > string_type
The string type.
basic_scanner(const string_type &in)
Initializes a new instance of the class to scan the specified string.
std::basic_istream< char_type > istream_type
The input stream type.