WPXOLEStream.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* POLE - Portable C++ library to access OLE Storage
00003    Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
00004 
00005    Redistribution and use in source and binary forms, with or without
00006    modification, are permitted provided that the following conditions
00007    are met:
00008    * Redistributions of source code must retain the above copyright notice,
00009      this list of conditions and the following disclaimer.
00010    * Redistributions in binary form must reproduce the above copyright notice,
00011      this list of conditions and the following disclaimer in the documentation
00012      and/or other materials provided with the distribution.
00013    * Neither the name of the authors nor the names of its contributors may be
00014      used to endorse or promote products derived from this software without
00015      specific prior written permission.
00016 
00017    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00027    THE POSSIBILITY OF SUCH DAMAGE.
00028 */
00029 
00030 #ifndef WPXOLESTREAM_H
00031 #define WPXOLESTREAM_H
00032 
00033 #include <string>
00034 #include <fstream>
00035 #include <vector>
00036 #include <list>
00037 
00038 class WPXInputStream;
00039 
00040 namespace libwpd
00041 {
00042 
00043 class IStorage;
00044 class Stream;
00045 class IStream;
00046 
00047 class Storage
00048 {
00049         friend class Stream;
00050 
00051 public:
00052 
00053         // for Storage::result()
00054         enum Result { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };
00055 
00059         Storage( WPXInputStream *is );
00060 
00064         ~Storage();
00065 
00069         bool isOLEStream();
00070 
00074         Result result();
00075 
00076 private:
00077         IStorage *m_io;
00078 
00079         // no copy or assign
00080         Storage( const Storage & );
00081         Storage &operator=( const Storage & );
00082 
00083 };
00084 
00085 class Stream
00086 {
00087         friend class Storage;
00088         friend class IStorage;
00089 
00090 public:
00091 
00095         Stream( Storage *storage, const std::string &name );
00096 
00100         ~Stream();
00101 
00105         unsigned long size();
00106 
00110         unsigned long read( unsigned char *data, unsigned long maxlen );
00111 
00112 private:
00113         IStream *m_io;
00114 
00115         // no copy or assign
00116         Stream( const Stream & );
00117         Stream &operator=( const Stream & );
00118 };
00119 
00120 }  // namespace libwpd
00121 
00122 #endif // WPXOLESTREAM_H
00123 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */