WPSOLEStream.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 WPSOLESTREAM_H
00031 #define WPSOLESTREAM_H
00032 
00033 #include <string>
00034 #include <fstream>
00035 #include <vector>
00036 
00037 #include <libwps_internal.h>
00038 
00039 class WPXInputStream;
00040 
00041 namespace libwps
00042 {
00043 
00044 class StorageIO;
00045 class Stream;
00046 class StreamIO;
00047 
00048 class Storage
00049 {
00050         friend class Stream;
00051 
00052 public:
00053 
00054         // for Storage::result()
00055         enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };
00056 
00060         Storage( shared_ptr<WPXInputStream> is );
00061 
00065         ~Storage();
00066 
00070         bool isOLEStream();
00071 
00075         int result();
00076 
00080         std::vector<std::string> getOLENames();
00081 
00085         shared_ptr<WPXInputStream> getDocumentOLEStream(const std::string &name);
00086 
00087 private:
00088         StorageIO *io;
00089 
00090         // no copy or assign
00091         Storage( const Storage & );
00092         Storage &operator=( const Storage & );
00093 
00094 };
00095 
00096 class Stream
00097 {
00098         friend class Storage;
00099         friend class StorageIO;
00100 
00101 public:
00102 
00106         Stream( Storage *storage, const std::string &name );
00107 
00111         ~Stream();
00112 
00116         unsigned long size();
00117 
00121         unsigned long read( unsigned char *data, unsigned long maxlen );
00122 
00123 private:
00124         StreamIO *io;
00125 
00126         // no copy or assign
00127         Stream( const Stream & );
00128         Stream &operator=( const Stream & );
00129 };
00130 
00131 }  // namespace libwps
00132 
00133 #endif // WPXOLESTREAM_H
00134 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */