1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#pragma once
/* We define this to make sure that SteamPrivate does can not be included
* without this header.
*/
#define __H_STREAM__
#include "baseobject.h"
#include "defs.h"
#include "utils.h"
/**
* @defgroup SStream SStream
* @addtogroup SStream
* @{
* @warning unimplemented.
* @TODO
*/
S_BEGIN_DECLS
#define S_STREAM(o) ((SStream *)(o))
#define S_STREAM_CLASS(c) ((SStreamClass *)(c))
typedef struct SStream SStream;
typedef struct SStreamClass SStreamClass;
typedef struct SStreamPrivate SStreamPrivate;
typedef sbyte * (*StreamReader)(SStream * self, size_t len);
typedef void (*StreamWriter)(SStream * self, size_t len, sbyte * data);
struct SStream {
SObject parent;
SStreamPrivate * priv;
};
struct SStreamClass {
SObjectClass parent_class;
StreamReader reader;
StreamWriter writer;
};
/**
* Create a new stream.
*/
S_EXPORTED
SStream *
s_stream_new ();
/**
*
*/
S_EXPORTED
size_t
s_stream_get_beffered (SStream * self);
/**
* Read from the stream.
*
* Reading is thread safe as only one thread can preform a read or write at a
* time.
*
* @param self The Stream to read from.
* @param len The number of items to read.
*
* @returns An array with the bytes.
*
* @warning If the requested length is not available the rest will be
* zeroed out in the output.
*/
S_EXPORTED
sbyte *
s_stream_read (SStream * self,
size_t len);
/**
* Write data to a stream.
*
* Writing to the stream is thread safe as only one thread can perform a read
* or a write to a stream at a time.
*
* @param self The stream to write to.
* @param len The number of items to write to the stream.
* @param data The bytes to be put in the stream.
*/
S_EXPORTED
void
s_stream_write (SStream * self,
size_t len,
sbyte * data);
/**
* @}
*/
S_END_DECLS
|