1 /* poppler-qiodeviceinstream.cc: Qt6 interface to poppler
2 * Copyright (C) 2019 Alexander Volkov <a.volkov@rusbitech.ru>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "poppler-qiodeviceinstream-private.h"
20
21 #include <QtCore/QIODevice>
22
23 #include <cstdio>
24
25 namespace Poppler {
26
QIODeviceInStream(QIODevice * device,Goffset startA,bool limitedA,Goffset lengthA,Object && dictA)27 QIODeviceInStream::QIODeviceInStream(QIODevice *device, Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA) : BaseSeekInputStream(startA, limitedA, lengthA, std::move(dictA)), m_device(device) { }
28
~QIODeviceInStream()29 QIODeviceInStream::~QIODeviceInStream()
30 {
31 close();
32 }
33
copy()34 BaseStream *QIODeviceInStream::copy()
35 {
36 return new QIODeviceInStream(m_device, start, limited, length, dict.copy());
37 }
38
makeSubStream(Goffset startA,bool limitedA,Goffset lengthA,Object && dictA)39 Stream *QIODeviceInStream::makeSubStream(Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA)
40 {
41 return new QIODeviceInStream(m_device, startA, limitedA, lengthA, std::move(dictA));
42 }
43
currentPos() const44 Goffset QIODeviceInStream::currentPos() const
45 {
46 return m_device->pos();
47 }
48
setCurrentPos(Goffset offset)49 void QIODeviceInStream::setCurrentPos(Goffset offset)
50 {
51 m_device->seek(offset);
52 }
53
read(char * buffer,Goffset count)54 Goffset QIODeviceInStream::read(char *buffer, Goffset count)
55 {
56 return m_device->read(buffer, count);
57 }
58
59 }
60