summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CSource.h
authorpohly <pohly>2005-05-05 14:39:33 (UTC)
committer pohly <pohly>2005-05-05 14:39:33 (UTC)
commit39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (side-by-side diff)
tree96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/CSource.h
parent279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff)
downloadopie-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.h62
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 @@
+#ifndef __CSOURCE_H
+#define __CSOURCE_H
+
+class CInfo
+{
+ public:
+ virtual unsigned long size() = 0;
+};
+
+class CSource : public CInfo
+{
+ public:
+ virtual int get() = 0;
+};
+
+class CSink : public CInfo
+{
+ public:
+ virtual void put(unsigned char c) = 0;
+};
+
+class CMemSource : public CSource
+{
+ unsigned long m_total_size;
+ unsigned long m_current;
+ unsigned char* m_buffer;
+ public:
+ CMemSource(unsigned char* _buffer, unsigned long _size)
+ :
+ m_total_size(_size),
+ m_current(0),
+ m_buffer(_buffer)
+ {}
+ unsigned long size() { return m_current; }
+ int get()
+ {
+ return ((m_current < m_total_size) ? m_buffer[m_current++] : -1);
+ }
+};
+
+class CMemSink : public CSink
+{
+ unsigned long m_total_size;
+ unsigned long m_current;
+ unsigned char* m_buffer;
+ public:
+ CMemSink(unsigned char* _buffer, unsigned long _size)
+ :
+ m_total_size(_size),
+ m_current(0),
+ m_buffer(_buffer)
+ {}
+ unsigned long size() { return m_current; }
+ void put(unsigned char c)
+ {
+ if (m_current < m_total_size)
+ {
+ m_buffer[m_current++] = c;
+ }
+ }
+};
+#endif