Coverage Report

Created: 2026-02-26 07:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openexr/src/lib/OpenEXR/ImfCompressionAttribute.cpp
Line
Count
Source
1
//
2
// SPDX-License-Identifier: BSD-3-Clause
3
// Copyright (c) Contributors to the OpenEXR Project.
4
//
5
6
//-----------------------------------------------------------------------------
7
//
8
//  class CompressionAttribute
9
//
10
//-----------------------------------------------------------------------------
11
12
#define COMPILING_IMF_COMPRESSION_ATTRIBUTE
13
14
#include "ImfCompressionAttribute.h"
15
16
#if defined(_MSC_VER)
17
// suppress warning about non-exported base classes
18
#    pragma warning(disable : 4275)
19
#endif
20
21
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
22
23
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
24
25
template <>
26
IMF_EXPORT const char*
27
CompressionAttribute::staticTypeName ()
28
86.4k
{
29
86.4k
    return "compression";
30
86.4k
}
31
32
template <>
33
IMF_EXPORT void
34
CompressionAttribute::writeValueTo (
35
    OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, int version) const
36
0
{
37
0
    unsigned char tmp = _value;
38
0
    Xdr::write<StreamIO> (os, tmp);
39
0
}
40
41
template <>
42
IMF_EXPORT void
43
CompressionAttribute::readValueFrom (
44
    OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, int size, int version)
45
0
{
46
0
    unsigned char tmp;
47
0
    Xdr::read<StreamIO> (is, tmp);
48
49
    //
50
    // prevent invalid values being written to Compression enum
51
    // by forcing all unknown types to NUM_COMPRESSION_METHODS which is also an invalid
52
    // pixel type, but can be used as a PixelType enum value
53
    // (Header::sanityCheck will throw an exception when files with invalid Compression types are read)
54
    //
55
56
0
    if (!isValidCompression (tmp)) { tmp = NUM_COMPRESSION_METHODS; }
57
58
0
    _value = Compression (tmp);
59
0
}
60
61
template class IMF_EXPORT_TEMPLATE_INSTANCE
62
    TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::Compression>;
63
64
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT