solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
str_to_num.h
Go to the documentation of this file.
1
6#ifndef D098E3F2_2EEB_4E1A_892A_156C7D7533C3
7#define D098E3F2_2EEB_4E1A_892A_156C7D7533C3
8
9#include <stdbool.h>
10#include <stdint.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16// Define error codes
17typedef enum { STO_SUCCESS, STO_OVERFLOW, STO_UNDERFLOW, STO_INVALID } StoError;
18
27StoError str_to_u8(const char* str, uint8_t* result);
28
37StoError str_to_i8(const char* str, int8_t* result);
38
47StoError str_to_u16(const char* str, uint16_t* result);
48
57StoError str_to_i16(const char* str, int16_t* result);
58
67StoError str_to_u32(const char* str, uint32_t* result);
68
77StoError str_to_i32(const char* str, int32_t* result);
78
87StoError str_to_u64(const char* str, uint64_t* result);
88
97StoError str_to_i64(const char* str, int64_t* result);
98
107StoError str_to_ulong(const char* str, unsigned long* result);
108
117StoError str_to_long(const char* str, long* result);
118
127StoError str_to_double(const char* str, double* result);
128
137StoError str_to_float(const char* str, float* result);
138
147StoError str_to_uint(const char* str, unsigned int* result);
148
158StoError str_to_uintptr(const char* str, uintptr_t* result);
159
168StoError str_to_int(const char* str, int* result);
169
179StoError str_to_ulong_base(const char* str, int base, unsigned long* result);
180
190StoError str_to_long_base(const char* str, int base, long* result);
191
201StoError str_to_int_base(const char* str, int base, int* result);
202
211StoError str_to_bool(const char* str, bool* result);
212
216const char* sto_error_string(StoError code);
217
218#ifdef __cplusplus
219}
220#endif
221
222#endif /* D098E3F2_2EEB_4E1A_892A_156C7D7533C3 */
StoError str_to_bool(const char *str, bool *result)
Converts a string to a boolean. Valid inputs are "true", "false", "yes", "no", "1",...
Definition str_to_num.c:257
StoError str_to_uintptr(const char *str, uintptr_t *result)
Converts a string to a uintptr_t.
Definition str_to_num.c:196
StoError str_to_ulong_base(const char *str, int base, unsigned long *result)
Converts a string to an unsigned long with a specified base.
StoError str_to_int_base(const char *str, int base, int *result)
Converts a string to an int with a specified base.
StoError str_to_float(const char *str, float *result)
Converts a string to a float.
Definition str_to_num.c:213
StoError str_to_ulong(const char *str, unsigned long *result)
Converts a string to an unsigned long.
StoError str_to_u64(const char *str, uint64_t *result)
Converts a string to a uint64_t.
StoError str_to_i64(const char *str, int64_t *result)
Converts a string to an int64_t.
StoError str_to_u8(const char *str, uint8_t *result)
Converts a string to a uint8_t.
StoError str_to_uint(const char *str, unsigned int *result)
Converts a string to an unsigned int.
StoError str_to_u32(const char *str, uint32_t *result)
Converts a string to a uint32_t.
StoError str_to_double(const char *str, double *result)
Converts a string to a double.
Definition str_to_num.c:229
StoError str_to_long_base(const char *str, int base, long *result)
Converts a string to a long with a specified base.
StoError str_to_u16(const char *str, uint16_t *result)
Converts a string to a uint16_t.
const char * sto_error_string(StoError code)
Definition str_to_num.c:273
StoError str_to_i32(const char *str, int32_t *result)
Converts a string to an int32_t.
StoError str_to_i16(const char *str, int16_t *result)
Converts a string to an int16_t.
StoError str_to_i8(const char *str, int8_t *result)
Converts a string to an int8_t.
StoError str_to_long(const char *str, long *result)
Converts a string to a long.
StoError str_to_int(const char *str, int *result)
Converts a string to an int.