object: add a range of string transformation functions

This commit is contained in:
2025-07-17 17:55:13 +01:00
parent 5dc6f4088b
commit 4690738af1
3 changed files with 110 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
#include <blue/core/status.h>
#include <blue/object/object.h>
#include <blue/object/type.h>
#include <ctype.h>
struct b_stream;
@@ -34,7 +35,19 @@ static inline void b_string_release(b_string *str)
}
BLUE_API char *b_string_steal(b_string *str);
BLUE_API b_status b_string_reserve(b_string *str, size_t capacity);
BLUE_API b_status b_string_replace(
b_string *str, size_t start, size_t length, const char *new_data);
BLUE_API b_status b_string_replace_all(b_string *str, const char *new_data);
BLUE_API b_status b_string_remove(b_string *str, size_t start, size_t length);
BLUE_API b_status b_string_transform(b_string *str, int (*transformer)(int));
static inline b_status b_string_toupper(b_string *str)
{
return b_string_transform(str, toupper);
}
static inline b_status b_string_tolower(b_string *str)
{
return b_string_transform(str, tolower);
}
BLUE_API b_status b_string_open_stream(b_string *str, struct b_stream **out);
BLUE_API void b_string_append_s(b_string *dest, const b_string *src);