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 <sstream> 00036 #include <list> 00037 00038 namespace libwpd 00039 { 00040 00041 class StorageIO; 00042 class Stream; 00043 class StreamIO; 00044 00045 class Storage 00046 { 00047 friend class Stream; 00048 00049 public: 00050 00051 // for Storage::result() 00052 enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError }; 00053 00057 Storage( const std::stringstream &memorystream ); 00058 00062 ~Storage(); 00063 00067 bool isOLEStream(); 00068 00072 int result(); 00073 00074 private: 00075 StorageIO *io; 00076 00077 // no copy or assign 00078 Storage( const Storage & ); 00079 Storage &operator=( const Storage & ); 00080 00081 }; 00082 00083 class Stream 00084 { 00085 friend class Storage; 00086 friend class StorageIO; 00087 00088 public: 00089 00093 // name must be absolute, e.g "/PerfectOffice_MAIN" 00094 Stream( Storage *storage, const std::string &name ); 00095 00099 ~Stream(); 00100 00104 unsigned long size(); 00105 00109 unsigned long read( unsigned char *data, unsigned long maxlen ); 00110 00111 private: 00112 StreamIO *io; 00113 00114 // no copy or assign 00115 Stream( const Stream & ); 00116 Stream &operator=( const Stream & ); 00117 }; 00118 00119 } // namespace libwpd 00120 00121 #endif // WPXOLESTREAM_H 00122 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */