filters

pole.h

00001 /* POLE - Portable C++ library to access OLE Storage 
00002    Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
00003 
00004    Redistribution and use in source and binary forms, with or without 
00005    modification, are permitted provided that the following conditions 
00006    are met:
00007    * Redistributions of source code must retain the above copyright notice, 
00008      this list of conditions and the following disclaimer.
00009    * Redistributions in binary form must reproduce the above copyright notice, 
00010      this list of conditions and the following disclaimer in the documentation 
00011      and/or other materials provided with the distribution.
00012    * Neither the name of the authors nor the names of its contributors may be 
00013      used to endorse or promote products derived from this software without 
00014      specific prior written permission.
00015 
00016    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00017    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00018    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00019    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00020    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00021    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00022    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00023    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00024    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00025    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
00026    THE POSSIBILITY OF SUCH DAMAGE.
00027 */
00028 
00029 #ifndef POLE_H
00030 #define POLE_H
00031 
00032 #include <string>
00033 #include <list>
00034 
00035 namespace POLE
00036 {
00037 
00038 class StorageIO;
00039 class Stream;
00040 class StreamIO;
00041 
00042 class Storage
00043 {
00044   friend class Stream;
00045   friend class StreamOut;
00046 
00047 public:
00048 
00049   // for Storage::result()
00050   enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };
00051   
00055   Storage( const char* filename );
00056 
00060   ~Storage();
00061   
00065   bool open();
00066 
00070   void close();
00071   
00075   int result();
00076 
00080   std::list<std::string> entries( const std::string& path = "/" );
00081   
00085   bool isDirectory( const std::string& name ); 
00086 
00097   Stream* stream( const std::string& name, bool reuse = true );
00098   //Stream* stream( const std::string& name, int mode = Stream::ReadOnly, bool reuse = true );
00099   
00100 private:
00101   StorageIO* io;
00102   
00103   // no copy or assign
00104   Storage( const Storage& );
00105   Storage& operator=( const Storage& );
00106 
00107 };
00108 
00109 class Stream
00110 {
00111   friend class Storage;
00112   friend class StorageIO;
00113   
00114 public:
00115 
00119   // name must be absolute, e.g "/Workbook"
00120   Stream( Storage* storage, const std::string& name );
00121 
00125   ~Stream();
00126 
00130   std::string fullName(); 
00131   
00135   unsigned long size();
00136 
00140   unsigned long tell();
00141 
00145   void seek( unsigned long pos ); 
00146 
00150   int getch();
00151 
00155   unsigned long read( unsigned char* data, unsigned long maxlen );
00156   
00160   bool eof();
00161   
00165   bool fail();
00166 
00167 private:
00168   StreamIO* io;
00169 
00170   // no copy or assign
00171   Stream( const Stream& );
00172   Stream& operator=( const Stream& );    
00173 };
00174 
00175 }
00176 
00177 #endif // POLE_H
KDE Home | KDE Accessibility Home | Description of Access Keys