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>
33 #include <sal/types.h>
37 * @short Abstract IO class
39 class DLLEXPORT HIODev
48 virtual bool open() = 0;
49 virtual void flush() = 0;
50 virtual bool state() const = 0;
51 /* gzip routine wrapper */
52 virtual bool setCompressed( bool ) = 0;
54 virtual bool read1b(unsigned char &out
) = 0;
55 virtual bool read1b(char &out
) = 0;
56 virtual bool read2b(unsigned short &out
) = 0;
57 virtual bool read4b(unsigned int &out
) = 0;
58 virtual bool read4b(int &out
) = 0;
59 virtual size_t readBlock( void *ptr
, size_t size
) = 0;
60 virtual size_t skipBlock( size_t size
) = 0;
62 size_t read2b( void *ptr
, size_t nmemb
);
63 size_t read4b( void *ptr
, size_t nmemb
);
68 /* File input and output devices */
71 * This controls the HStream given by constructor
72 * @short Stream IO device
74 class HStreamIODev final
: public HIODev
77 /* zlib으로 압축을 풀기 위한 자료 구조 */
78 std::unique_ptr
<HStream
> _stream
;
81 explicit HStreamIODev(std::unique_ptr
<HStream
> stream
);
82 virtual ~HStreamIODev() override
;
84 * Check whether the stream is available
86 virtual bool open() override
;
88 * If the stream is gzipped, flush the stream.
90 virtual void flush() override
;
94 virtual bool state() const override
;
96 * Set whether the stream is compressed or not
98 virtual bool setCompressed( bool ) override
;
100 * Read one byte from stream
102 virtual bool read1b(unsigned char &out
) override
;
103 virtual bool read1b(char &out
) override
;
105 * Read 2 bytes from stream
107 using HIODev::read2b
;
108 virtual bool read2b(unsigned short &out
) override
;
110 * Read 4 bytes from stream
112 using HIODev::read4b
;
113 virtual bool read4b(unsigned int &out
) override
;
114 virtual bool read4b(int &out
) override
;
116 * Read some bytes from stream to given pointer as amount of size
118 virtual size_t readBlock( void *ptr
, size_t size
) override
;
120 * Move current pointer of stream as amount of size
122 virtual size_t skipBlock( size_t size
) override
;
125 * Initialize this object
127 virtual void init() override
;
130 /* Memory, input and output devices */
132 * The HMemIODev class controls the Input/Output device.
133 * @short Memory IO device
135 class HMemIODev final
: public HIODev
140 HMemIODev(char *s
, size_t len
);
141 virtual ~HMemIODev() override
;
143 virtual bool open() override
;
144 virtual void flush() override
;
145 virtual bool state() const override
;
146 /* gzip routine wrapper */
147 virtual bool setCompressed( bool ) override
;
148 virtual bool read1b(unsigned char &out
) override
;
149 virtual bool read1b(char &out
) override
;
150 using HIODev::read2b
;
151 virtual bool read2b(unsigned short &out
) override
;
152 using HIODev::read4b
;
153 virtual bool read4b(unsigned int &out
) override
;
154 virtual bool read4b(int &out
) override
;
155 virtual size_t readBlock( void *ptr
, size_t size
) override
;
156 virtual size_t skipBlock( size_t size
) override
;
158 virtual void init() override
;
160 #endif // INCLUDED_HWPFILTER_SOURCE_HIODEV_H
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */