core: stringstream: convert to a b_object type inheriting from b_stream

This commit is contained in:
2025-10-24 12:32:54 +01:00
parent fd4f60e37f
commit a5762e537b
2 changed files with 208 additions and 191 deletions

View File

@@ -1,27 +1,36 @@
#ifndef BLUELIB_CORE_STRINGSTREAM_H_
#define BLUELIB_CORE_STRINGSTREAM_H_
#ifndef BLUE_CORE_STRINGSTREAM_H_
#define BLUE_CORE_STRINGSTREAM_H_
#include <blue/core/macros.h>
#include <blue/core/misc.h>
#include <blue/core/status.h>
#include <blue/core/stream.h>
#include <stddef.h>
typedef struct b_stringstream {
b_stream ss_base;
char *ss_buf;
size_t ss_len;
size_t ss_max;
unsigned char ss_alloc;
int *ss_istack;
int ss_add_indent;
size_t ss_istack_ptr, ss_istack_size;
} b_stringstream;
B_DECLS_BEGIN;
BLUE_API void b_stringstream_begin(b_stringstream *strv, char *buf, size_t max);
BLUE_API void b_stringstream_begin_dynamic(b_stringstream *strv);
#define B_TYPE_STRINGSTREAM (b_stringstream_get_type())
B_DECLARE_TYPE(b_stringstream);
B_TYPE_CLASS_DECLARATION_BEGIN(b_stringstream)
B_TYPE_CLASS_DECLARATION_END(b_stringstream)
BLUE_API b_type b_stringstream_get_type(void);
BLUE_API b_stringstream *b_stringstream_create(void);
BLUE_API b_stringstream *b_stringstream_create_with_buffer(char *buf, size_t max);
BLUE_API b_status b_stringstream_reset(b_stringstream *strv);
BLUE_API b_status b_stringstream_reset_with_buffer(
b_stringstream *strv, char *buf, size_t max);
BLUE_API const char *b_stringstream_ptr(const b_stringstream *strv);
BLUE_API char *b_stringstream_steal(b_stringstream *strv);
BLUE_API size_t b_stringstream_get_length(const b_stringstream *strv);
#if 0
BLUE_API void b_stringstream_push_indent(b_stringstream *strv, int indent);
BLUE_API void b_stringstream_pop_indent(b_stringstream *strv);
@@ -33,6 +42,8 @@ BLUE_API b_status b_stringstream_addvf(
BLUE_API b_status b_stringstream_addvl(
b_stringstream *strv, const char **strs, size_t count);
BLUE_API b_status b_stringstream_add_many(b_stringstream *strv, ...);
BLUE_API char *b_stringstream_end(b_stringstream *strv);
#endif
B_DECLS_END;
#endif