a wrapper around strings

This commit is contained in:
Odweta
2024-02-04 18:51:42 +01:00
parent 53a282a3ea
commit 8832a2a4aa
9 changed files with 210 additions and 103 deletions
+27
View File
@@ -0,0 +1,27 @@
#ifndef STRING_H
#define STRING_H
#include <odweta/util.h>
typedef struct {
char *content;
size_t length;
} string_t;
string_t *string_new(); // create a new empty string
string_t *string_from(char *chars); // create a new string from a given char_sequence
bool string_push_chars(string_t *this, char *chars); // append a char_sequence to a string
bool string_push(string_t *this, string_t *other); // append a string to a string
compare_e string_compare(string_t *left, string_t* right); // compare two strings
void string_print(string_t *this); // print a string
void string_println(string_t *this); // print a string with a \n
bool string_is_empty(string_t *this); // return true when s->content == ""
void string_cleanup(string_t *this); // memory cleanup
#endif