Death to C++
This commit is contained in:
@@ -7,38 +7,38 @@
|
||||
////////////////////////////////
|
||||
// String types
|
||||
|
||||
struct Str8 {
|
||||
typedef struct Str8 {
|
||||
const char *str;
|
||||
U64 size;
|
||||
};
|
||||
} Str8;
|
||||
|
||||
struct Str8Node {
|
||||
Str8Node *next;
|
||||
Str8 string;
|
||||
};
|
||||
typedef struct Str8Node {
|
||||
struct Str8Node *next;
|
||||
Str8 string;
|
||||
} Str8Node;
|
||||
|
||||
struct Str8List {
|
||||
typedef struct Str8List {
|
||||
Str8Node *first;
|
||||
Str8Node *last;
|
||||
U64 count;
|
||||
U64 total_size;
|
||||
};
|
||||
} Str8List;
|
||||
|
||||
////////////////////////////////
|
||||
// Forward declaration for Arena
|
||||
struct Arena;
|
||||
typedef struct Arena Arena;
|
||||
|
||||
////////////////////////////////
|
||||
// Constructors
|
||||
|
||||
static inline Str8 str8(const char *s, U64 len) { return {s, len}; }
|
||||
static inline Str8 str8_cstr(const char *s) { return {s, s ? (U64)strlen(s) : 0}; }
|
||||
static inline Str8 str8_lit(const char *s) { return {s, s ? (U64)strlen(s) : 0}; }
|
||||
static inline Str8 str8(const char *s, U64 len) { Str8 r = {s, len}; return r; }
|
||||
static inline Str8 str8_cstr(const char *s) { Str8 r = {s, s ? (U64)strlen(s) : 0}; return r; }
|
||||
static inline Str8 str8_lit(const char *s) { Str8 r = {s, s ? (U64)strlen(s) : 0}; return r; }
|
||||
static inline B32 str8_match(Str8 a, Str8 b) {
|
||||
if (a.size != b.size) return 0;
|
||||
return MemoryCompare(a.str, b.str, a.size) == 0;
|
||||
}
|
||||
static inline B32 str8_is_empty(Str8 s) { return s.size == 0 || s.str == nullptr; }
|
||||
static inline B32 str8_is_empty(Str8 s) { return s.size == 0 || s.str == NULL; }
|
||||
|
||||
////////////////////////////////
|
||||
// String operations (require arena)
|
||||
|
||||
Reference in New Issue
Block a user