/src/gdal/frmts/pdf/pdfio.h
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: PDF driver |
4 | | * Purpose: GDALDataset driver for PDF dataset. |
5 | | * Author: Even Rouault, <even dot rouault at spatialys.com> |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2010-2013, Even Rouault <even dot rouault at spatialys.com> |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #ifndef PDFIO_H_INCLUDED |
14 | | #define PDFIO_H_INCLUDED |
15 | | |
16 | | #include "cpl_vsi_virtual.h" |
17 | | |
18 | | /************************************************************************/ |
19 | | /* VSIPDFFileStream */ |
20 | | /************************************************************************/ |
21 | | |
22 | 3.51M | #define BUFFER_SIZE 1024 |
23 | | |
24 | | class VSIPDFFileStream final : public BaseStream |
25 | | { |
26 | | public: |
27 | | VSIPDFFileStream(VSILFILE *f, const char *pszFilename, Object &&dictA); |
28 | | VSIPDFFileStream(VSIPDFFileStream *poParent, vsi_l_offset startA, |
29 | | bool limitedA, vsi_l_offset lengthA, Object &&dictA); |
30 | | virtual ~VSIPDFFileStream(); |
31 | | |
32 | | virtual BaseStream *copy() override; |
33 | | |
34 | | #if POPPLER_MAJOR_VERSION > 25 || \ |
35 | | (POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 5) |
36 | | virtual std::unique_ptr<Stream> makeSubStream(Goffset startA, bool limitedA, |
37 | | Goffset lengthA, |
38 | | Object &&dictA) override; |
39 | | #else |
40 | | virtual Stream *makeSubStream(Goffset startA, bool limitedA, |
41 | | Goffset lengthA, Object &&dictA) override; |
42 | | |
43 | | #endif |
44 | | virtual Goffset getPos() override; |
45 | | virtual Goffset getStart() override; |
46 | | |
47 | | virtual void setPos(Goffset pos, int dir = 0) override; |
48 | | virtual void moveStart(Goffset delta) override; |
49 | | |
50 | | virtual StreamKind getKind() const override; |
51 | | |
52 | | virtual GooString *getFileName() override; |
53 | | |
54 | | virtual int getChar() override; |
55 | | virtual int getUnfilteredChar() override; |
56 | | virtual int lookChar() override; |
57 | | |
58 | | #if POPPLER_MAJOR_VERSION > 25 || \ |
59 | | (POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2) |
60 | | virtual bool reset() override; |
61 | | #else |
62 | | virtual void reset() override; |
63 | | #endif |
64 | | |
65 | | static void resetNoCheckReturnValue(Stream *str) |
66 | 0 | { |
67 | | #if POPPLER_MAJOR_VERSION > 25 || \ |
68 | | (POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2) |
69 | | CPL_IGNORE_RET_VAL(str->reset()); |
70 | | #else |
71 | 0 | str->reset(); |
72 | 0 | #endif |
73 | 0 | } |
74 | | |
75 | | #if POPPLER_MAJOR_VERSION > 25 || \ |
76 | | (POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 3) |
77 | | virtual bool unfilteredReset() override; |
78 | | #else |
79 | | virtual void unfilteredReset() override; |
80 | | #endif |
81 | | |
82 | | virtual void close() override; |
83 | | |
84 | | bool FoundLinearizedHint() const |
85 | 0 | { |
86 | 0 | return bFoundLinearizedHint; |
87 | 0 | } |
88 | | |
89 | | private: |
90 | | virtual bool hasGetChars() override; |
91 | | virtual int getChars(int nChars, unsigned char *buffer) override; |
92 | | |
93 | | VSIPDFFileStream *poParent = nullptr; |
94 | | GooString *poFilename = nullptr; |
95 | | VSILFILE *f = nullptr; |
96 | | vsi_l_offset nStart = 0; |
97 | | bool bLimited = false; |
98 | | vsi_l_offset nLength = 0; |
99 | | |
100 | | vsi_l_offset nCurrentPos = VSI_L_OFFSET_MAX; |
101 | | int bHasSavedPos = FALSE; |
102 | | vsi_l_offset nSavedPos = 0; |
103 | | |
104 | | GByte abyBuffer[BUFFER_SIZE]; |
105 | | int nPosInBuffer = -1; |
106 | | int nBufferLength = -1; |
107 | | |
108 | | bool bFoundLinearizedHint = false; |
109 | | |
110 | | int FillBuffer(); |
111 | | |
112 | | CPL_DISALLOW_COPY_ASSIGN(VSIPDFFileStream) |
113 | | }; |
114 | | |
115 | | #endif // PDFIO_H_INCLUDED |