LCOV - code coverage report
Current view: top level - frmts/pdf - pdfio.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 3 5 60.0 %
Date: 2026-02-03 21:43:34 Functions: 1 2 50.0 %

          Line data    Source code
       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             : #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             :     ~VSIPDFFileStream() override;
      31             : 
      32             :     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             :     Goffset getPos() override;
      45             :     Goffset getStart() override;
      46             : 
      47             :     void setPos(Goffset pos, int dir = 0) override;
      48             :     void moveStart(Goffset delta) override;
      49             : 
      50             :     StreamKind getKind() const override;
      51             : 
      52             :     GooString *getFileName() override;
      53             : 
      54             :     int getChar() override;
      55             :     int getUnfilteredChar() override;
      56             :     int lookChar() override;
      57             : 
      58             : #if POPPLER_MAJOR_VERSION > 25
      59             :     bool rewind() override;
      60             : #elif POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2
      61             :     bool reset() override;
      62             : #else
      63             :     void reset() override;
      64             : #endif
      65             : 
      66           3 :     static void resetNoCheckReturnValue(Stream *str)
      67             :     {
      68             : #if POPPLER_MAJOR_VERSION > 25
      69             :         CPL_IGNORE_RET_VAL(str->rewind());
      70             : #elif POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2
      71             :         CPL_IGNORE_RET_VAL(str->reset());
      72             : #else
      73           3 :         str->reset();
      74             : #endif
      75           3 :     }
      76             : 
      77             : #if POPPLER_MAJOR_VERSION > 25
      78             :     bool unfilteredRewind() override;
      79             : #elif POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2
      80             :     bool unfilteredReset() override;
      81             : #else
      82             :     void unfilteredReset() override;
      83             : #endif
      84             : 
      85             :     void close() override;
      86             : 
      87           0 :     bool FoundLinearizedHint() const
      88             :     {
      89           0 :         return bFoundLinearizedHint;
      90             :     }
      91             : 
      92             :   private:
      93             :     bool hasGetChars() override;
      94             :     int getChars(int nChars, unsigned char *buffer) override;
      95             : 
      96             :     VSIPDFFileStream *poParent = nullptr;
      97             :     GooString *poFilename = nullptr;
      98             :     VSILFILE *f = nullptr;
      99             :     vsi_l_offset nStart = 0;
     100             :     bool bLimited = false;
     101             :     vsi_l_offset nLength = 0;
     102             : 
     103             :     vsi_l_offset nCurrentPos = VSI_L_OFFSET_MAX;
     104             :     int bHasSavedPos = FALSE;
     105             :     vsi_l_offset nSavedPos = 0;
     106             : 
     107             :     GByte abyBuffer[BUFFER_SIZE];
     108             :     int nPosInBuffer = -1;
     109             :     int nBufferLength = -1;
     110             : 
     111             :     bool bFoundLinearizedHint = false;
     112             : 
     113             :     int FillBuffer();
     114             : 
     115             :     CPL_DISALLOW_COPY_ASSIGN(VSIPDFFileStream)
     116             : };
     117             : 
     118             : #endif  // PDFIO_H_INCLUDED

Generated by: LCOV version 1.14