3 #ifndef INCLUDE_NN_NLIB_STRTO_H_
4 #define INCLUDE_NN_NLIB_STRTO_H_
28 if (tmp > 127 || tmp < -128)
return ERANGE;
29 *v =
static_cast<int8_t
>(tmp);
38 if (tmp > 32767 || tmp < -32768)
return ERANGE;
39 *v =
static_cast<int16_t
>(tmp);
48 if (tmp > 255)
return ERANGE;
49 *v =
static_cast<uint8_t
>(tmp);
58 if (tmp > 65535)
return ERANGE;
59 *v =
static_cast<uint16_t
>(tmp);
67 #define NLIB_DEF_STRTO(from_type, to_type) \
69 NLIB_ALWAYS_INLINE errno_t StrTo(const char* s, int base, from_type* v) NLIB_NOEXCEPT \
71 return StrTo(s, base, reinterpret_cast<to_type*>(v)); \
74 NLIB_DEF_STRTO(
int, int32_t)
76 NLIB_DEF_STRTO(
signed char, int8_t)
77 NLIB_DEF_STRTO(
short, int16_t)
79 NLIB_DEF_STRTO(
long long, int64_t)
81 NLIB_DEF_STRTO(
unsigned int, uint32_t)
82 NLIB_DEF_STRTO(
unsigned char, uint8_t)
83 NLIB_DEF_STRTO(
unsigned short, uint16_t)
85 NLIB_DEF_STRTO(
unsigned long long, uint64_t)
106 #endif // INCLUDE_NN_NLIB_STRTO_H_
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
errno_t StrTo(const char *s, int base, int32_t *v) noexcept
Converts the string s into an int32_t-type integer.
A file that contains the configuration information for each development environment.