mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-28 00:34:06 +02:00
48 lines
1.0 KiB
C
48 lines
1.0 KiB
C
#pragma once
|
|
|
|
#include "../collections/collection.h"
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
char* str_dup(const char* str);
|
|
|
|
typedef struct {
|
|
const char* ptr;
|
|
size_t len;
|
|
} StrSlice;
|
|
|
|
typedef struct {
|
|
const char* text;
|
|
size_t text_len;
|
|
size_t i;
|
|
const char* split;
|
|
size_t split_len;
|
|
} StrSplitter;
|
|
|
|
StrSplitter str_splitter(const char* text, size_t text_len, const char* split);
|
|
StrSlice str_split_next(StrSplitter* splitter);
|
|
|
|
DEFINE_VEC(char, String, string, 8)
|
|
|
|
void string_push_str(String* string, const char* str);
|
|
void string_push_fmt_va(String* string, const char* fmt, ...);
|
|
char* string_copy(const String* string);
|
|
|
|
#define string_pushf(STRING, ...) string_push_fmt_va(STRING, __VA_ARGS__)
|
|
|
|
DEFINE_VEC(char*, RawStrVec, rawstr_vec, 8)
|
|
|
|
#define MAX_HASH_INPUT_LEN 256 - 1
|
|
|
|
char* str_hash(const char* input);
|
|
bool str_hash_equal(const char* hash, const char* input);
|
|
|
|
uint64_t str_fast_hash(const char* input);
|
|
|
|
char* str_random(size_t length);
|
|
|
|
#ifdef RUN_TESTS
|
|
void test_util_str(void);
|
|
#endif
|