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 //
3 // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
4 // Digital Ltd. LLC
5 //
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
16 // distribution.
17 // * Neither the name of Industrial Light & Magic nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 ///////////////////////////////////////////////////////////////////////////
34 
35 
36 
37 #ifndef INCLUDED_IMF_NAME_H
38 #define INCLUDED_IMF_NAME_H
39 
40 //-----------------------------------------------------------------------------
41 //
42 // class ImfName -- a zero-terminated string
43 // with a fixed, small maximum length
44 //
45 //-----------------------------------------------------------------------------
46 
47 #include <string.h>
48 #include "ImfNamespace.h"
49 #include "ImfExport.h"
50 
52 
53 
54 class Name
55 {
56  public:
57 
58  //-------------
59  // Constructors
60  //-------------
61 
63  Name ();
65  Name (const char text[]);
66 
67 
68  //--------------------
69  // Assignment operator
70  //--------------------
71 
73  Name & operator = (const char text[]);
74 
75 
76  //---------------------
77  // Access to the string
78  //---------------------
79 
80  inline
81  const char * text () const {return _text;}
82  inline
83  const char * operator * () const {return _text;}
84 
85  //---------------
86  // Maximum length
87  //---------------
88 
89  static const int SIZE = 256;
90  static const int MAX_LENGTH = SIZE - 1;
91 
92  private:
93 
94  char _text[SIZE];
95 };
96 
97 
99 bool operator == (const Name &x, const Name &y);
101 bool operator != (const Name &x, const Name &y);
103 bool operator < (const Name &x, const Name &y);
104 
105 
106 //-----------------
107 // Inline functions
108 //-----------------
109 
110 inline Name &
111 Name::operator = (const char text[])
112 {
113  strncpy (_text, text, MAX_LENGTH);
114  return *this;
115 }
116 
117 
118 inline
120 {
121  _text[0] = 0;
122 }
123 
124 
125 inline
126 Name::Name (const char text[])
127 {
128  *this = text;
129  _text [MAX_LENGTH] = 0;
130 }
131 
132 
133 inline bool
134 operator == (const Name &x, const Name &y)
135 {
136  return strcmp (*x, *y) == 0;
137 }
138 
139 
140 inline bool
141 operator != (const Name &x, const Name &y)
142 {
143  return !(x == y);
144 }
145 
146 
147 inline bool
148 operator < (const Name &x, const Name &y)
149 {
150  return strcmp (*x, *y) < 0;
151 }
152 
153 
155 
156 
157 
158 
159 #endif
Definition: ImfName.h:54
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:109
IMF_EXPORT Name & operator=(const char text[])
Definition: ImfName.h:111
IMF_EXPORT bool operator<(const Name &x, const Name &y)
Definition: ImfName.h:148
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:577
#define IMF_EXPORT
Definition: ImfExport.h:44
static const int MAX_LENGTH
Definition: ImfName.h:90
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:108
const char * operator*() const
Definition: ImfName.h:83
const char * text() const
Definition: ImfName.h:81
IMF_EXPORT Name()
Definition: ImfName.h:119
static const int SIZE
Definition: ImfName.h:89
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:563