ds: string: convert to new object system

This commit is contained in:
2025-10-19 11:02:36 +01:00
parent 3ee9de74f0
commit 3eebdddc21
3 changed files with 514 additions and 381 deletions

View File

@@ -1,16 +1,23 @@
#ifndef BLUELIB_STRING_H_
#define BLUELIB_STRING_H_
#ifndef BLUE_DS_STRING_H_
#define BLUE_DS_STRING_H_
#include <blue/core/encoding.h>
#include <blue/core/iterator.h>
#include <blue/core/macros.h>
#include <blue/core/status.h>
#include <blue/ds/object.h>
#include <blue/ds/type.h>
#include <ctype.h>
struct b_stream;
B_DECLS_BEGIN;
#define B_STRING(p) ((b_string *)(p))
struct b_stream;
struct b_string_p;
#define B_TYPE_STRING (b_string_get_type())
B_DECLARE_TYPE(b_string);
B_TYPE_CLASS_DECLARATION_BEGIN(b_string)
B_TYPE_CLASS_DECLARATION_END(b_string)
#define B_CSTR(s) (b_string_create_from_cstr(s))
#define B_RV_CSTR(s) (B_RV(b_string_create_from_cstr(s)))
@@ -19,12 +26,12 @@ struct b_stream;
for (int z__b_unique_name() = b_string_iterator_begin(str, it); \
b_string_iterator_is_valid(it); b_string_iterator_next(it))
typedef struct b_string b_string;
typedef struct b_string_iterator {
b_iterator _base;
int _m, _f;
b_string *_s, *_tmp;
b_string *_tmp;
struct b_string_p *_s_p, *_tmp_p;
const char **_d;
size_t _nd, _ds;
@@ -50,20 +57,14 @@ typedef enum b_string_tokenise_flags {
B_STRING_TOK_F_INCLUDE_EMPTY_TOKENS = 0x01u,
} b_string_tokenise_flags;
BLUE_API b_string *b_string_create(void);
BLUE_API b_type b_string_get_type(void);
B_TYPE_DEFAULT_CONSTRUCTOR(b_string, B_TYPE_STRING);
BLUE_API b_string *b_string_create_from_cstr(const char *s);
BLUE_API b_string *b_string_create_from_wstr(const b_wchar *s);
BLUE_API b_string *b_string_create_from_c(char c, size_t count);
BLUE_API b_string *b_string_duplicate(const b_string *str);
static inline b_string *b_string_retain(b_string *str)
{
return B_STRING(b_retain(B_DSREF(str)));
}
static inline void b_string_release(b_string *str)
{
b_release(B_DSREF(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(
@@ -138,4 +139,6 @@ BLUE_API size_t b_wstrlen(const b_wchar *s);
BLUE_API uint64_t b_string_hash(const b_string *s);
B_DECLS_END;
#endif