32 lines
550 B
C
32 lines
550 B
C
#ifndef STRING_H
|
|
#define STRING_H
|
|
|
|
#include "memory.h"
|
|
|
|
#include <stddef.h>
|
|
|
|
#define STR_LIT(sp, s) string_create(sp, s, sizeof(s) - 1)
|
|
|
|
struct StringPool
|
|
{
|
|
Arena* a;
|
|
};
|
|
|
|
struct StringView
|
|
{
|
|
const char* buf;
|
|
size_t len;
|
|
};
|
|
|
|
typedef struct StringPool StringPool;
|
|
typedef struct StringView StringView;
|
|
|
|
StringPool string_pool_create(Arena* a);
|
|
|
|
StringView string_create(StringPool* sp, const char* s, size_t len);
|
|
|
|
// Ensure that lengths do not contain null term
|
|
StringView string_concat_ss(StringPool* sp, StringView* a, StringView* b);
|
|
|
|
#endif
|