Add BasicString
This commit is contained in:
parent
bb2db0d30d
commit
3f5e3558b9
10
src/strings/basic_string/basic_string.c
Normal file
10
src/strings/basic_string/basic_string.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include "basic_string.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void wapp_bstr_print(const BasicString *str) {
|
||||
if (!str) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%.*s\n", (i32)str->size, str->buf);
|
||||
}
|
25
src/strings/basic_string/basic_string.h
Normal file
25
src/strings/basic_string/basic_string.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef BASIC_STRING_H
|
||||
#define BASIC_STRING_H
|
||||
|
||||
#include "aliases.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct bstr BasicString;
|
||||
struct bstr {
|
||||
u64 size;
|
||||
const char *buf;
|
||||
};
|
||||
|
||||
#define wapp_bstr_new(STR) \
|
||||
(BasicString) { .size = strlen(STR), .str = STR }
|
||||
void wapp_bstr_print(const BasicString *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !BASIC_STRING_H
|
Loading…
Reference in New Issue
Block a user