Coverage Report

Created: 2026-08-17 07:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openexr/src/lib/OpenEXR/ImfName.h
Line
Count
Source
1
//
2
// SPDX-License-Identifier: BSD-3-Clause
3
// Copyright (c) Contributors to the OpenEXR Project.
4
//
5
6
#ifndef INCLUDED_IMF_NAME_H
7
#define INCLUDED_IMF_NAME_H
8
9
//-----------------------------------------------------------------------------
10
//
11
//  class ImfName -- a zero-terminated string
12
//  with a fixed, small maximum length
13
//
14
//-----------------------------------------------------------------------------
15
16
#include "ImfExport.h"
17
#include "ImfNamespace.h"
18
19
#include <cstring>
20
21
#if defined(_MSC_VER)
22
#    pragma warning(push, 0)
23
#    pragma warning(disable : 4996)
24
#endif
25
26
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
27
28
class IMF_EXPORT_TYPE Name
29
{
30
public:
31
    //-------------
32
    // Constructors
33
    //-------------
34
35
    Name ();
36
    Name (const char text[]);
37
    Name (const Name&) = default;
38
    Name (Name&&)      = default;
39
    ~Name ()           = default;
40
41
    //--------------------
42
    // Assignment operator
43
    //--------------------
44
45
    Name& operator= (const Name&) = default;
46
    Name& operator= (Name&&)      = default;
47
    Name& operator= (const char text[]);
48
49
    //---------------------
50
    // Access to the string
51
    //---------------------
52
53
0
    inline const char* text () const { return _text; }
54
49.4M
    inline const char* operator* () const { return _text; }
55
56
    //---------------
57
    // Maximum length
58
    //---------------
59
60
    static const int SIZE       = 256;
61
    static const int MAX_LENGTH = SIZE - 1;
62
63
private:
64
    char _text[SIZE];
65
};
66
67
//-----------------
68
// Inline functions
69
//-----------------
70
71
inline Name&
72
Name::operator= (const char text[])
73
7.16M
{
74
7.16M
    strncpy (_text, text, MAX_LENGTH);
75
7.16M
    _text[MAX_LENGTH] = 0;
76
7.16M
    return *this;
77
7.16M
}
78
79
inline Name::Name ()
80
{
81
    _text[0] = 0;
82
}
83
84
inline Name::Name (const char text[])
85
7.16M
{
86
7.16M
    *this             = text;
87
7.16M
    _text[MAX_LENGTH] = 0;
88
7.16M
}
89
90
inline bool
91
operator== (const Name& x, const Name& y)
92
0
{
93
0
    return strcmp (*x, *y) == 0;
94
0
}
95
96
inline bool
97
operator== (const Name& x, const char text[])
98
0
{
99
0
    return strcmp (*x, text) == 0;
100
0
}
101
102
inline bool
103
operator== (const char text[], const Name& y)
104
0
{
105
0
    return strcmp (text, *y) == 0;
106
0
}
107
108
inline bool
109
operator!= (const Name& x, const Name& y)
110
0
{
111
0
    return !(x == y);
112
0
}
113
114
inline bool
115
operator!= (const Name& x, const char text[])
116
0
{
117
0
    return !(x == text);
118
0
}
119
120
inline bool
121
operator!= (const char text[], const Name& y)
122
0
{
123
0
    return !(text == y);
124
0
}
125
126
inline bool
127
operator< (const Name& x, const Name& y)
128
24.7M
{
129
24.7M
    return strcmp (*x, *y) < 0;
130
24.7M
}
131
132
inline bool
133
operator< (const Name& x, const char text[])
134
0
{
135
0
    return strcmp (*x, text) < 0;
136
0
}
137
138
inline bool
139
operator< (const char text[], const Name& y)
140
0
{
141
0
    return strcmp (text, *y) < 0;
142
0
}
143
144
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
145
146
#if defined(_MSC_VER)
147
#    pragma warning(pop)
148
#endif
149
150
#endif