15 return c >=
'0' && c <=
'9';
20 return c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r' || c ==
'\f' || c ==
'\v';
25 if (!str)
return false;
32 if (*str ==
'\0')
return false;
34 bool negative =
false;
38 }
else if (*str ==
'+') {
42 if (*str ==
'\0' || !
isDigit(*str))
return false;
45 const fl::u32 max_div_10 = 214748364U;
46 const fl::u32 max_mod_10 = 7U;
47 const fl::u32 max_neg_div_10 = 214748364U;
48 const fl::u32 max_neg_mod_10 = 8U;
51 fl::u32 digit = *str -
'0';
55 if (value > max_neg_div_10 || (value == max_neg_div_10 && digit > max_neg_mod_10)) {
59 if (value > max_div_10 || (value == max_div_10 && digit > max_mod_10)) {
64 value = value * 10 + digit;
69 if (*str !=
'\0')
return false;
72 result = -
static_cast<fl::i32
>(value);
74 result =
static_cast<fl::i32
>(value);
82 if (!str)
return false;
89 if (*str ==
'\0')
return false;
94 }
else if (*str ==
'-') {
98 if (*str ==
'\0' || !
isDigit(*str))
return false;
101 const fl::u32 max_div_10 = 429496729U;
102 const fl::u32 max_mod_10 = 5U;
104 while (*str &&
isDigit(*str)) {
105 fl::u32 digit = *str -
'0';
108 if (value > max_div_10 || (value == max_div_10 && digit > max_mod_10)) {
112 value = value * 10 + digit;
117 if (*str !=
'\0')
return false;
147 if (c ==
'\n')
break;
148 if (c ==
'\r')
continue;
201 return !token.
empty();
235 if (parse_i32(token.
c_str(), temp) && temp >= -128 && temp <= 127) {
236 n =
static_cast<fl::i8>(temp);
250 if (parse_u32(token.
c_str(), temp) && temp <= 255) {
251 n =
static_cast<fl::u8>(temp);
265 if (parse_i32(token.
c_str(), temp) && temp >= -32768 && temp <= 32767) {
266 n =
static_cast<fl::i16
>(temp);
281 if (!parse_i32(token.
c_str(), n)) {
293 if (!parse_u32(token.
c_str(), n)) {
310 if (
ALMOST_EQUAL_FLOAT(f, 0.0f) && token !=
"0" && token !=
"0.0" && token !=
"0." && token.
find(
"0") != 0) {
324 d =
static_cast<double>(f);
326 if (
ALMOST_EQUAL_FLOAT(f, 0.0f) && token !=
"0" && token !=
"0.0" && token !=
"0." && token.
find(
"0") != 0) {
358 if (c ==
'\n')
break;
359 if (c ==
'\r')
continue;
361 char ch[2] = {
static_cast<char>(c),
'\0'};
377 return static_cast<int>(
static_cast<unsigned char>(
buffer_[
pos_++]));
410 return static_cast<int>(
static_cast<unsigned char>(
buffer_[
pos_]));
fl::size find(const char &value) const
const char * c_str() const
void clear(bool freeMemory=false)
istream_real & putback(char c)
char buffer_[BUFFER_SIZE]
static const fl::size BUFFER_SIZE
istream_real & operator>>(string &str)
bool readToken(string &token)
istream_real & getline(string &str)
Result type for promise operations.
string & append(const BitsetFixed< N > &bs)
#define FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS
#define ALMOST_EQUAL_FLOAT(a, b)
bool parse_u32(const char *str, fl::u32 &result)
bool parse_i32(const char *str, fl::i32 &result)
FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS istream cin
istream_real & cin_real()