35 lines
714 B
C
35 lines
714 B
C
#ifndef BASIC_STRING_H
|
|
#define BASIC_STRING_H
|
|
|
|
#include "aliases.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif // __cplusplus
|
|
|
|
typedef struct bstr BasicString;
|
|
struct bstr {
|
|
u64 size;
|
|
const char *buf;
|
|
};
|
|
|
|
typedef struct strvw StringView;
|
|
struct strvw {
|
|
const u64 size;
|
|
const char *buf;
|
|
};
|
|
|
|
#define new_string(STR) \
|
|
{ .size = strlen(STR), .buf = STR }
|
|
#define wapp_bstr_new(STR) ((BasicString)new_string(STR))
|
|
#define wapp_strvw_new(STR) ((StringView)new_string(STR))
|
|
#define wapp_string_print(STR) (printf("%.*s\n", (i32)STR.size, STR.buf))
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif // __cplusplus
|
|
|
|
#endif // !BASIC_STRING_H
|