InStream/OutStream
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef INCLUDED_C_OUTSTREAM_H
|
||||
#define INCLUDED_C_OUTSTREAM_H
|
||||
|
||||
#ifndef INCLUDED_C_TYPES_H
|
||||
#include <c_Types.h>
|
||||
#endif /*INCLUDED_C_TYPES_H*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
typedef struct c_OutStream_t c_OutStream_t;
|
||||
|
||||
typedef struct {
|
||||
c_err_t (*write)(c_OutStream_t* self, const void* buffer, c_size_t bytes_to_write, c_size_t* out_bytes_written);
|
||||
c_err_t (*flush)(c_OutStream_t* self);
|
||||
void (*destroy)(c_OutStream_t* self);
|
||||
} c_OutStreamVtbl_t;
|
||||
|
||||
struct c_OutStream_t {
|
||||
const c_OutStreamVtbl_t* vtbl; /* Object vtable tracker handle link */
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
/* Base Public Routing Virtual Methods */
|
||||
C_STATIC_FORCE_INLINE c_err_t c_OutStream_Write(c_OutStream_t* self, const void* buffer, c_size_t bytes_to_write, c_size_t* out_bytes_written) {
|
||||
if (!self || !self->vtbl || !self->vtbl->write) return C_ERR_PARAM;
|
||||
return self->vtbl->write(self, buffer, bytes_to_write, out_bytes_written);
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE c_err_t c_OutStream_Flush(c_OutStream_t* self) {
|
||||
if (!self || !self->vtbl || !self->vtbl->flush) return C_ERR_PARAM;
|
||||
return self->vtbl->flush(self);
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE void c_OutStream_Destroy(c_OutStream_t* self) {
|
||||
if (!self || !self->vtbl || !self->vtbl->destroy) return;
|
||||
self->vtbl->destroy(self);
|
||||
}
|
||||
|
||||
|
||||
#endif /*INCLUDED_C_OUTSTREAM_H*/
|
||||
Reference in New Issue
Block a user