Coverage Report

Created: 2026-10-28 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openexr/src/lib/OpenEXR/ImfKeyCode.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 KeyCode
9
//
10
//-----------------------------------------------------------------------------
11
12
#include "Iex.h"
13
#include "ImfNamespace.h"
14
#include "ImfKeyCode.h"
15
16
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
17
18
KeyCode::KeyCode (
19
    int filmMfcCode,
20
    int filmType,
21
    int prefix,
22
    int count,
23
    int perfOffset,
24
    int perfsPerFrame,
25
    int perfsPerCount)
26
1.33k
{
27
1.33k
    setFilmMfcCode (filmMfcCode);
28
1.33k
    setFilmType (filmType);
29
1.33k
    setPrefix (prefix);
30
1.33k
    setCount (count);
31
1.33k
    setPerfOffset (perfOffset);
32
1.33k
    setPerfsPerFrame (perfsPerFrame);
33
1.33k
    setPerfsPerCount (perfsPerCount);
34
1.33k
}
35
36
KeyCode::KeyCode (const KeyCode& other)
37
504
{
38
504
    _filmMfcCode   = other._filmMfcCode;
39
504
    _filmType      = other._filmType;
40
504
    _prefix        = other._prefix;
41
504
    _count         = other._count;
42
504
    _perfOffset    = other._perfOffset;
43
504
    _perfsPerFrame = other._perfsPerFrame;
44
504
    _perfsPerCount = other._perfsPerCount;
45
504
}
46
47
KeyCode&
48
KeyCode::operator= (const KeyCode& other)
49
504
{
50
504
    if (this != &other)
51
504
    {
52
504
        _filmMfcCode   = other._filmMfcCode;
53
504
        _filmType      = other._filmType;
54
504
        _prefix        = other._prefix;
55
504
        _count         = other._count;
56
504
        _perfOffset    = other._perfOffset;
57
504
        _perfsPerFrame = other._perfsPerFrame;
58
504
        _perfsPerCount = other._perfsPerCount;
59
504
    }
60
61
504
    return *this;
62
504
}
63
64
bool
65
KeyCode::operator== (const KeyCode& other) const
66
0
{
67
0
    return (_filmMfcCode   == other._filmMfcCode &&
68
0
            _filmType      == other._filmType &&
69
0
            _prefix        == other._prefix &&
70
0
            _count         == other._count &&
71
0
            _perfOffset    == other._perfOffset &&
72
0
            _perfsPerFrame == other._perfsPerFrame &&
73
0
            _perfsPerCount == other._perfsPerCount);
74
0
}
75
76
int
77
KeyCode::filmMfcCode () const
78
0
{
79
0
    return _filmMfcCode;
80
0
}
81
82
void
83
KeyCode::setFilmMfcCode (int filmMfcCode)
84
1.33k
{
85
1.33k
    if (filmMfcCode < 0 || filmMfcCode > 99)
86
65
        throw IEX_NAMESPACE::ArgExc ("Invalid key code film manufacturer code "
87
65
                                     "(must be between 0 and 99).");
88
89
1.27k
    _filmMfcCode = filmMfcCode;
90
1.27k
}
91
92
int
93
KeyCode::filmType () const
94
0
{
95
0
    return _filmType;
96
0
}
97
98
void
99
KeyCode::setFilmType (int filmType)
100
1.27k
{
101
1.27k
    if (filmType < 0 || filmType > 99)
102
58
        throw IEX_NAMESPACE::ArgExc ("Invalid key code film type "
103
58
                                     "(must be between 0 and 99).");
104
105
1.21k
    _filmType = filmType;
106
1.21k
}
107
108
int
109
KeyCode::prefix () const
110
0
{
111
0
    return _prefix;
112
0
}
113
114
void
115
KeyCode::setPrefix (int prefix)
116
1.21k
{
117
1.21k
    if (prefix < 0 || prefix > 999999)
118
36
        throw IEX_NAMESPACE::ArgExc ("Invalid key code prefix "
119
36
                                     "(must be between 0 and 999999).");
120
121
1.17k
    _prefix = prefix;
122
1.17k
}
123
124
int
125
KeyCode::count () const
126
0
{
127
0
    return _count;
128
0
}
129
130
void
131
KeyCode::setCount (int count)
132
1.17k
{
133
1.17k
    if (count < 0 || count > 9999)
134
35
        throw IEX_NAMESPACE::ArgExc ("Invalid key code count "
135
35
                                     "(must be between 0 and 9999).");
136
137
1.14k
    _count = count;
138
1.14k
}
139
140
int
141
KeyCode::perfOffset () const
142
0
{
143
0
    return _perfOffset;
144
0
}
145
146
void
147
KeyCode::setPerfOffset (int perfOffset)
148
1.14k
{
149
1.14k
    if (perfOffset < 0 || perfOffset > 119)
150
47
        throw IEX_NAMESPACE::ArgExc ("Invalid key code perforation offset "
151
47
                                     "(must be between 0 and 119).");
152
153
1.09k
    _perfOffset = perfOffset;
154
1.09k
}
155
156
int
157
KeyCode::perfsPerFrame () const
158
0
{
159
0
    return _perfsPerFrame;
160
0
}
161
162
void
163
KeyCode::setPerfsPerFrame (int perfsPerFrame)
164
1.09k
{
165
1.09k
    if (perfsPerFrame < 1 || perfsPerFrame > 15)
166
57
        throw IEX_NAMESPACE::ArgExc (
167
57
            "Invalid key code number of perforations per frame "
168
57
            "(must be between 1 and 15).");
169
170
1.03k
    _perfsPerFrame = perfsPerFrame;
171
1.03k
}
172
173
int
174
KeyCode::perfsPerCount () const
175
0
{
176
0
    return _perfsPerCount;
177
0
}
178
179
void
180
KeyCode::setPerfsPerCount (int perfsPerCount)
181
1.03k
{
182
1.03k
    if (perfsPerCount < 20 || perfsPerCount > 120)
183
30
        throw IEX_NAMESPACE::ArgExc (
184
30
            "Invalid key code number of perforations per count "
185
30
            "(must be between 20 and 120).");
186
187
1.00k
    _perfsPerCount = perfsPerCount;
188
1.00k
}
189
190
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT