serial: convert b_serial_ctx to a b_object interface
This commit is contained in:
@@ -1,34 +1,8 @@
|
||||
#ifndef BLUE_SERIAL_H_
|
||||
#define BLUE_SERIAL_H_
|
||||
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/object.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <blue/core/stream.h>
|
||||
|
||||
typedef enum b_serial_format {
|
||||
B_SERIAL_FORMAT_NONE = 0,
|
||||
B_SERIAL_FORMAT_BITCODE,
|
||||
B_SERIAL_FORMAT_JSON,
|
||||
B_SERIAL_FORMAT_TOML,
|
||||
} b_serial_format;
|
||||
|
||||
typedef enum b_serial_flags {
|
||||
B_SERIAL_F_NONE = 0,
|
||||
B_SERIAL_F_PRETTY = 0x01u,
|
||||
} b_serial_flags;
|
||||
|
||||
typedef struct b_serial_ctx b_serial_ctx;
|
||||
|
||||
BLUE_API b_status b_serial_ctx_create(b_serial_ctx **out);
|
||||
BLUE_API b_status b_serial_ctx_destroy(b_serial_ctx *ctx);
|
||||
|
||||
BLUE_API b_status b_serial_ctx_serialise(
|
||||
b_serial_ctx *ctx, b_serial_format fmt, b_object *src, b_stream *dest,
|
||||
b_serial_flags flags);
|
||||
|
||||
BLUE_API b_status b_serial_ctx_deserialise(
|
||||
b_serial_ctx *ctx, b_serial_format fmt, b_stream *src, b_object **dest,
|
||||
b_serial_flags flags);
|
||||
#include <blue/serial/bitcode.h>
|
||||
#include <blue/serial/ctx.h>
|
||||
#include <blue/serial/toml.h>
|
||||
|
||||
#endif
|
||||
|
||||
21
serial/include/blue/serial/bitcode.h
Normal file
21
serial/include/blue/serial/bitcode.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef BLUE_SERIAL_BITCODE_H_
|
||||
#define BLUE_SERIAL_BITCODE_H_
|
||||
|
||||
#include <blue/core/macros.h>
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_BITCODE_SERIAL_CTX (b_bitcode_serial_ctx_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_bitcode_serial_ctx);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_bitcode_serial_ctx)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_bitcode_serial_ctx)
|
||||
|
||||
BLUE_API b_type b_bitcode_serial_ctx_get_type(void);
|
||||
|
||||
B_TYPE_DEFAULT_CONSTRUCTOR(b_bitcode_serial_ctx, B_TYPE_BITCODE_SERIAL_CTX);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
42
serial/include/blue/serial/ctx.h
Normal file
42
serial/include/blue/serial/ctx.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef BLUE_SERIAL_CTX_H_
|
||||
#define BLUE_SERIAL_CTX_H_
|
||||
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/object.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <blue/core/stream.h>
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_SERIAL_CTX (b_serial_ctx_get_type())
|
||||
|
||||
typedef enum b_serial_flags {
|
||||
B_SERIAL_F_NONE = 0,
|
||||
B_SERIAL_F_PRETTY = 0x01u,
|
||||
} b_serial_flags;
|
||||
|
||||
B_DECLARE_TYPE(b_serial_ctx);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_serial_ctx)
|
||||
b_status (*s_serialise)(
|
||||
b_serial_ctx *, b_object *, b_stream *, b_serial_flags);
|
||||
b_status (*s_deserialise)(
|
||||
b_serial_ctx *, b_stream *, b_object **, b_serial_flags);
|
||||
B_TYPE_CLASS_DECLARATION_END(b_serial_ctx)
|
||||
|
||||
typedef struct b_serial_ctx_data {
|
||||
b_stream_buffer *ctx_streambuf;
|
||||
} b_serial_ctx_data;
|
||||
|
||||
BLUE_API b_type b_serial_ctx_get_type(void);
|
||||
|
||||
BLUE_API b_status b_serial_ctx_serialise(
|
||||
b_serial_ctx *ctx, b_object *src, b_stream *dest, b_serial_flags flags);
|
||||
|
||||
BLUE_API b_status b_serial_ctx_deserialise(
|
||||
b_serial_ctx *ctx, b_stream *src, b_object **dest, b_serial_flags flags);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
21
serial/include/blue/serial/toml.h
Normal file
21
serial/include/blue/serial/toml.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef BLUE_SERIAL_TOML_H_
|
||||
#define BLUE_SERIAL_TOML_H_
|
||||
|
||||
#include <blue/core/macros.h>
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_TOML_SERIAL_CTX (b_toml_serial_ctx_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_toml_serial_ctx);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_toml_serial_ctx)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_toml_serial_ctx)
|
||||
|
||||
BLUE_API b_type b_toml_serial_ctx_get_type(void);
|
||||
|
||||
B_TYPE_DEFAULT_CONSTRUCTOR(b_toml_serial_ctx, B_TYPE_TOML_SERIAL_CTX);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user