tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / hwpfilter / source / hiodev.h
blobb6f2c7aa2be793cd90a3db2438b4cc60f582d0ee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 /**
21 * hwpio.h
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>
30 #include <stdio.h>
32 #include <memory>
33 #include <sal/types.h>
35 #include "hwplib.h"
36 /**
37 * @short Abstract IO class
39 class DLLEXPORT HIODev
41 protected:
42 bool compressed;
43 virtual void init();
44 public:
45 HIODev();
46 virtual ~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 );
66 struct gz_stream;
68 /* File input and output devices */
70 /**
71 * This controls the HStream given by constructor
72 * @short Stream IO device
74 class HStreamIODev final: public HIODev
76 private:
77 /* zlib으로 압축을 풀기 위한 자료 구조 */
78 std::unique_ptr<HStream> _stream;
79 gz_stream *_gzfp;
80 public:
81 explicit HStreamIODev(std::unique_ptr<HStream> stream);
82 virtual ~HStreamIODev() override;
83 /**
84 * Check whether the stream is available
86 virtual bool open() override;
87 /**
88 * If the stream is gzipped, flush the stream.
90 virtual void flush() override;
91 /**
92 * Not implemented.
94 virtual bool state() const override;
95 /**
96 * Set whether the stream is compressed or not
98 virtual bool setCompressed( bool ) override;
99 /**
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;
123 private:
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
137 uchar *ptr;
138 size_t pos, length;
139 public:
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;
157 private:
158 virtual void init() override;
160 #endif // INCLUDED_HWPFILTER_SOURCE_HIODEV_H
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */