33#include <NDEVR/BaseValues.h>
34#include <NDEVR/Angle.h>
58 0.0000000000000000001,
61 template<
class t_type>
79 template<
class t_type>
80 static t_type
_parse(
const char* in,
const char** out, t_type NaN_Value,
bool check_overflow);
82 template<
class t_type>
87 template<
class t_type>
88 static constexpr t_type
parseUInt(
const char* in,
const char** out, t_type NaN_Value,
bool check_overflow)
90 if (*in <
'0' || *in >
'9')
96 for (
uint04 i = 0; i < maxDigits<t_type>() - 1; i++)
98 if (*in <
'0' || *in >
'9')
100 check_overflow =
false;
108 if (*in >=
'0' && *in <=
'9')
110 t_type new_value = (value * 10) + (*in -
'0');
112 if (new_value < value)
119 if (*in >
'0' && *in <
'9')
129 template <
class t_
int_type,
typename t_type>
130 static t_type
parseFloat(
const char* c,
const char** out_s, t_type NaN_Value,
bool check_overflow)
138 bool inv = (*c ==
'-');
139 if (inv || *c ==
'+')
141 t_int_type value = 0;
154 const char* c_old = c;
162 while (*c >=
'0' && *c <=
'9')
166 if (*c ==
'e' || *c ==
'E')
174 float_value = -float_value;
185 if (*in ==
'+') in++;
186 return parseUInt(in, out, NaN_Value, check_overflow);
191 if (*in ==
'+') in++;
192 return parseUInt(in, out, NaN_Value, check_overflow);
197 if (*in ==
'+') in++;
198 return parseUInt(in, out, NaN_Value, check_overflow);
203 if (*in ==
'+') in++;
204 return parseUInt(in, out, NaN_Value, check_overflow);
209 bool inv = (*in ==
'-');
210 if (inv || *in ==
'+')
215 return inv ? -value : value;
220 bool inv = (*in ==
'-');
221 if (inv || *in ==
'+')
226 return inv ? -value : value;
232 bool inv = (*in ==
'-');
233 if (inv || *in ==
'+')
238 return inv ? -value : value;
244 bool inv = (*in ==
'-');
245 if (inv || *in ==
'+')
276 if (*in <
'0' || *in >
'7')
278 value = (value << 3) + (*in -
'0');
293 if (*in >=
'0' && *in <=
'9')
294 value = (value << 4u) + (*in -
'0');
295 else if (*in >=
'A' && *in <=
'F')
296 value = (value << 4u) + (*in -
'A') + 10;
297 else if (*in >=
'a' && *in <=
'f')
298 value = (value << 4u) + (*in -
'a') + 10;
311 template<
class t_
char_type>
315 if (in >=
'0' && in <=
'9')
317 else if (in >=
'a' && in <=
'f')
318 out = 10u + in -
'a';
319 else if (in >=
'A' && in <=
'F')
320 out = 10u + in -
'A';
327 template<
class t_
char_type>
339 template<
class t_
char_type>
344 return 'x' == in[1] ? strtoul16(in + 2, out) : strtoul8(in + 1, out);
346 return strtoul10(in, out);
Stores an angle in an optimized format.
Definition StringStream.h:352
constexpr t_type internal() const
Definition Angle.h:313
Definition NumberParser.hpp:77
static sint02 _parse(const char *in, const char **out, sint02 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:218
static fltp08 _parse(const char *in, const char **out, fltp08 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:264
static t_type parse(const char *in, const char **out=nullptr, t_type NaN_Value=Constant< t_type >::NaN, bool check_overflow=true)
Definition NumberParser.hpp:83
static sint01 _parse(const char *in, const char **out, sint01 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:207
static uint01 _parse(const char *in, const char **out, uint01 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:183
static Angle< fltp04 > _parse(const char *in, const char **out, Angle< fltp04 > NaN_Value, bool check_overflow)
Definition NumberParser.hpp:359
static uint04 _parse(const char *in, const char **out, uint04 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:195
static Angle< sint04 > _parse(const char *in, const char **out, Angle< sint04 > NaN_Value, bool check_overflow)
Definition NumberParser.hpp:349
static uint02 _parse(const char *in, const char **out, uint02 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:189
static uint08 _parse(const char *in, const char **out, uint08 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:201
static sint08 _parse(const char *in, const char **out, sint08 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:242
static uint04 strtoul_cppstyle(const t_char_type *in, const t_char_type **out=nullptr)
Definition NumberParser.hpp:340
static t_type parseFloat(const char *c, const char **out_s, t_type NaN_Value, bool check_overflow)
Definition NumberParser.hpp:130
static sint04 _parse(const char *in, const char **out, sint04 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:230
static uint01 HexOctetToDecimal(const t_char_type *in)
Definition NumberParser.hpp:328
static uint04 HexDigitToDecimal(t_char_type in)
Definition NumberParser.hpp:312
static uint04 parseHex(const char *in, const char **out=nullptr)
Definition NumberParser.hpp:288
static t_type _parse(const char *in, const char **out, t_type NaN_Value, bool check_overflow)
static uint04 parseOctal(const char *in, const char **out=nullptr)
Definition NumberParser.hpp:271
static constexpr t_type parseUInt(const char *in, const char **out, t_type NaN_Value, bool check_overflow)
Definition NumberParser.hpp:88
static fltp04 _parse(const char *in, const char **out, fltp04 NaN_Value, bool check_overflow)
Definition NumberParser.hpp:258
static Angle< fltp08 > _parse(const char *in, const char **out, Angle< fltp08 > NaN_Value, bool check_overflow)
Definition NumberParser.hpp:354
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:76
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Definition BaseValues.hpp:86
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
int8_t sint01
-Defines an alias representing a 1 byte, signed integer. -Can represent exact integer values -127 thr...
Definition BaseValues.hpp:56
constexpr uint04 maxDigits< uint04 >()
Definition NumberParser.hpp:70
constexpr uint04 maxDigits< sint04 >()
Definition NumberParser.hpp:71
constexpr uint04 maxDigits< uint02 >()
Definition NumberParser.hpp:67
constexpr uint04 maxDigits< sint02 >()
Definition NumberParser.hpp:68
constexpr uint04 maxDigits< sint08 >()
Definition NumberParser.hpp:73
int16_t sint02
-Defines an alias representing a 2 byte, signed integer. -Can represent exact integer values -32767 t...
Definition BaseValues.hpp:66
constexpr uint04 maxDigits< uint08 >()
Definition NumberParser.hpp:74
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
constexpr uint04 maxDigits< uint01 >()
Definition NumberParser.hpp:64
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:109
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
constexpr uint04 maxDigits()
const fltp08 fast_atof_table[20]
Definition NumberParser.hpp:38
constexpr uint04 maxDigits< sint01 >()
Definition NumberParser.hpp:65
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition BaseValues.hpp:272