First commit
This commit is contained in:
51
include/DynString.h
Normal file
51
include/DynString.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef DYN_STRING_H_
|
||||
#define DYN_STRING_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "scufcont.h"
|
||||
|
||||
#define DYN_STRING_FMT(dstr) (int) (dstr).len, (dstr).data
|
||||
|
||||
#define DynString_is_null(dstr) ((dstr)->data == NULL)
|
||||
#define DynString_c_str(dstr) ((dstr)->data)
|
||||
|
||||
typedef struct {
|
||||
char* data;
|
||||
size_t len;
|
||||
size_t capacity;
|
||||
} DynString;
|
||||
|
||||
ScufContResult DynString_alloc(DynString* dstr, const char* str, const size_t len);
|
||||
ScufContResult DynString_reserve(DynString* dstr, const size_t new_capacity);
|
||||
void DynString_free(DynString* dstr);
|
||||
bool DynString_equal(const DynString* s1, const DynString* s2);
|
||||
bool DynString_equal_c_str(const DynString* s1, const char* s2);
|
||||
bool DynString_equal_next_chars_c_str(
|
||||
const DynString* dstr,
|
||||
const char* str,
|
||||
const size_t str_len,
|
||||
const size_t s
|
||||
);
|
||||
ScufContResult DynString_concat_c_str(
|
||||
DynString* dstr,
|
||||
const char* str,
|
||||
const size_t str_len
|
||||
);
|
||||
ScufContResult DynString_alloc_concat_c_strs(
|
||||
DynString* dstr,
|
||||
const char* s1,
|
||||
const size_t s1_len,
|
||||
const char* s2,
|
||||
const size_t s2_len
|
||||
);
|
||||
ScufContResult DynString_split(
|
||||
const DynString* dstr,
|
||||
const char* delim,
|
||||
DynString** split_arr,
|
||||
size_t* arr_len
|
||||
);
|
||||
void DynString_split_arr_free(DynString** arr, const size_t arr_len);
|
||||
|
||||
#endif // DYN_STRING_H_
|
||||
Reference in New Issue
Block a user