LibreOffice Module hwpfilter (master) 1
hiodev.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
25#ifndef INCLUDED_HWPFILTER_SOURCE_HIODEV_H
26#define INCLUDED_HWPFILTER_SOURCE_HIODEV_H
27
28#include <sal/config.h>
29
30#include <stdio.h>
31
32#include <memory>
33#include <sal/types.h>
34
35#include "hwplib.h"
40{
41 protected:
43 virtual void init();
44 public:
45 HIODev();
46 virtual ~HIODev();
47
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;
53
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;
61
62 size_t read2b( void *ptr, size_t nmemb );
63 size_t read4b( void *ptr, size_t nmemb );
64};
65
66struct gz_stream;
67
68/* File input and output devices */
69
74class HStreamIODev final: public HIODev
75{
76 private:
77/* zlib으로 압축을 풀기 위한 자료 구조 */
78 std::unique_ptr<HStream> _stream;
80 public:
81 explicit HStreamIODev(std::unique_ptr<HStream> stream);
82 virtual ~HStreamIODev() override;
86 virtual bool open() override;
90 virtual void flush() override;
94 virtual bool state() const override;
98 virtual bool setCompressed( bool ) override;
102 virtual bool read1b(unsigned char &out) override;
103 virtual bool read1b(char &out) override;
107 using HIODev::read2b;
108 virtual bool read2b(unsigned short &out) override;
112 using HIODev::read4b;
113 virtual bool read4b(unsigned int &out) override;
114 virtual bool read4b(int &out) override;
118 virtual size_t readBlock( void *ptr, size_t size ) override;
122 virtual size_t skipBlock( size_t size ) override;
123 private:
127 virtual void init() override;
128};
129
130/* Memory, input and output devices */
135class HMemIODev final: public HIODev
136{
138 size_t pos, length;
139 public:
140 HMemIODev(char *s, size_t len);
141 virtual ~HMemIODev() override;
142
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;
159};
160#endif // INCLUDED_HWPFILTER_SOURCE_HIODEV_H
161
162/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FILE * init(int, char **)
hwpio.h (C) 1999 Mizi Research, All rights are reserved
Definition: hiodev.h:40
bool compressed
Definition: hiodev.h:42
virtual bool read2b(unsigned short &out)=0
virtual bool read1b(char &out)=0
virtual bool open()=0
virtual bool read4b(int &out)=0
virtual bool state() const =0
virtual bool read1b(unsigned char &out)=0
virtual size_t skipBlock(size_t size)=0
virtual void flush()=0
virtual bool setCompressed(bool)=0
virtual bool read4b(unsigned int &out)=0
virtual size_t readBlock(void *ptr, size_t size)=0
The HMemIODev class controls the Input/Output device.
Definition: hiodev.h:136
virtual size_t skipBlock(size_t size) override
Definition: hiodev.cxx:347
virtual size_t readBlock(void *ptr, size_t size) override
Definition: hiodev.cxx:336
virtual bool read1b(unsigned char &out) override
Definition: hiodev.cxx:284
virtual ~HMemIODev() override
Definition: hiodev.cxx:251
virtual void init() override
Definition: hiodev.cxx:256
size_t length
Definition: hiodev.h:138
virtual bool read4b(unsigned int &out) override
Definition: hiodev.cxx:315
virtual bool state() const override
Definition: hiodev.cxx:274
HMemIODev(char *s, size_t len)
Definition: hiodev.cxx:243
virtual bool read2b(unsigned short &out) override
Definition: hiodev.cxx:304
virtual void flush() override
Definition: hiodev.cxx:270
virtual bool setCompressed(bool) override
Definition: hiodev.cxx:279
virtual bool open() override
Definition: hiodev.cxx:264
uchar * ptr
Definition: hiodev.h:137
size_t pos
Definition: hiodev.h:138
This controls the HStream given by constructor.
Definition: hiodev.h:75
virtual size_t readBlock(void *ptr, size_t size) override
Read some bytes from stream to given pointer as amount of size.
Definition: hiodev.cxx:207
virtual void flush() override
If the stream is gzipped, flush the stream.
Definition: hiodev.cxx:121
virtual bool read1b(unsigned char &out) override
Read one byte from stream.
Definition: hiodev.cxx:155
virtual ~HStreamIODev() override
Definition: hiodev.cxx:98
virtual size_t skipBlock(size_t size) override
Move current pointer of stream as amount of size.
Definition: hiodev.cxx:217
virtual bool read2b(unsigned short &out) override
Definition: hiodev.cxx:175
std::unique_ptr< HStream > _stream
Definition: hiodev.h:78
HStreamIODev(std::unique_ptr< HStream > stream)
Definition: hiodev.cxx:92
virtual bool setCompressed(bool) override
Set whether the stream is compressed or not.
Definition: hiodev.cxx:133
virtual bool read4b(unsigned int &out) override
Definition: hiodev.cxx:186
virtual bool open() override
Check whether the stream is available.
Definition: hiodev.cxx:115
gz_stream * _gzfp
Definition: hiodev.h:79
virtual void init() override
Initialize this object.
Definition: hiodev.cxx:108
virtual bool state() const override
Not implemented.
Definition: hiodev.cxx:127
unsigned char uchar
Definition: hwplib.h:40
#define DLLEXPORT
Definition: hwplib.h:201
Structure for using z_stream.
Definition: hgzip.h:30