koStoreDevice.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef koStoreDevice_h
00021 #define koStoreDevice_h
00022
00023 #include <koStore.h>
00024
00030 class KoStoreDevice : public QIODevice
00031 {
00032 public:
00034 KoStoreDevice( KoStore * store ) : m_store(store) {
00035 setType( IO_Direct );
00036 }
00037 ~KoStoreDevice() {}
00038
00039 bool open( int m ) {
00040 if ( m & IO_ReadOnly )
00041 return ( m_store->mode() == KoStore::Read );
00042 if ( m & IO_WriteOnly )
00043 return ( m_store->mode() == KoStore::Write );
00044 return false;
00045 }
00046 void close() { }
00047 void flush() { }
00048
00049 Offset size() const {
00050 if ( m_store->mode() == KoStore::Read )
00051 return m_store->size();
00052 else
00053 return 0xffffffff;
00054 }
00055
00056 virtual Q_LONG readBlock( char *data, Q_ULONG maxlen ) { return m_store->read(data, maxlen); }
00057 virtual Q_LONG writeBlock( const char *data, Q_ULONG len ) { return m_store->write( data, len ); }
00058
00059 Q_LONG writeBlock( const QByteArray& data ) { return QIODevice::writeBlock( data ); }
00060
00061 int getch() {
00062 char c[2];
00063 if ( m_store->read(c, 1) == -1)
00064 return -1;
00065 else
00066 return c[0];
00067 }
00068 int putch( int _c ) {
00069 char c[2];
00070 c[0] = _c;
00071 c[1] = 0;
00072 if (m_store->write( c, 1 ) == 1)
00073 return _c;
00074 else
00075 return -1;
00076 }
00077 int ungetch( int ) { return -1; }
00078
00079
00080 virtual bool at( Offset pos ) { return m_store->at(pos); }
00081 virtual Offset at() const { return m_store->at(); }
00082 virtual bool atEnd() const { return m_store->atEnd(); }
00083
00084 protected:
00085 KoStore * m_store;
00086 };
00087
00088 #endif
This file is part of the documentation for lib Library Version 1.4.2.