filters

kpresenter/powerpoint/libppt/pole.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 POLE_H
30#define POLE_H
31
32#include <string>
33#include <list>
34
35namespace POLE
36{
37
38class StorageIO;
39class Stream;
40class StreamIO;
41
42class Storage
43{
44 friend class Stream;
45 friend class StreamOut;
46
47public:
48
49 // for Storage::result()
50 enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };
51
55 Storage( const char* filename );
56
60 ~Storage();
61
65 bool open();
66
70 void close();
71
75 int result();
76
80 std::list<std::string> entries( const std::string& path = "/" );
81
85 bool isDirectory( const std::string& name );
86
97 Stream* stream( const std::string& name, bool reuse = true );
98 //Stream* stream( const std::string& name, int mode = Stream::ReadOnly, bool reuse = true );
99
100private:
101 StorageIO* io;
102
103 // no copy or assign
104 Storage( const Storage& );
105 Storage& operator=( const Storage& );
106
107};
108
109class Stream
110{
111 friend class Storage;
112 friend class StorageIO;
113
114public:
115
119 // name must be absolute, e.g "/Workbook"
120 Stream( Storage* storage, const std::string& name );
121
125 ~Stream();
126
130 std::string fullName();
131
135 unsigned long size();
136
140 unsigned long tell();
141
145 void seek( unsigned long pos );
146
150 int getch();
151
155 unsigned long read( unsigned char* data, unsigned long maxlen );
156
160 bool eof();
161
165 bool fail();
166
167private:
168 StreamIO* io;
169
170 // no copy or assign
171 Stream( const Stream& );
172 Stream& operator=( const Stream& );
173};
174
175}
176
177#endif // POLE_H