1 #ifndef GENESIS_UTILS_IO_PARSER_H_ 2 #define GENESIS_UTILS_IO_PARSER_H_ 60 if( ! source || ! isdigit( *source ) ) {
61 throw std::runtime_error(
62 "Expecting digit in " + source.
source_name() +
" at " + source.
at() +
"." 66 while( source && isdigit( *source )) {
69 if( x > ( std::numeric_limits<T>::max() - y ) / 10 ) {
70 throw std::overflow_error(
71 "Numerical overflow in " + source.
source_name() +
" at " + source.
at() +
"." 94 throw std::runtime_error(
95 "Expecting number in " + source.
source_name() +
" at " + source.
at() +
"." 99 if( *source ==
'-' ) {
102 if( ! source || ! isdigit( *source ) ) {
103 throw std::runtime_error(
104 "Expecting digit in " + source.
source_name() +
" at " + source.
at() +
"." 109 while( source && isdigit( *source )) {
112 if( x < ( std::numeric_limits<T>::min() + y ) / 10 ) {
113 throw std::underflow_error(
114 "Numerical underflow in " + source.
source_name() +
" at " + source.
at() +
"." 124 if( *source ==
'+' ) {
127 return parse_unsigned_integer<T>(source);
136 return parse_signed_integer<T>(source);
160 throw std::runtime_error(
161 "Expecting float number in " + source.
source_name() +
" at " + source.
at() +
"." 167 if( *source ==
'-' ){
170 }
else if( *source ==
'+' ) {
175 bool found_mantisse =
false;
176 while( source && isdigit( *source )) {
177 int y = *source -
'0';
181 found_mantisse =
true;
185 if( source && *source ==
'.' ) {
188 if( ! source || ! isdigit( *source ) ) {
189 throw std::runtime_error(
190 "Invalid float number in " + source.
source_name() +
" at " + source.
at() +
"." 195 while( source && isdigit( *source )) {
197 int y = *source -
'0';
200 found_mantisse =
true;
205 if( ! found_mantisse ) {
206 throw std::runtime_error(
207 "Invalid float number in " + source.
source_name() +
" at " + source.
at() +
"." 212 if( source && tolower(*source) ==
'e' ) {
216 int e = parse_signed_integer<int>( source );
228 if( ( e & 1 ) == 0 ) {
297 bool use_escapes =
true,
298 bool use_twin_quotes =
false,
299 bool include_qmarks =
false 305 #endif // include guard 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.
T parse_unsigned_integer(utils::InputStream &source)
Read an unsigned integer 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_integer(utils::InputStream &source)
Alias for parse_signed_integer().
T parse_signed_integer(utils::InputStream &source)
Read a signed integer from a stream and return it.
std::string parse_number_string(utils::InputStream &source)
Read a general number string from an input stream.
T parse_float(utils::InputStream &source)
Read a floating point number from a stream and return it.