Code

Cleaned up virtual destructor problem and compile warnings.
[inkscape.git] / src / extension / internal / libwpg / WPGOLEStream.h
1 /* POLE - Portable C++ library to access OLE Storage 
2    Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
3 \r
4    Redistribution and use in source and binary forms, with or without \r
5    modification, are permitted provided that the following conditions \r
6    are met:\r
7    * Redistributions of source code must retain the above copyright notice, \r
8      this list of conditions and the following disclaimer.\r
9    * Redistributions in binary form must reproduce the above copyright notice, \r
10      this list of conditions and the following disclaimer in the documentation \r
11      and/or other materials provided with the distribution.\r
12    * Neither the name of the authors nor the names of its contributors may be \r
13      used to endorse or promote products derived from this software without \r
14      specific prior written permission.\r
15 \r
16    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" \r
17    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r
18    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE \r
19    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \r
20    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \r
21    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \r
22    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \r
23    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN \r
24    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \r
25    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF \r
26    THE POSSIBILITY OF SUCH DAMAGE.
27 */
29 #ifndef WPGOLESTREAM_H
30 #define WPGOLESTREAM_H
32 #include <string>
33 #include <fstream>
34 #include <sstream>
35 #include <list>
37 namespace libwpg
38 {
40 class StorageIO;
41 class Stream;
42 class StreamIO;
44 class Storage
45 {
46   friend class Stream;
48 public:
49 \r
50   // for Storage::result()
51   enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };\r
52   \r
53   /**
54    * Constructs a storage with data.
55    **/
56   Storage( const std::stringstream &memorystream );
58   /**
59    * Destroys the storage.
60    **/
61   ~Storage();
62   
63   /**
64    * Checks whether the storage is OLE2 storage.
65    **/
66   bool isOle();
68   /**
69    * Returns the error code of last operation.
70    **/
71   int result();
72   
73 private:
74   StorageIO* io;
75   
76   // no copy or assign
77   Storage( const Storage& );
78   Storage& operator=( const Storage& );
80 };
82 class Stream
83 {
84   friend class Storage;
85   friend class StorageIO;
86   
87 public:\r
88 \r
89   /**\r
90    * Creates a new stream.\r
91    */\r
92   // name must be absolute, e.g "/PerfectOffice_MAIN"\r
93   Stream( Storage* storage, const std::string& name );\r
94 \r
95   /**\r
96    * Destroys the stream.\r
97    */\r
98   ~Stream();
99 \r
100   /**
101    * Returns the stream size.
102    **/
103   unsigned long size();
105   /**
106    * Reads a block of data.
107    **/
108   unsigned long read( unsigned char* data, unsigned long maxlen );\r
109   \r
110 private:
111   StreamIO* io;
112 \r
113   // no copy or assign
114   Stream( const Stream& );
115   Stream& operator=( const Stream& );    
116 };
118 }  // namespace libwpg
120 #endif // WPGOLESTREAM_H