LCOV - code coverage report
Current view: top level - frmts/pdf - pdfio.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 5 5 100.0 %
Date: 2026-02-28 20:27:10 Functions: 2 2 100.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             : #if POPPLER_MAJOR_VERSION > 26 ||                                              \
      33             :     (POPPLER_MAJOR_VERSION == 26 && POPPLER_MINOR_VERSION >= 2)
      34             :     std::unique_ptr<BaseStream> copy() override;
      35             : #else
      36             :     BaseStream *copy() override;
      37             : #endif
      38             : 
      39             : #if POPPLER_MAJOR_VERSION > 25 ||                                              \
      40             :     (POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 5)
      41             :     virtual std::unique_ptr<Stream> makeSubStream(Goffset startA, bool limitedA,
      42             :                                                   Goffset lengthA,
      43             :                                                   Object &&dictA) override;
      44             : #else
      45             :     virtual Stream *makeSubStream(Goffset startA, bool limitedA,
      46             :                                   Goffset lengthA, Object &&dictA) override;
      47             : 
      48             : #endif
      49             :     Goffset getPos() override;
      50             :     Goffset getStart() override;
      51             : 
      52             :     void setPos(Goffset pos, int dir = 0) override;
      53             :     void moveStart(Goffset delta) override;
      54             : 
      55             :     StreamKind getKind() const override;
      56             : 
      57             :     GooString *getFileName() override;
      58             : 
      59             :     int getChar() override;
      60             :     int getUnfilteredChar() override;
      61             :     int lookChar() override;
      62             : 
      63             : #if POPPLER_MAJOR_VERSION > 25
      64             :     bool rewind() override;
      65             : #elif POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2
      66             :     bool reset() override;
      67             : #else
      68             :     void reset() override;
      69             : #endif
      70             : 
      71           3 :     static void resetNoCheckReturnValue(Stream *str)
      72             :     {
      73             : #if POPPLER_MAJOR_VERSION > 25
      74             :         CPL_IGNORE_RET_VAL(str->rewind());
      75             : #elif POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2
      76             :         CPL_IGNORE_RET_VAL(str->reset());
      77             : #else
      78           3 :         str->reset();
      79             : #endif
      80           3 :     }
      81             : 
      82             : #if POPPLER_MAJOR_VERSION > 25
      83             :     bool unfilteredRewind() override;
      84             : #elif POPPLER_MAJOR_VERSION == 25 && POPPLER_MINOR_VERSION >= 2
      85             :     bool unfilteredReset() override;
      86             : #else
      87             :     void unfilteredReset() override;
      88             : #endif
      89             : 
      90             :     void close() override;
      91             : 
      92         233 :     bool FoundLinearizedHint() const
      93             :     {
      94         233 :         return bFoundLinearizedHint;
      95             :     }
      96             : 
      97             :   private:
      98             :     bool hasGetChars() override;
      99             :     int getChars(int nChars, unsigned char *buffer) override;
     100             : 
     101             :     VSIPDFFileStream *poParent = nullptr;
     102             :     GooString *poFilename = nullptr;
     103             :     VSILFILE *f = nullptr;
     104             :     vsi_l_offset nStart = 0;
     105             :     bool bLimited = false;
     106             :     vsi_l_offset nLength = 0;
     107             : 
     108             :     vsi_l_offset nCurrentPos = VSI_L_OFFSET_MAX;
     109             :     int bHasSavedPos = FALSE;
     110             :     vsi_l_offset nSavedPos = 0;
     111             : 
     112             :     GByte abyBuffer[BUFFER_SIZE];
     113             :     int nPosInBuffer = -1;
     114             :     int nBufferLength = -1;
     115             : 
     116             :     bool bFoundLinearizedHint = false;
     117             : 
     118             :     int FillBuffer();
     119             : 
     120             :     CPL_DISALLOW_COPY_ASSIGN(VSIPDFFileStream)
     121             : };
     122             : 
     123             : #endif  // PDFIO_H_INCLUDED

Generated by: LCOV version 1.14