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 #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 
27 
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  inline const char* text () const { return _text; }
54  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 {
74  strncpy (_text, text, MAX_LENGTH);
75  return *this;
76 }
77 
78 inline Name::Name ()
79 {
80  _text[0] = 0;
81 }
82 
83 inline Name::Name (const char text[])
84 {
85  *this = text;
86  _text[MAX_LENGTH] = 0;
87 }
88 
89 inline bool
90 operator== (const Name& x, const Name& y)
91 {
92  return strcmp (*x, *y) == 0;
93 }
94 
95 inline bool
96 operator== (const Name& x, const char text[])
97 {
98  return strcmp (*x, text) == 0;
99 }
100 
101 inline bool
102 operator== (const char text[], const Name& y)
103 {
104  return strcmp (text, *y) == 0;
105 }
106 
107 inline bool
108 operator!= (const Name& x, const Name& y)
109 {
110  return !(x == y);
111 }
112 
113 inline bool
114 operator!= (const Name& x, const char text[])
115 {
116  return !(x == text);
117 }
118 
119 inline bool
120 operator!= (const char text[], const Name& y)
121 {
122  return !(text == y);
123 }
124 
125 inline bool
126 operator< (const Name& x, const Name& y)
127 {
128  return strcmp (*x, *y) < 0;
129 }
130 
131 inline bool
132 operator< (const Name& x, const char text[])
133 {
134  return strcmp (*x, text) < 0;
135 }
136 
137 inline bool
138 operator< (const char text[], const Name& y)
139 {
140  return strcmp (text, *y) < 0;
141 }
142 
144 
145 #if defined(_MSC_VER)
146 # pragma warning(pop)
147 #endif
148 
149 #endif
Definition: ImfName.h:28
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:83
Name & operator=(const Name &)=default
bool operator<(const Name &x, const Name &y)
Definition: ImfName.h:126
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
LeafData & operator=(const LeafData &)=delete
static const int MAX_LENGTH
Definition: ImfName.h:61
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:80
#define SIZE
Definition: simple.C:41
const char * text() const
Definition: ImfName.h:53
Name()
Definition: ImfName.h:78
#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