hex_to_str
This commit is contained in:
@@ -20,6 +20,7 @@ typedef int64_t i64;
|
||||
typedef uint64_t u64;
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
typedef void* ptr;
|
||||
|
||||
#if !__cplusplus
|
||||
typedef u8 bool;
|
||||
@@ -33,7 +34,7 @@ typedef const char* cstr;
|
||||
|
||||
#define nameof(V) #V
|
||||
|
||||
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
|
||||
#define ARRAY_LEN(A) (sizeof(A)/sizeof(A[0]))
|
||||
#define ALIGN_TO(_SIZE,_ALIGN) (((_SIZE) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1))
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
|
||||
@@ -21,7 +21,7 @@ void StringBuilder_append_str(StringBuilder* b, str s);
|
||||
void StringBuilder_append_i64(StringBuilder* b, i64 a);
|
||||
void StringBuilder_append_u64(StringBuilder* b, u64 a);
|
||||
void StringBuilder_append_f64(StringBuilder* b, f64 a);
|
||||
void StringBuilder_append_memory(StringBuilder* b, Array mem);
|
||||
void StringBuilder_append_memory(StringBuilder* b, Array mem, bool uppercase);
|
||||
|
||||
// adds '\0' to the buffer and returns pointer to buffer content
|
||||
str StringBuilder_getStr(StringBuilder* b);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../std.h"
|
||||
#include "char.h"
|
||||
#include "cstr.h"
|
||||
#include "../collections/Array.h"
|
||||
|
||||
typedef struct str {
|
||||
char* data;
|
||||
@@ -11,7 +12,7 @@ typedef struct str {
|
||||
} str;
|
||||
|
||||
/// creates str from a string literal
|
||||
#define STR(LITERAL) str_construct(LITERAL, ARRAY_SIZE(LITERAL) - 1, true)
|
||||
#define STR(LITERAL) str_construct(LITERAL, ARRAY_LEN(LITERAL) - 1, true)
|
||||
|
||||
#define str_construct(DATA, LEN, ZERO_TERMINATED) ((str){ .data = DATA, .size = LEN, .isZeroTerminated = ZERO_TERMINATED })
|
||||
|
||||
@@ -41,3 +42,5 @@ u32 str_hash32(str s);
|
||||
|
||||
str str_toUpper(str src);
|
||||
str str_toLower(str src);
|
||||
|
||||
str hex_to_str(Array buf, bool uppercase);
|
||||
Reference in New Issue
Block a user