45#define string_from_literal(StringLiteral) \
46 string_from(StringLiteral, strlen(StringLiteral))
63#define String __attribute__((cleanup(string_clear))) string_t
71__attribute__((format(printf, 2, 3)))
72bool string_append_format(
string_t* self, const
char* format, ...);
81#define string_append_literal(Self, StringLiteral) \
82 string_append_cstring(Self, StringLiteral, strlen(StringLiteral))
126#define string_foreach(STRING, Element) array_foreach (char, STRING, Element)
129#define string_enumerate(STRING, Element, Index) \
130 array_enumerate (char, STRING, Element, Index)
Dynamic string implementation.
bool string_pop_n(string_t *self, char *destination, size_t count)
Pop the count last characters.
bool string_trim(string_t *self)
Resize the underlying storage, for it not to take any more room that needed.
size_t string_length(const string_t *self)
Number of characters in the string.
void string_apply_inplace(string_t *self, char(*function)(char))
Replace each character by its image through the provided function.
char * string_to_cstring(string_t *self)
Provide compatibility with legacy string functions.
bool string_pop_front(string_t *self, char *destination)
Pop the first character.
char * string_end(const string_t *self)
One-past-the-last pointer.
bool string_contains(const string_t *self, char character)
Searches character in self.
string_t string_tolower(const string_t *self)
Creates a copy of the string, with all alphabetic characters to lower-case.
string_t string_new(void)
Constructs an empty string.
uint32_t string_fnv1a_32(const string_t *self)
Fowler–Noll–Vo hash function, on 32 bits.
string_t string_from(const char *cstring, size_t length)
Construct a string with an initial value.
void string_toupper_inplace(string_t *self)
Replace each alphabetic character by its upper case equivalent.
bool string_is_empty(const string_t *self)
True if the string has a length of zero.
string_t string_pop_as_string(string_t *self, size_t count)
Create a string from the count last characters.
bool string_reserve(string_t *self, size_t count)
Ensure the underlying storage can accomodate count more characters.
array_t string_t
A string is an array of char.
bool string_pop(string_t *self, char *destination)
Pop the last character.
string_t string_toupper(const string_t *self)
Creates a copy of the string, with all alphabetic characters to upper-case.
bool string_is_equal(const string_t *self, const string_t *other)
Compares the content of the 2 strings.
bool string_append_cstring(string_t *self, const char *cstring, size_t length)
Add a raw character string to the back of the string.
uint32_t cstring_fnv1a_32(const char *cstring, size_t length)
Fowler–Noll–Vo hash function, on 32 bits.
bool string_pop_front_n(string_t *self, char *destination, size_t count)
Pop the first count characters.
bool string_append_char(string_t *self, char character)
Add a single character to the back of the string.
bool is_char_in_cstring(char character, const char *cstring)
Searches character in cstring.
bool string_append(string_t *self, const string_t *other)
Concatenate two strings.
void string_clear(string_t *self)
Release allocated resources to the system.
void string_tolower_inplace(string_t *self)
Replace each alphabetic character by its lower case equivalent.
string_t string_map(const string_t *self, char(*function)(char))
Creates a copy of the string, where each character is the image through the provided function.
char * string_get(const string_t *self, size_t index)
The address of the character at the requested index.
O2S array implementation.