Line data Source code
1 : /****************************************************************************** 2 : * $Id$ 3 : * 4 : * Project: PDF driver 5 : * Purpose: GDALDataset driver for PDF dataset. 6 : * Author: Even Rouault, <even dot rouault at spatialys.com> 7 : * 8 : ****************************************************************************** 9 : * Copyright (c) 2010-2013, Even Rouault <even dot rouault at spatialys.com> 10 : * 11 : * SPDX-License-Identifier: MIT 12 : ****************************************************************************/ 13 : 14 : #ifndef PDFIO_H_INCLUDED 15 : #define PDFIO_H_INCLUDED 16 : 17 : #include "cpl_vsi_virtual.h" 18 : 19 : /************************************************************************/ 20 : /* VSIPDFFileStream */ 21 : /************************************************************************/ 22 : 23 : #define BUFFER_SIZE 1024 24 : 25 : class VSIPDFFileStream final : public BaseStream 26 : { 27 : public: 28 : VSIPDFFileStream(VSILFILE *f, const char *pszFilename, Object &&dictA); 29 : VSIPDFFileStream(VSIPDFFileStream *poParent, vsi_l_offset startA, 30 : bool limitedA, vsi_l_offset lengthA, Object &&dictA); 31 : virtual ~VSIPDFFileStream(); 32 : 33 : virtual BaseStream *copy() override; 34 : 35 : virtual Stream *makeSubStream(Goffset startA, bool limitedA, 36 : Goffset lengthA, Object &&dictA) override; 37 : virtual Goffset getPos() override; 38 : virtual Goffset getStart() override; 39 : 40 : virtual void setPos(Goffset pos, int dir = 0) override; 41 : virtual void moveStart(Goffset delta) override; 42 : 43 : virtual StreamKind getKind() const override; 44 : 45 : virtual GooString *getFileName() override; 46 : 47 : virtual int getChar() override; 48 : virtual int getUnfilteredChar() override; 49 : virtual int lookChar() override; 50 : 51 : virtual void reset() override; 52 : virtual void unfilteredReset() override; 53 : virtual void close() override; 54 : 55 0 : bool FoundLinearizedHint() const 56 : { 57 0 : return bFoundLinearizedHint; 58 : } 59 : 60 : private: 61 : virtual bool hasGetChars() override; 62 : virtual int getChars(int nChars, unsigned char *buffer) override; 63 : 64 : VSIPDFFileStream *poParent = nullptr; 65 : GooString *poFilename = nullptr; 66 : VSILFILE *f = nullptr; 67 : vsi_l_offset nStart = 0; 68 : bool bLimited = false; 69 : vsi_l_offset nLength = 0; 70 : 71 : vsi_l_offset nCurrentPos = VSI_L_OFFSET_MAX; 72 : int bHasSavedPos = FALSE; 73 : vsi_l_offset nSavedPos = 0; 74 : 75 : GByte abyBuffer[BUFFER_SIZE]; 76 : int nPosInBuffer = -1; 77 : int nBufferLength = -1; 78 : 79 : bool bFoundLinearizedHint = false; 80 : 81 : int FillBuffer(); 82 : 83 : CPL_DISALLOW_COPY_ASSIGN(VSIPDFFileStream) 84 : }; 85 : 86 : #endif // PDFIO_H_INCLUDED