Renamed DynArray to DArray and added first tests
This commit is contained in:
51
include/DString.h
Normal file
51
include/DString.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef SCUFCONT_DSTRING_H_
|
||||
#define SCUFCONT_DSTRING_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "scufcont.h"
|
||||
|
||||
#define SCDSTRING_FMT(dstr) (int) (dstr).len, (dstr).data
|
||||
|
||||
#define SCDString_is_null(dstr) ((dstr)->data == NULL)
|
||||
#define SCDString_c_str(dstr) ((dstr)->data)
|
||||
|
||||
typedef struct {
|
||||
char* data;
|
||||
size_t len;
|
||||
size_t capacity;
|
||||
} SCDString;
|
||||
|
||||
ScufContResult SCDString_alloc(SCDString* dstr, const char* str, const size_t len);
|
||||
ScufContResult SCDString_reserve(SCDString* dstr, const size_t new_capacity);
|
||||
void SCDString_free(SCDString* dstr);
|
||||
bool SCDString_equal(const SCDString* s1, const SCDString* s2);
|
||||
bool SCDString_equal_c_str(const SCDString* s1, const char* s2);
|
||||
bool SCDString_equal_next_chars_c_str(
|
||||
const SCDString* dstr,
|
||||
const char* str,
|
||||
const size_t str_len,
|
||||
const size_t s
|
||||
);
|
||||
ScufContResult SCDString_concat_c_str(
|
||||
SCDString* dstr,
|
||||
const char* str,
|
||||
const size_t str_len
|
||||
);
|
||||
ScufContResult SCDString_alloc_concat_c_strs(
|
||||
SCDString* dstr,
|
||||
const char* s1,
|
||||
const size_t s1_len,
|
||||
const char* s2,
|
||||
const size_t s2_len
|
||||
);
|
||||
ScufContResult SCDString_split(
|
||||
const SCDString* dstr,
|
||||
const char* delim,
|
||||
SCDString** split_arr,
|
||||
size_t* arr_len
|
||||
);
|
||||
void SCDString_split_arr_free(SCDString** arr, const size_t arr_len);
|
||||
|
||||
#endif // SCUFCONT_DSTRING_H_
|
||||
Reference in New Issue
Block a user