1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 * (C) 1999 Mizi Research, All rights are reserved
25 #ifndef INCLUDED_HWPFILTER_SOURCE_HIODEV_H
26 #define INCLUDED_HWPFILTER_SOURCE_HIODEV_H
28 #include <sal/config.h>
32 #include <boost/scoped_ptr.hpp>
33 #include <sal/types.h>
37 * @short Abstract IO class
39 class DLLEXPORT HIODev
48 virtual bool open() = 0;
49 virtual void close() = 0;
50 virtual void flush() = 0;
51 virtual int state() const = 0;
52 /* gzip routine wrapper */
53 virtual bool setCompressed( bool ) = 0;
55 virtual bool read1b(unsigned char &out
) = 0;
56 virtual bool read1b(char &out
) = 0;
57 virtual bool read2b(unsigned short &out
) = 0;
58 virtual bool read4b(unsigned int &out
) = 0;
59 virtual bool read4b(int &out
) = 0;
60 virtual int readBlock( void *ptr
, int size
) = 0;
61 virtual int skipBlock( int size
) = 0;
63 int read1b( void *ptr
, int nmemb
);
64 int read2b( void *ptr
, int nmemb
);
65 int read4b( void *ptr
, int nmemb
);
73 * This controls the HStream given by constructor
74 * @short Stream IO device
76 class HStreamIODev
: public HIODev
79 /* zlib으로 압축을 풀기 위한 자료 구조 */
80 boost::scoped_ptr
<HStream
> _stream
;
83 HStreamIODev(HStream
* stream
);
84 virtual ~HStreamIODev();
86 * Check whether the stream is available
88 virtual bool open() SAL_OVERRIDE
;
92 virtual void close() SAL_OVERRIDE
;
94 * If the stream is gzipped, flush the stream.
96 virtual void flush() SAL_OVERRIDE
;
100 virtual int state() const SAL_OVERRIDE
;
102 * Set whether the stream is compressed or not
104 virtual bool setCompressed( bool ) SAL_OVERRIDE
;
106 * Read one byte from stream
108 using HIODev::read1b
;
109 virtual bool read1b(unsigned char &out
) SAL_OVERRIDE
;
110 virtual bool read1b(char &out
) SAL_OVERRIDE
;
112 * Read 2 bytes from stream
114 using HIODev::read2b
;
115 virtual bool read2b(unsigned short &out
) SAL_OVERRIDE
;
117 * Read 4 bytes from stream
119 using HIODev::read4b
;
120 virtual bool read4b(unsigned int &out
) SAL_OVERRIDE
;
121 virtual bool read4b(int &out
) SAL_OVERRIDE
;
123 * Read some bytes from stream to given pointer as amount of size
125 virtual int readBlock( void *ptr
, int size
) SAL_OVERRIDE
;
127 * Move current pointer of stream as amount of size
129 virtual int skipBlock( int size
) SAL_OVERRIDE
;
132 * Initialize this object
134 virtual void init() SAL_OVERRIDE
;
139 * The HMemIODev class controls the Input/Output device.
140 * @short Memory IO device
142 class HMemIODev
: public HIODev
147 HMemIODev(char *s
, int len
);
148 virtual ~HMemIODev();
150 virtual bool open() SAL_OVERRIDE
;
151 virtual void close() SAL_OVERRIDE
;
152 virtual void flush() SAL_OVERRIDE
;
153 virtual int state() const SAL_OVERRIDE
;
154 /* gzip routine wrapper */
155 virtual bool setCompressed( bool ) SAL_OVERRIDE
;
156 using HIODev::read1b
;
157 virtual bool read1b(unsigned char &out
) SAL_OVERRIDE
;
158 virtual bool read1b(char &out
) SAL_OVERRIDE
;
159 using HIODev::read2b
;
160 virtual bool read2b(unsigned short &out
) SAL_OVERRIDE
;
161 using HIODev::read4b
;
162 virtual bool read4b(unsigned int &out
) SAL_OVERRIDE
;
163 virtual bool read4b(int &out
) SAL_OVERRIDE
;
164 virtual int readBlock( void *ptr
, int size
) SAL_OVERRIDE
;
165 virtual int skipBlock( int size
) SAL_OVERRIDE
;
167 virtual void init() SAL_OVERRIDE
;
169 #endif // INCLUDED_HWPFILTER_SOURCE_HIODEV_H
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */