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 : * Permission is hereby granted, free of charge, to any person obtaining a 12 : * copy of this software and associated documentation files (the "Software"), 13 : * to deal in the Software without restriction, including without limitation 14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 : * and/or sell copies of the Software, and to permit persons to whom the 16 : * Software is furnished to do so, subject to the following conditions: 17 : * 18 : * The above copyright notice and this permission notice shall be included 19 : * in all copies or substantial portions of the Software. 20 : * 21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 : * DEALINGS IN THE SOFTWARE. 28 : ****************************************************************************/ 29 : 30 : #ifndef PDFIO_H_INCLUDED 31 : #define PDFIO_H_INCLUDED 32 : 33 : #include "cpl_vsi_virtual.h" 34 : 35 : /************************************************************************/ 36 : /* VSIPDFFileStream */ 37 : /************************************************************************/ 38 : 39 : #define BUFFER_SIZE 1024 40 : 41 : class VSIPDFFileStream final : public BaseStream 42 : { 43 : public: 44 : VSIPDFFileStream(VSILFILE *f, const char *pszFilename, Object &&dictA); 45 : VSIPDFFileStream(VSIPDFFileStream *poParent, vsi_l_offset startA, 46 : bool limitedA, vsi_l_offset lengthA, Object &&dictA); 47 : virtual ~VSIPDFFileStream(); 48 : 49 : virtual BaseStream *copy() override; 50 : 51 : virtual Stream *makeSubStream(Goffset startA, bool limitedA, 52 : Goffset lengthA, Object &&dictA) override; 53 : virtual Goffset getPos() override; 54 : virtual Goffset getStart() override; 55 : 56 : virtual void setPos(Goffset pos, int dir = 0) override; 57 : virtual void moveStart(Goffset delta) override; 58 : 59 : virtual StreamKind getKind() const override; 60 : 61 : virtual GooString *getFileName() override; 62 : 63 : virtual int getChar() override; 64 : virtual int getUnfilteredChar() override; 65 : virtual int lookChar() override; 66 : 67 : virtual void reset() override; 68 : virtual void unfilteredReset() override; 69 : virtual void close() override; 70 : 71 0 : bool FoundLinearizedHint() const 72 : { 73 0 : return bFoundLinearizedHint; 74 : } 75 : 76 : private: 77 : virtual bool hasGetChars() override; 78 : virtual int getChars(int nChars, unsigned char *buffer) override; 79 : 80 : VSIPDFFileStream *poParent; 81 : GooString *poFilename; 82 : VSILFILE *f; 83 : vsi_l_offset nStart; 84 : bool bLimited; 85 : vsi_l_offset nLength; 86 : 87 : vsi_l_offset nCurrentPos; 88 : int bHasSavedPos; 89 : vsi_l_offset nSavedPos; 90 : 91 : GByte abyBuffer[BUFFER_SIZE]; 92 : int nPosInBuffer; 93 : int nBufferLength; 94 : 95 : bool bFoundLinearizedHint = false; 96 : 97 : int FillBuffer(); 98 : }; 99 : 100 : #endif // PDFIO_H_INCLUDED