filters

kword/starwriter/pole.h
1/* POLE - Portable library to access OLE Storage
2 Copyright (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA
18*/
19
20#ifndef POLE_H
21#define POLE_H
22
23#include <string>
24#include <list>
25
26namespace POLE
27{
28
29class StorageIO;
30class Stream;
31
32class Storage
33{
34
35public:
36
37 enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError,
38 StupidWorkaroundForBrokenCompiler=255 };
39
40 enum { ReadOnly, WriteOnly, ReadWrite };
41
42 Storage();
43
44 ~Storage();
45
51 bool open( const char* filename, int m = ReadOnly );
52
56 void flush();
57
64 void close();
65
66 std::list<std::string> listDirectory();
67
68 bool enterDirectory( const std::string& directory );
69
70 void leaveDirectory();
71
72 std::string path();
73
81 Stream* stream( const std::string& name );
82
83 int result;
84
85protected:
86
87 StorageIO* io;
88
89private:
90
91 // no copy or assign
92 Storage( const Storage& );
93 Storage& operator=( const Storage& );
94
95};
96
97class StreamIO;
98
99class Stream
100{
101 public:
102
103 Stream( StreamIO* io );
104
105 ~Stream();
106
107 unsigned long size();
108
109 unsigned long tell();
110
111 void seek( unsigned long pos );
112
113 int getch();
114
115 unsigned long read( unsigned char* data, unsigned long maxlen );
116
117 private:
118
119 StreamIO* io;
120
121 // no copy or assign
122 Stream( const Stream& );
123 Stream& operator=( const Stream& );
124};
125
126
127}
128
129#endif // POLE_H