CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
strnum.h
1#pragma once
2
3#include <cx/string/strbase.h>
4
5CX_C_BEGIN
6
44
45// for keeping annotations consistent and prototypes on a single line
46#define _strNumSuccess _Success_(return)
47
58
83_strNumSuccess bool strToInt32(_Out_ int32* _Nonnull out, _In_opt_ strref s, int base,
84 flags_t flags);
85
104_strNumSuccess bool strToUInt32(_Out_ uint32* _Nonnull out, _In_opt_ strref s, int base,
105 flags_t flags);
106
116_strNumSuccess bool strToInt64(_Out_ int64* _Nonnull out, _In_opt_ strref s, int base,
117 flags_t flags);
118
128_strNumSuccess bool strToUInt64(_Out_ uint64* _Nonnull out, _In_opt_ strref s, int base,
129 flags_t flags);
130
149bool strFromInt32(_Inout_ strhandle out, int32 i, uint16 base);
150
168bool strFromUInt32(_Inout_ strhandle out, uint32 i, uint16 base);
169
178bool strFromInt64(_Inout_ strhandle out, int64 i, uint16 base);
179
188bool strFromUInt64(_Inout_ strhandle out, uint64 i, uint16 base);
189
210_strNumSuccess bool strToFloat32(_Out_ float32* _Nonnull out, _In_opt_ strref s, flags_t flags);
211
228_strNumSuccess bool strToFloat64(_Out_ float64* _Nonnull out, _In_opt_ strref s, flags_t flags);
229
248bool strFromFloat32(_Inout_ strhandle out, float32 f);
249
266bool strFromFloat64(_Inout_ strhandle out, float64 f);
267
275
277#define STRNUM_INTBUF 66
278
293_Ret_valid_ uint8* _Nonnull _strnum_u64toa(_Out_writes_(STRNUM_INTBUF) uint8 buf[STRNUM_INTBUF],
294 _Out_opt_ uint32* _Nullable len, uint64 value,
295 uint16 base, uint32 mindigits, char sign, bool upper);
296
298#define STRNUM_FPDIGITS 18
299
301#define STRNUM_FPBUF 25
302
311uint32 _strnum_f64toa(float64 d, _Out_writes_(STRNUM_FPBUF) uint8 dest[STRNUM_FPBUF]);
312
320uint32 _strnum_f32toa(float32 f, _Out_writes_(STRNUM_FPBUF) uint8 dest[STRNUM_FPBUF]);
321
331int32 _strnum_grisu2_32(float32 f, _Out_writes_(18) uint8* _Nonnull digits,
332 _Inout_ int32* _Nonnull K);
333
342int32 _strnum_grisu2_64(float64 d, _Out_writes_(18) uint8* _Nonnull digits,
343 _Inout_ int32* _Nonnull K);
344
346
348
349CX_C_END
string * strhandle
Pointer to a string variable.
Definition strbase.h:64
uint32 _strnum_f32toa(float32 f, uint8 dest[STRNUM_FPBUF])
#define STRNUM_INTBUF
Buffer size for integer-to-string conversion (64-bit binary + sign + null terminator)
Definition strnum.h:277
uint8 * _strnum_u64toa(uint8 buf[STRNUM_INTBUF], uint32 *len, uint64 value, uint16 base, uint32 mindigits, char sign, bool upper)
uint32 _strnum_f64toa(float64 d, uint8 dest[STRNUM_FPBUF])
int32 _strnum_grisu2_32(float32 f, uint8 *digits, int32 *K)
int32 _strnum_grisu2_64(float64 d, uint8 *digits, int32 *K)
#define STRNUM_FPBUF
Buffer size for floating-point-to-string conversion (sign + digits + exponent + null)
Definition strnum.h:301
bool strToUInt32(uint32 *out, strref s, int base, flags_t flags)
bool strToInt64(int64 *out, strref s, int base, flags_t flags)
bool strToFloat64(float64 *out, strref s, flags_t flags)
bool strToInt32(int32 *out, strref s, int base, flags_t flags)
bool strFromInt32(strhandle out, int32 i, uint16 base)
bool strFromUInt64(strhandle out, uint64 i, uint16 base)
bool strFromFloat32(strhandle out, float32 f)
bool strFromInt64(strhandle out, int64 i, uint16 base)
STRNUM_FLAGS
Definition strnum.h:52
bool strToFloat32(float32 *out, strref s, flags_t flags)
bool strFromFloat64(strhandle out, float64 f)
bool strToUInt64(uint64 *out, strref s, int base, flags_t flags)
bool strFromUInt32(strhandle out, uint32 i, uint16 base)
@ STRNUM_NoTrailing
Reject anything following the number.
Definition strnum.h:53
@ STRNUM_NoPrefix
Do not accept a "0x" base prefix.
Definition strnum.h:55
@ STRNUM_NoWS
Do not skip leading whitespace.
Definition strnum.h:54
@ STRNUM_NoSign
Reject a leading '+' or '-'.
Definition strnum.h:56
Core string types and fundamental operations.