author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (unidiff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/CSource.h | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (limited to 'noncore/apps/opie-reader/CSource.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CSource.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/CSource.h b/noncore/apps/opie-reader/CSource.h new file mode 100644 index 0000000..2885f72 --- a/dev/null +++ b/noncore/apps/opie-reader/CSource.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef __CSOURCE_H | ||
2 | #define __CSOURCE_H | ||
3 | |||
4 | class CInfo | ||
5 | { | ||
6 | public: | ||
7 | virtual unsigned long size() = 0; | ||
8 | }; | ||
9 | |||
10 | class CSource : public CInfo | ||
11 | { | ||
12 | public: | ||
13 | virtual int get() = 0; | ||
14 | }; | ||
15 | |||
16 | class CSink : public CInfo | ||
17 | { | ||
18 | public: | ||
19 | virtual void put(unsigned char c) = 0; | ||
20 | }; | ||
21 | |||
22 | class CMemSource : public CSource | ||
23 | { | ||
24 | unsigned long m_total_size; | ||
25 | unsigned long m_current; | ||
26 | unsigned char* m_buffer; | ||
27 | public: | ||
28 | CMemSource(unsigned char* _buffer, unsigned long _size) | ||
29 | : | ||
30 | m_total_size(_size), | ||
31 | m_current(0), | ||
32 | m_buffer(_buffer) | ||
33 | {} | ||
34 | unsigned long size() { return m_current; } | ||
35 | int get() | ||
36 | { | ||
37 | return ((m_current < m_total_size) ? m_buffer[m_current++] : -1); | ||
38 | } | ||
39 | }; | ||
40 | |||
41 | class CMemSink : public CSink | ||
42 | { | ||
43 | unsigned long m_total_size; | ||
44 | unsigned long m_current; | ||
45 | unsigned char* m_buffer; | ||
46 | public: | ||
47 | CMemSink(unsigned char* _buffer, unsigned long _size) | ||
48 | : | ||
49 | m_total_size(_size), | ||
50 | m_current(0), | ||
51 | m_buffer(_buffer) | ||
52 | {} | ||
53 | unsigned long size() { return m_current; } | ||
54 | void put(unsigned char c) | ||
55 | { | ||
56 | if (m_current < m_total_size) | ||
57 | { | ||
58 | m_buffer[m_current++] = c; | ||
59 | } | ||
60 | } | ||
61 | }; | ||
62 | #endif | ||