HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfName.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 
7 #ifndef INCLUDED_IMF_NAME_H
8 #define INCLUDED_IMF_NAME_H
9 
10 //-----------------------------------------------------------------------------
11 //
12 // class ImfName -- a zero-terminated string
13 // with a fixed, small maximum length
14 //
15 //-----------------------------------------------------------------------------
16 
17 #include "ImfExport.h"
18 #include "ImfNamespace.h"
19 
20 #include <cstring>
21 
22 #if defined(_MSC_VER)
23 #pragma warning( push, 0 )
24 #pragma warning (disable : 4996)
25 #endif
26 
28 
29 
31 {
32  public:
33 
34  //-------------
35  // Constructors
36  //-------------
37 
38  Name ();
39  Name (const char text[]);
40  Name (const Name &) = default;
41  Name (Name &&) = default;
42  ~Name () = default;
43 
44 
45  //--------------------
46  // Assignment operator
47  //--------------------
48 
49  Name &operator = (const Name &) = default;
50  Name &operator = (Name &&) = default;
51  Name &operator = (const char text[]);
52 
53 
54  //---------------------
55  // Access to the string
56  //---------------------
57 
58  inline
59  const char * text () const {return _text;}
60  inline
61  const char * operator * () const {return _text;}
62 
63  //---------------
64  // Maximum length
65  //---------------
66 
67  static const int SIZE = 256;
68  static const int MAX_LENGTH = SIZE - 1;
69 
70  private:
71 
72  char _text[SIZE];
73 };
74 
75 //-----------------
76 // Inline functions
77 //-----------------
78 
79 inline Name &
80 Name::operator = (const char text[])
81 {
82  strncpy (_text, text, MAX_LENGTH);
83  return *this;
84 }
85 
86 
87 inline
89 {
90  _text[0] = 0;
91 }
92 
93 
94 inline
95 Name::Name (const char text[])
96 {
97  *this = text;
98  _text [MAX_LENGTH] = 0;
99 }
100 
101 
102 inline bool
103 operator == (const Name &x, const Name &y)
104 {
105  return strcmp (*x, *y) == 0;
106 }
107 
108 
109 inline bool
110 operator == (const Name &x, const char text[])
111 {
112  return strcmp (*x, text) == 0;
113 }
114 
115 
116 inline bool
117 operator == (const char text[], const Name &y)
118 {
119  return strcmp (text, *y) == 0;
120 }
121 
122 
123 inline bool
124 operator != (const Name &x, const Name &y)
125 {
126  return !(x == y);
127 }
128 
129 
130 inline bool
131 operator != (const Name &x, const char text[])
132 {
133  return !(x == text);
134 }
135 
136 
137 inline bool
138 operator != (const char text[], const Name &y)
139 {
140  return !(text == y);
141 }
142 
143 
144 inline bool
145 operator < (const Name &x, const Name &y)
146 {
147  return strcmp (*x, *y) < 0;
148 }
149 
150 
151 inline bool
152 operator < (const Name &x, const char text[])
153 {
154  return strcmp (*x, text) < 0;
155 }
156 
157 
158 inline bool
159 operator < (const char text[], const Name &y)
160 {
161  return strcmp (text, *y) < 0;
162 }
163 
164 
166 
167 #if defined(_MSC_VER)
168 #pragma warning (pop)
169 #endif
170 
171 #endif
Definition: ImfName.h:30
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:80
Name & operator=(const Name &)=default
bool operator<(const Name &x, const Name &y)
Definition: ImfName.h:145
GLint y
Definition: glcorearb.h:103
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
IMATH_HOSTDEVICE constexpr Color4< T > operator*(S a, const Color4< T > &v) IMATH_NOEXCEPT
Reverse multiplication: S * Color4.
Definition: ImathColor.h:732
GLint GLenum GLint x
Definition: glcorearb.h:409
static const int MAX_LENGTH
Definition: ImfName.h:68
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:79
#define SIZE
Definition: simple.C:41
const char * text() const
Definition: ImfName.h:59
Name()
Definition: ImfName.h:88
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542