Scribus
Open source desktop publishing at your fingertips
WPGOLEStream.h
1 /* POLE - Portable C++ library to access OLE Storage
2  Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
3 
4  Redistribution and use in source and binary forms, with or without
5  modification, are permitted provided that the following conditions
6  are met:
7  * Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice,
10  this list of conditions and the following disclaimer in the documentation
11  and/or other materials provided with the distribution.
12  * Neither the name of the authors nor the names of its contributors may be
13  used to endorse or promote products derived from this software without
14  specific prior written permission.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef WPGOLESTREAM_H
30 #define WPGOLESTREAM_H
31 
32 #include <string>
33 #include <fstream>
34 #include <sstream>
35 #include <list>
36 
37 namespace libwpg
38 {
39 
40 class StorageIO;
41 class Stream;
42 class StreamIO;
43 
44 class Storage
45 {
46  friend class Stream;
47 
48 public:
49 
50  // for Storage::result()
51  enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };
52 
56  Storage( const std::stringstream &memorystream );
57 
61  ~Storage();
62 
66  bool isOLEStream();
67 
71  int result();
72 
73 private:
74  StorageIO* io;
75 
76  // no copy or assign
77  Storage( const Storage& );
78  Storage& operator=( const Storage& );
79 
80 };
81 
82 class Stream
83 {
84  friend class Storage;
85  friend class StorageIO;
86 
87 public:
88 
92  // name must be absolute, e.g "/PerfectOffice_MAIN"
93  Stream( Storage* storage, const std::string& name );
94 
98  ~Stream();
99 
103  unsigned long size();
104 
108  unsigned long read( unsigned char* data, unsigned long maxlen );
109 
110 private:
111  StreamIO* io;
112 
113  // no copy or assign
114  Stream( const Stream& );
115  Stream& operator=( const Stream& );
116 };
117 
118 } // namespace libwpg
119 
120 #endif // WPGOLESTREAM_H
Storage(const std::stringstream &memorystream)
Definition: WPGOLEStream.cpp:970
bool isOLEStream()
Definition: WPGOLEStream.cpp:986
Definition: WPGOLEStream.h:44
Definition: WPGOLEStream.cpp:129
Stream(Storage *storage, const std::string &name)
Definition: WPGOLEStream.cpp:993
Definition: WPGOLEStream.h:82
unsigned long read(unsigned char *data, unsigned long maxlen)
Definition: WPGOLEStream.cpp:1009
Definition: WPGOLEStream.cpp:169
~Stream()
Definition: WPGOLEStream.cpp:999
int result()
Definition: WPGOLEStream.cpp:981
unsigned long size()
Definition: WPGOLEStream.cpp:1004
~Storage()
Definition: WPGOLEStream.cpp:976
Definition: WPGBinaryData.h:34