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
35
36// for keeping annotations consistent and prototypes on a single line
37#define _strNumSuccess _Success_(return)
38
62_strNumSuccess bool strToInt32(_Out_ int32* _Nonnull out, _In_opt_ strref s, int base, bool strict);
63
81_strNumSuccess bool strToUInt32(_Out_ uint32* _Nonnull out, _In_opt_ strref s, int base,
82 bool strict);
83
93_strNumSuccess bool strToInt64(_Out_ int64* _Nonnull out, _In_opt_ strref s, int base, bool strict);
94
104_strNumSuccess bool strToUInt64(_Out_ uint64* _Nonnull out, _In_opt_ strref s, int base,
105 bool strict);
106
125bool strFromInt32(_Inout_ strhandle out, int32 i, uint16 base);
126
144bool strFromUInt32(_Inout_ strhandle out, uint32 i, uint16 base);
145
154bool strFromInt64(_Inout_ strhandle out, int64 i, uint16 base);
155
164bool strFromUInt64(_Inout_ strhandle out, uint64 i, uint16 base);
165
184_strNumSuccess bool strToFloat32(_Out_ float32* _Nonnull out, _In_opt_ strref s, bool strict);
185
202_strNumSuccess bool strToFloat64(_Out_ float64* _Nonnull out, _In_opt_ strref s, bool strict);
203
222bool strFromFloat32(_Inout_ strhandle out, float32 f);
223
240bool strFromFloat64(_Inout_ strhandle out, float64 f);
241
249
251#define STRNUM_INTBUF 66
252
267_Ret_valid_ uint8* _Nonnull _strnum_u64toa(_Out_writes_(STRNUM_INTBUF) uint8 buf[STRNUM_INTBUF],
268 _Out_opt_ uint32* _Nullable len, uint64 value,
269 uint16 base, uint32 mindigits, char sign, bool upper);
270
272#define STRNUM_FPDIGITS 18
273
275#define STRNUM_FPBUF 25
276
285uint32 _strnum_f64toa(float64 d, _Out_writes_(STRNUM_FPBUF) uint8 dest[STRNUM_FPBUF]);
286
294uint32 _strnum_f32toa(float32 f, _Out_writes_(STRNUM_FPBUF) uint8 dest[STRNUM_FPBUF]);
295
305int32 _strnum_grisu2_32(float32 f, _Out_writes_(18) uint8* _Nonnull digits,
306 _Inout_ int32* _Nonnull K);
307
316int32 _strnum_grisu2_64(float64 d, _Out_writes_(18) uint8* _Nonnull digits,
317 _Inout_ int32* _Nonnull K);
318
320
322
323CX_C_END
string * strhandle
Pointer to a string variable.
Definition strbase.h:45
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:251
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:275
bool strFromInt32(strhandle out, int32 i, uint16 base)
bool strFromUInt64(strhandle out, uint64 i, uint16 base)
bool strToUInt64(uint64 *out, strref s, int base, bool strict)
bool strToInt32(int32 *out, strref s, int base, bool strict)
bool strFromFloat32(strhandle out, float32 f)
bool strToFloat32(float32 *out, strref s, bool strict)
bool strFromInt64(strhandle out, int64 i, uint16 base)
bool strToUInt32(uint32 *out, strref s, int base, bool strict)
bool strFromFloat64(strhandle out, float64 f)
bool strToInt64(int64 *out, strref s, int base, bool strict)
bool strFromUInt32(strhandle out, uint32 i, uint16 base)
bool strToFloat64(float64 *out, strref s, bool strict)
Core string types and fundamental operations.