filters

pole.h

00001 /* POLE - Portable library to access OLE Storage 
00002    Copyright (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008    
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA
00018 */
00019 
00020 #ifndef POLE_H
00021 #define POLE_H
00022 
00023 #include <string>
00024 #include <list>
00025 
00026 namespace POLE
00027 {
00028 
00029 class StorageIO;
00030 class Stream;
00031 
00032 class Storage
00033 {
00034 
00035 public:
00036 
00037   enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError, 
00038     StupidWorkaroundForBrokenCompiler=255 };
00039 
00040   enum { ReadOnly, WriteOnly, ReadWrite };
00041 
00042   Storage();
00043 
00044   ~Storage();
00045 
00051   bool open( const char* filename, int m = ReadOnly );
00052 
00056   void flush();
00057 
00064   void close();
00065 
00066   std::list<std::string> listDirectory();
00067 
00068   bool enterDirectory( const std::string& directory );
00069 
00070   void leaveDirectory();
00071 
00072   std::string path();
00073 
00081   Stream* stream( const std::string& name );
00082 
00083   int result;
00084 
00085 protected:
00086 
00087   StorageIO* io;
00088 
00089 private:
00090 
00091   // no copy or assign
00092   Storage( const Storage& );
00093   Storage& operator=( const Storage& );
00094 
00095 };
00096 
00097 class StreamIO;
00098 
00099 class Stream
00100 {
00101   public:
00102 
00103     Stream( StreamIO* io );
00104 
00105     ~Stream();
00106 
00107     unsigned long size();
00108 
00109     unsigned long tell();
00110 
00111     void seek( unsigned long pos ); 
00112 
00113     int getch();
00114 
00115     unsigned long read( unsigned char* data, unsigned long maxlen );
00116 
00117   private:
00118 
00119     StreamIO* io;
00120 
00121     // no copy or assign
00122     Stream( const Stream& );
00123     Stream& operator=( const Stream& );
00124 };
00125 
00126 
00127 }
00128 
00129 #endif // POLE_H
KDE Home | KDE Accessibility Home | Description of Access Keys