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
00025
00026
00027
00028
00034 class KoStoreDevice : public QIODevice
00035 {
00036 public:
00037
00038 KoStoreDevice( KoStore * store ) : m_store(store) {
00039 setType( IO_Direct );
00040 }
00041 ~KoStoreDevice() {}
00042
00043 bool open( int m ) {
00044 if ( m & IO_ReadOnly )
00045 return ( m_store->mode() == KoStore::Read );
00046 if ( m & IO_WriteOnly )
00047 return ( m_store->mode() == KoStore::Write );
00048 return false;
00049 }
00050 void close() { }
00051 void flush() { }
00052
00053 Offset size() const {
00054 if ( m_store->mode() == KoStore::Read )
00055 return m_store->size();
00056 else
00057 return 0xffffffff;
00058 }
00059
00060 Q_LONG readBlock( char *data, Q_ULONG maxlen ) { return m_store->read(data, maxlen); }
00061 Q_LONG writeBlock( const char *data, Q_ULONG len ) { return m_store->write( data, len ); }
00062 Q_LONG readLine( char *, Q_ULONG ) { return -1; }
00063
00064 int getch() {
00065 char c[2];
00066 if ( m_store->read(c, 1) == -1)
00067 return -1;
00068 else
00069 return c[0];
00070 }
00071 int putch( int _c ) {
00072 char c[2];
00073 c[0] = _c;
00074 c[1] = 0;
00075 if (m_store->write( c, 1 ) == 1)
00076 return _c;
00077 else
00078 return -1;
00079 }
00080 int ungetch( int ) { return -1; }
00081
00082
00083 virtual bool at( Offset pos ) { return m_store->at(pos); }
00084 virtual Offset at() const { return m_store->at(); }
00085 virtual bool atEnd() const { return m_store->atEnd(); }
00086
00087 protected:
00088 KoStore * m_store;
00089 };
00090
00091 #endif
This file is part of the documentation for lib Library Version 1.3.5.