Coverage Report

Created: 2026-10-14 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/exiv2/include/exiv2/pgfimage.hpp
Line
Count
Source
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
3
#ifndef EXIV2_PGFIMAGE_HPP
4
#define EXIV2_PGFIMAGE_HPP
5
6
// *****************************************************************************
7
#include "exiv2lib_export.h"
8
9
// included header files
10
#include "image.hpp"
11
12
// *****************************************************************************
13
// namespace extensions
14
namespace Exiv2 {
15
// *****************************************************************************
16
// class definitions
17
18
/*!
19
  @brief Class to access PGF images. Exif and IPTC metadata are supported
20
      directly.
21
 */
22
class EXIV2API PgfImage : public Image {
23
 public:
24
  //! @name Creators
25
  //@{
26
  /*!
27
    @brief Constructor that can either open an existing PGF image or create
28
        a new image from scratch. If a new image is to be created, any
29
        existing data is overwritten. Since the constructor can not return
30
        a result, callers should check the good() method after object
31
        construction to determine success or failure.
32
    @param io An auto-pointer that owns a BasicIo instance used for
33
        reading and writing image metadata. \b Important: The constructor
34
        takes ownership of the passed in BasicIo instance through the
35
        auto-pointer. Callers should not continue to use the BasicIo
36
        instance after it is passed to this method.  Use the Image::io()
37
        method to get a temporary reference.
38
    @param params Parameters that are passed through to Image's constructor.
39
   */
40
  PgfImage(std::unique_ptr<BasicIo> io, const ImageCtorParams& params);
41
  //@}
42
43
  //! @name Manipulators
44
  //@{
45
  void readMetadata() override;
46
  void writeMetadata() override;
47
  //@}
48
49
  //! @name Accessors
50
  //@{
51
0
  [[nodiscard]] std::string mimeType() const override {
52
0
    return "image/pgf";
53
0
  }
54
  //@}
55
56
 private:
57
  bool bSwap_;  // true for bigEndian hardware, else false
58
  /*!
59
    @brief Provides the main implementation of writeMetadata() by
60
          writing all buffered metadata to the provided BasicIo.
61
    @throw Error on input-output errors or when the image data is not valid.
62
    @param outIo BasicIo instance to write to (a temporary location).
63
64
   */
65
  void doWriteMetadata(BasicIo& outIo);
66
  //! Read Magick number. Only version >= 6 is supported.
67
  static byte readPgfMagicNumber(BasicIo& iIo);
68
  //! Read PGF Header size encoded in 32 bits integer.
69
  size_t readPgfHeaderSize(BasicIo& iIo) const;
70
  //! Read header structure.
71
  DataBuf readPgfHeaderStructure(BasicIo& iIo, uint32_t& width, uint32_t& height) const;
72
  //@}
73
74
};  // class PgfImage
75
76
// *****************************************************************************
77
// template, inline and free functions
78
79
// These could be static private functions on Image subclasses but then
80
// ImageFactory needs to be made a friend.
81
/*!
82
  @brief Create a new PgfImage instance and return an auto-pointer to it.
83
         Caller owns the returned object and the auto-pointer ensures that
84
         it will be deleted.
85
 */
86
EXIV2API Image::UniquePtr newPgfInstance(std::unique_ptr<BasicIo> io, const ImageCtorParams& params);
87
88
//! Check if the file iIo is a PGF image.
89
EXIV2API bool isPgfType(BasicIo& iIo, bool advance);
90
91
}  // namespace Exiv2
92
93
#endif  // EXIV2_PGFIMAGE_HPP