~ubuntu-branches/ubuntu/saucy/libwpd/saucy

« back to all changes in this revision

Viewing changes to src/lib/WPXOLEStream.h

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2011-11-29 23:31:13 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20111129233113-xdtwca9h0y6wdxst
Tags: 0.9.4-1
New upstream release

Show diffs side-by-side

added added

removed removed

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