HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
typedesc.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenImageIO project.
2 // SPDX-License-Identifier: Apache-2.0
3 // https://github.com/AcademySoftwareFoundation/OpenImageIO
4 
5 // clang-format off
6 
7 /// \file
8 /// The TypeDesc class is used to describe simple data types.
9 
10 
11 #pragma once
12 
13 #if defined(_MSC_VER)
14 // Ignore warnings about conditional expressions that always evaluate true
15 // on a given platform but may evaluate differently on another. There's
16 // nothing wrong with such conditionals.
17 # pragma warning(disable : 4127)
18 #endif
19 
20 #include <cmath>
21 #include <cstddef>
22 #include <iostream>
23 #include <limits>
24 
25 #include <OpenImageIO/dassert.h>
26 #include <OpenImageIO/export.h>
29 #include <OpenImageIO/strutil.h>
30 
31 // Define symbols that let client applications determine if newly added
32 // features are supported.
33 #define OIIO_TYPEDESC_VECTOR2 1
34 
35 
36 
38 
39 /////////////////////////////////////////////////////////////////////////////
40 /// A TypeDesc describes simple data types.
41 ///
42 /// It frequently comes up (in my experience, with renderers and image
43 /// handling programs) that you want a way to describe data that is passed
44 /// through APIs through blind pointers. These are some simple classes
45 /// that provide a simple type descriptor system. This is not meant to
46 /// be comprehensive -- for example, there is no provision for structs,
47 /// unions, pointers, const, or 'nested' type definitions. Just simple
48 /// integer and floating point, *common* aggregates such as 3-points,
49 /// and reasonably-lengthed arrays thereof.
50 ///
51 /////////////////////////////////////////////////////////////////////////////
52 
53 struct OIIO_UTIL_API TypeDesc {
54  /// BASETYPE is a simple enum describing the base data types that
55  /// correspond (mostly) to the C/C++ built-in types.
56  enum BASETYPE {
57  UNKNOWN, ///< unknown type
58  NONE, ///< void/no type
59  UINT8, ///< 8-bit unsigned int values ranging from 0..255,
60  ///< (C/C++ `unsigned char`).
61  UCHAR=UINT8,
62  INT8, ///< 8-bit int values ranging from -128..127,
63  ///< (C/C++ `char`).
64  CHAR=INT8,
65  UINT16, ///< 16-bit int values ranging from 0..65535,
66  ///< (C/C++ `unsigned short`).
67  USHORT=UINT16,
68  INT16, ///< 16-bit int values ranging from -32768..32767,
69  ///< (C/C++ `short`).
70  SHORT=INT16,
71  UINT32, ///< 32-bit unsigned int values (C/C++ `unsigned int`).
72  UINT=UINT32,
73  INT32, ///< signed 32-bit int values (C/C++ `int`).
74  INT=INT32,
75  UINT64, ///< 64-bit unsigned int values (C/C++
76  ///< `unsigned long long` on most architectures).
77  ULONGLONG=UINT64,
78  INT64, ///< signed 64-bit int values (C/C++ `long long`
79  ///< on most architectures).
80  LONGLONG=INT64,
81  HALF, ///< 16-bit IEEE floating point values (OpenEXR `half`).
82  FLOAT, ///< 32-bit IEEE floating point values, (C/C++ `float`).
83  DOUBLE, ///< 64-bit IEEE floating point values, (C/C++ `double`).
84  STRING, ///< Character string.
85  PTR, ///< A pointer value.
86  USTRINGHASH, ///< The hash of a ustring
87  LASTBASE
88  };
89 
90  /// AGGREGATE describes whether our TypeDesc is a simple scalar of one
91  /// of the BASETYPE's, or one of several simple aggregates.
92  ///
93  /// Note that aggregates and arrays are different. A `TypeDesc(FLOAT,3)`
94  /// is an array of three floats, a `TypeDesc(FLOAT,VEC3)` is a single
95  /// 3-component vector comprised of floats, and `TypeDesc(FLOAT,3,VEC3)`
96  /// is an array of 3 vectors, each of which is comprised of 3 floats.
97  enum AGGREGATE {
98  SCALAR = 1, ///< A single scalar value (such as a raw `int` or
99  ///< `float` in C). This is the default.
100  VEC2 = 2, ///< 2 values representing a 2D vector.
101  VEC3 = 3, ///< 3 values representing a 3D vector.
102  VEC4 = 4, ///< 4 values representing a 4D vector.
103  MATRIX33 = 9, ///< 9 values representing a 3x3 matrix.
104  MATRIX44 = 16 ///< 16 values representing a 4x4 matrix.
105  };
106 
107  /// VECSEMANTICS gives hints about what the data represent (for example,
108  /// if a spatial vector quantity should transform as a point, direction
109  /// vector, or surface normal).
111  NOXFORM = 0, ///< No semantic hints.
112  NOSEMANTICS = 0, ///< No semantic hints.
113  COLOR, ///< Color
114  POINT, ///< Point: a spatial location
115  VECTOR, ///< Vector: a spatial direction
116  NORMAL, ///< Normal: a surface normal
117  TIMECODE, ///< indicates an `int[2]` representing the standard
118  ///< 4-byte encoding of an SMPTE timecode.
119  KEYCODE, ///< indicates an `int[7]` representing the standard
120  ///< 28-byte encoding of an SMPTE keycode.
121  RATIONAL, ///< A VEC2 representing a rational number `val[0] / val[1]`
122  BOX, ///< A VEC2[2] or VEC3[2] that represents a 2D or 3D bounds (min/max)
123  };
124 
125  unsigned char basetype; ///< C data type at the heart of our type
126  unsigned char aggregate; ///< What kind of AGGREGATE is it?
127  unsigned char vecsemantics; ///< Hint: What does the aggregate represent?
128  unsigned char reserved; ///< Reserved for future expansion
129  int arraylen; ///< Array length, 0 = not array, -1 = unsized
130 
131  /// Construct from a BASETYPE and optional aggregateness, semantics,
132  /// and arrayness.
133  OIIO_HOSTDEVICE constexpr TypeDesc (BASETYPE btype=UNKNOWN, AGGREGATE agg=SCALAR,
134  VECSEMANTICS semantics=NOSEMANTICS,
135  int arraylen=0) noexcept
136  : basetype(static_cast<unsigned char>(btype)),
137  aggregate(static_cast<unsigned char>(agg)),
138  vecsemantics(static_cast<unsigned char>(semantics)), reserved(0),
139  arraylen(arraylen)
140  { }
141 
142  /// Construct an array of a non-aggregate BASETYPE.
143  OIIO_HOSTDEVICE constexpr TypeDesc (BASETYPE btype, int arraylen) noexcept
144  : TypeDesc(btype, SCALAR, NOSEMANTICS, arraylen) {}
145 
146  /// Construct an array from BASETYPE, AGGREGATE, and array length,
147  /// with unspecified (or moot) semantic hints.
148  OIIO_HOSTDEVICE constexpr TypeDesc (BASETYPE btype, AGGREGATE agg, int arraylen) noexcept
149  : TypeDesc(btype, agg, NOSEMANTICS, arraylen) {}
150 
151  /// Construct from a string (e.g., "float[3]"). If no valid
152  /// type could be assembled, set base to UNKNOWN.
153  ///
154  /// Examples:
155  /// ```
156  /// TypeDesc("int") == TypeDesc(TypeDesc::INT) // C++ int32_t
157  /// TypeDesc("float") == TypeDesc(TypeDesc::FLOAT) // C++ float
158  /// TypeDesc("uint16") == TypeDesc(TypeDesc::UINT16) // C++ uint16_t
159  /// TypeDesc("float[4]") == TypeDesc(TypeDesc::FLOAT, 4) // array
160  /// TypeDesc("point") == TypeDesc(TypeDesc::FLOAT,
161  /// TypeDesc::VEC3, TypeDesc::POINT)
162  /// ```
163  ///
164  TypeDesc (string_view typestring);
165 
166  /// Copy constructor.
167  OIIO_HOSTDEVICE constexpr TypeDesc (const TypeDesc &t) noexcept = default;
168 
169 
170  /// Return the name, for printing and whatnot. For example,
171  /// "float", "int[5]", "normal"
172  const char *c_str() const;
173 
174  friend std::ostream& operator<< (std::ostream& o, const TypeDesc& t) {
175  o << t.c_str(); return o;
176  }
177 
178  /// Return the number of elements: 1 if not an array, or the array
179  /// length. Invalid to call this for arrays of undetermined size.
180  OIIO_HOSTDEVICE OIIO_CONSTEXPR14 size_t numelements () const noexcept {
181  OIIO_DASSERT_MSG (arraylen >= 0, "Called numelements() on TypeDesc "
182  "of array with unspecified length (%d)", arraylen);
183  return (arraylen >= 1 ? arraylen : 1);
184  }
185 
186  /// Return the number of basetype values: the aggregate count multiplied
187  /// by the array length (or 1 if not an array). Invalid to call this
188  /// for arrays of undetermined size.
189  OIIO_HOSTDEVICE OIIO_CONSTEXPR14 size_t basevalues () const noexcept {
190  return numelements() * aggregate;
191  }
192 
193  /// Does this TypeDesc describe an array?
194  OIIO_HOSTDEVICE constexpr bool is_array () const noexcept { return (arraylen != 0); }
195 
196  /// Does this TypeDesc describe an array, but whose length is not
197  /// specified?
198  OIIO_HOSTDEVICE constexpr bool is_unsized_array () const noexcept { return (arraylen < 0); }
199 
200  /// Does this TypeDesc describe an array, whose length is specified?
201  OIIO_HOSTDEVICE constexpr bool is_sized_array () const noexcept { return (arraylen > 0); }
202 
203  /// Return the size, in bytes, of this type.
204  ///
205  OIIO_HOSTDEVICE size_t size () const noexcept {
206  OIIO_DASSERT_MSG (arraylen >= 0, "Called size() on TypeDesc "
207  "of array with unspecified length (%d)", arraylen);
208  size_t a = (size_t) (arraylen > 0 ? arraylen : 1);
209  if (sizeof(size_t) > sizeof(int)) {
210  // size_t has plenty of room for this multiplication
211  return a * elementsize();
212  } else {
213  // need overflow protection
214  unsigned long long s = (unsigned long long) a * elementsize();
215  const size_t toobig = std::numeric_limits<size_t>::max();
216  return s < toobig ? (size_t)s : toobig;
217  }
218  }
219 
220  /// Return the type of one element, i.e., strip out the array-ness.
221  ///
223  TypeDesc t (*this); t.arraylen = 0; return t;
224  }
225 
226  /// Return the size, in bytes, of one element of this type (that is,
227  /// ignoring whether it's an array).
228  OIIO_HOSTDEVICE size_t elementsize () const noexcept { return aggregate * basesize(); }
229 
230  /// Return just the underlying C scalar type, i.e., strip out the
231  /// array-ness and the aggregateness.
232  OIIO_HOSTDEVICE constexpr TypeDesc scalartype() const { return TypeDesc(BASETYPE(basetype)); }
233 
234  /// Return the base type size, i.e., stripped of both array-ness
235  /// and aggregateness.
236  size_t basesize () const noexcept;
237 
238  /// True if it's a floating-point type (versus a fundamentally
239  /// integral type or something else like a string).
240  bool is_floating_point () const noexcept;
241 
242  /// True if it's a signed type that allows for negative values.
243  bool is_signed () const noexcept;
244 
245  /// Shortcut: is it UNKNOWN?
246  OIIO_HOSTDEVICE constexpr bool is_unknown () const noexcept { return (basetype == UNKNOWN); }
247 
248  /// if (typedesc) is the same as asking whether it's not UNKNOWN.
249  OIIO_HOSTDEVICE constexpr operator bool () const noexcept { return (basetype != UNKNOWN); }
250 
251  /// Set *this to the type described in the string. Return the
252  /// length of the part of the string that describes the type. If
253  /// no valid type could be assembled, return 0 and do not modify
254  /// *this.
255  size_t fromstring (string_view typestring);
256 
257  /// Compare two TypeDesc values for equality.
258  ///
259  OIIO_HOSTDEVICE constexpr bool operator== (const TypeDesc &t) const noexcept {
260  return basetype == t.basetype && aggregate == t.aggregate &&
261  vecsemantics == t.vecsemantics && arraylen == t.arraylen;
262  }
263 
264  /// Compare two TypeDesc values for inequality.
265  ///
266  OIIO_HOSTDEVICE constexpr bool operator!= (const TypeDesc &t) const noexcept { return ! (*this == t); }
267 
268  /// Compare a TypeDesc to a basetype (it's the same if it has the
269  /// same base type and is not an aggregate or an array).
270  OIIO_HOSTDEVICE friend constexpr bool operator== (const TypeDesc &t, BASETYPE b) noexcept {
271  return (BASETYPE)t.basetype == b && (AGGREGATE)t.aggregate == SCALAR && !t.is_array();
272  }
273  OIIO_HOSTDEVICE friend constexpr bool operator== (BASETYPE b, const TypeDesc &t) noexcept {
274  return (BASETYPE)t.basetype == b && (AGGREGATE)t.aggregate == SCALAR && !t.is_array();
275  }
276 
277  /// Compare a TypeDesc to a basetype (it's the same if it has the
278  /// same base type and is not an aggregate or an array).
279  OIIO_HOSTDEVICE friend constexpr bool operator!= (const TypeDesc &t, BASETYPE b) noexcept {
280  return (BASETYPE)t.basetype != b || (AGGREGATE)t.aggregate != SCALAR || t.is_array();
281  }
282  OIIO_HOSTDEVICE friend constexpr bool operator!= (BASETYPE b, const TypeDesc &t) noexcept {
283  return (BASETYPE)t.basetype != b || (AGGREGATE)t.aggregate != SCALAR || t.is_array();
284  }
285 
286  /// TypeDesc's are equivalent if they are equal, or if their only
287  /// inequality is differing vector semantics.
288  OIIO_HOSTDEVICE friend constexpr bool equivalent (const TypeDesc &a, const TypeDesc &b) noexcept {
289  return a.basetype == b.basetype && a.aggregate == b.aggregate &&
290  (a.arraylen == b.arraylen || (a.is_unsized_array() && b.is_sized_array())
291  || (a.is_sized_array() && b.is_unsized_array()));
292  }
293  /// Member version of equivalent
294  OIIO_HOSTDEVICE constexpr bool equivalent (const TypeDesc &b) const noexcept {
295  return this->basetype == b.basetype && this->aggregate == b.aggregate &&
296  (this->arraylen == b.arraylen || (this->is_unsized_array() && b.is_sized_array())
297  || (this->is_sized_array() && b.is_unsized_array()));
298  }
299 
300  /// Is this a 2-vector aggregate (of the given type, float by default)?
301  OIIO_HOSTDEVICE constexpr bool is_vec2 (BASETYPE b=FLOAT) const noexcept {
302  return this->aggregate == VEC2 && this->basetype == b && !is_array();
303  }
304 
305  /// Is this a 3-vector aggregate (of the given type, float by default)?
306  OIIO_HOSTDEVICE constexpr bool is_vec3 (BASETYPE b=FLOAT) const noexcept {
307  return this->aggregate == VEC3 && this->basetype == b && !is_array();
308  }
309 
310  /// Is this a 4-vector aggregate (of the given type, float by default)?
311  OIIO_HOSTDEVICE constexpr bool is_vec4 (BASETYPE b=FLOAT) const noexcept {
312  return this->aggregate == VEC4 && this->basetype == b && !is_array();
313  }
314 
315  /// Is this an array of aggregates that represents a 2D bounding box?
316  OIIO_HOSTDEVICE constexpr bool is_box2 (BASETYPE b=FLOAT) const noexcept {
317  return this->aggregate == VEC2 && this->basetype == b && arraylen == 2
318  && this->vecsemantics == BOX;
319  }
320 
321  /// Is this an array of aggregates that represents a 3D bounding box?
322  OIIO_HOSTDEVICE constexpr bool is_box3 (BASETYPE b=FLOAT) const noexcept {
323  return this->aggregate == VEC3 && this->basetype == b && arraylen == 2
324  && this->vecsemantics == BOX;
325  }
326 
327  /// Demote the type to a non-array
328  ///
329  OIIO_HOSTDEVICE void unarray (void) noexcept { arraylen = 0; }
330 
331  /// Test for lexicographic 'less', comes in handy for lots of STL
332  /// containers and algorithms.
333  bool operator< (const TypeDesc &x) const noexcept;
334 
335  /// Given base data types of a and b, return a basetype that is a best
336  /// guess for one that can handle both without any loss of range or
337  /// precision.
338  static BASETYPE basetype_merge(TypeDesc a, TypeDesc b);
339 
340  // DEPRECATED(1.8): These static const member functions were mildly
341  // problematic because they required external linkage (and possibly
342  // even static initialization order fiasco) and were a memory reference
343  // that incurred some performance penalty and inability to optimize.
344  // Please instead use the out-of-class constexpr versions below. We
345  // will eventually remove these.
346 #ifndef OIIO_DOXYGEN
347  static const TypeDesc TypeFloat;
348  static const TypeDesc TypeColor;
349  static const TypeDesc TypeString;
350  static const TypeDesc TypeInt;
351  static const TypeDesc TypeHalf;
352  static const TypeDesc TypePoint;
353  static const TypeDesc TypeVector;
354  static const TypeDesc TypeNormal;
355  static const TypeDesc TypeMatrix;
356  static const TypeDesc TypeMatrix33;
357  static const TypeDesc TypeMatrix44;
358  static const TypeDesc TypeTimeCode;
359  static const TypeDesc TypeKeyCode;
360  static const TypeDesc TypeFloat4;
361  static const TypeDesc TypeRational;
362 #endif
363 };
364 
365 // Validate that TypeDesc can be used directly as POD in a C interface.
366 static_assert(std::is_default_constructible<TypeDesc>(), "TypeDesc is not default constructable.");
367 static_assert(std::is_trivially_copyable<TypeDesc>(), "TypeDesc is not trivially copyable.");
368 static_assert(std::is_trivially_destructible<TypeDesc>(), "TypeDesc is not trivially destructible.");
369 static_assert(std::is_trivially_move_constructible<TypeDesc>(), "TypeDesc is not move constructible.");
370 static_assert(std::is_trivially_copy_constructible<TypeDesc>(), "TypeDesc is not copy constructible.");
371 static_assert(std::is_trivially_move_assignable<TypeDesc>(), "TypeDesc is not move assignable.");
372 
373 // Static values for commonly used types. Because these are constexpr,
374 // they should incur no runtime construction cost and should optimize nicely
375 // in various ways.
376 OIIO_INLINE_CONSTEXPR TypeDesc TypeUnknown (TypeDesc::UNKNOWN);
377 OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat (TypeDesc::FLOAT);
384 OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix = TypeMatrix44;
385 OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat2 (TypeDesc::FLOAT, TypeDesc::VEC2);
387 OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat4 (TypeDesc::FLOAT, TypeDesc::VEC4);
388 OIIO_INLINE_CONSTEXPR TypeDesc TypeVector4 = TypeFloat4;
389 OIIO_INLINE_CONSTEXPR TypeDesc TypeString (TypeDesc::STRING);
390 OIIO_INLINE_CONSTEXPR TypeDesc TypeInt (TypeDesc::INT);
391 OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt (TypeDesc::UINT);
392 OIIO_INLINE_CONSTEXPR TypeDesc TypeInt32 (TypeDesc::INT);
393 OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt32 (TypeDesc::UINT);
394 OIIO_INLINE_CONSTEXPR TypeDesc TypeInt16 (TypeDesc::INT16);
395 OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt16 (TypeDesc::UINT16);
396 OIIO_INLINE_CONSTEXPR TypeDesc TypeInt8 (TypeDesc::INT8);
397 OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt8 (TypeDesc::UINT8);
398 OIIO_INLINE_CONSTEXPR TypeDesc TypeInt64 (TypeDesc::INT64);
399 OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt64 (TypeDesc::UINT64);
400 OIIO_INLINE_CONSTEXPR TypeDesc TypeVector2i(TypeDesc::INT, TypeDesc::VEC2);
401 OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2(TypeDesc::FLOAT, TypeDesc::VEC2, TypeDesc::BOX, 2);
402 OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3(TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::BOX, 2);
403 OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2i(TypeDesc::INT, TypeDesc::VEC2, TypeDesc::BOX, 2);
404 OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3i(TypeDesc::INT, TypeDesc::VEC3, TypeDesc::BOX, 2);
405 OIIO_INLINE_CONSTEXPR TypeDesc TypeHalf (TypeDesc::HALF);
409 OIIO_INLINE_CONSTEXPR TypeDesc TypePointer(TypeDesc::PTR);
410 OIIO_INLINE_CONSTEXPR TypeDesc TypeUstringhash(TypeDesc::USTRINGHASH);
411 
412 
413 
414 // DEPRECATED(2.1)
416 std::string tostring (TypeDesc type, const void *data,
417  const char *float_fmt, // E.g. "%g"
418  const char *string_fmt = "%s", // E.g. "\"%s\""
419  const char aggregate_delim[2] = "()", // Both sides of vector
420  const char *aggregate_sep = ",", // E.g. ", "
421  const char array_delim[2] = "{}", // Both sides of array
422  const char *array_sep = ","); // E.g. "; "
423 
424 
425 
426 /// A template mechanism for getting the a base type from C type
427 ///
428 template<typename T> struct BaseTypeFromC {};
429 template<> struct BaseTypeFromC<unsigned char> { static const TypeDesc::BASETYPE value = TypeDesc::UINT8; };
430 template<> struct BaseTypeFromC<char> { static const TypeDesc::BASETYPE value = TypeDesc::INT8; };
431 template<> struct BaseTypeFromC<unsigned short> { static const TypeDesc::BASETYPE value = TypeDesc::UINT16; };
432 template<> struct BaseTypeFromC<short> { static const TypeDesc::BASETYPE value = TypeDesc::INT16; };
433 template<> struct BaseTypeFromC<unsigned int> { static const TypeDesc::BASETYPE value = TypeDesc::UINT; };
434 template<> struct BaseTypeFromC<int> { static const TypeDesc::BASETYPE value = TypeDesc::INT; };
435 template<> struct BaseTypeFromC<unsigned long long> { static const TypeDesc::BASETYPE value = TypeDesc::UINT64; };
436 template<> struct BaseTypeFromC<long long> { static const TypeDesc::BASETYPE value = TypeDesc::INT64; };
437 #if defined(_HALF_H_) || defined(IMATH_HALF_H_)
438 template<> struct BaseTypeFromC<half> { static const TypeDesc::BASETYPE value = TypeDesc::HALF; };
439 #endif
440 template<> struct BaseTypeFromC<float> { static const TypeDesc::BASETYPE value = TypeDesc::FLOAT; };
441 template<> struct BaseTypeFromC<double> { static const TypeDesc::BASETYPE value = TypeDesc::DOUBLE; };
442 template<> struct BaseTypeFromC<const char*> { static const TypeDesc::BASETYPE value = TypeDesc::STRING; };
443 template<> struct BaseTypeFromC<char*> { static const TypeDesc::BASETYPE value = TypeDesc::STRING; };
444 template<> struct BaseTypeFromC<std::string> { static const TypeDesc::BASETYPE value = TypeDesc::STRING; };
445 template<> struct BaseTypeFromC<string_view> { static const TypeDesc::BASETYPE value = TypeDesc::STRING; };
446 class ustring;
447 template<> struct BaseTypeFromC<ustring> { static const TypeDesc::BASETYPE value = TypeDesc::STRING; };
448 template<size_t S> struct BaseTypeFromC<char[S]> { static const TypeDesc::BASETYPE value = TypeDesc::STRING; };
449 template<size_t S> struct BaseTypeFromC<const char[S]> { static const TypeDesc::BASETYPE value = TypeDesc::STRING; };
450 
451 
452 /// A template mechanism for getting the TypeDesc from a C type.
453 /// The default for simple types is just the TypeDesc based on BaseTypeFromC.
454 /// But we can specialize more complex types.
455 template<typename T> struct TypeDescFromC { static const constexpr TypeDesc value() { return TypeDesc(BaseTypeFromC<T>::value); } };
456 template<> struct TypeDescFromC<int32_t> { static const constexpr TypeDesc value() { return TypeDesc::INT32; } };
457 template<> struct TypeDescFromC<uint32_t> { static const constexpr TypeDesc value() { return TypeDesc::UINT32; } };
458 template<> struct TypeDescFromC<int16_t> { static const constexpr TypeDesc value() { return TypeDesc::INT16; } };
459 template<> struct TypeDescFromC<uint16_t> { static const constexpr TypeDesc value() { return TypeDesc::UINT16; } };
460 template<> struct TypeDescFromC<int8_t> { static const constexpr TypeDesc value() { return TypeDesc::INT8; } };
461 template<> struct TypeDescFromC<uint8_t> { static const constexpr TypeDesc value() { return TypeDesc::UINT8; } };
462 template<> struct TypeDescFromC<float> { static const constexpr TypeDesc value() { return TypeDesc::FLOAT; } };
463 #if defined(_HALF_H_) || defined(IMATH_HALF_H_)
464 template<> struct TypeDescFromC<half> { static const constexpr TypeDesc value() { return TypeDesc::HALF; } };
465 #endif
466 template<> struct TypeDescFromC<double> { static const constexpr TypeDesc value() { return TypeDesc::DOUBLE; } };
467 template<size_t S> struct TypeDescFromC<char[S]> { static const constexpr TypeDesc value() { return TypeDesc::STRING; } };
468 template<size_t S> struct TypeDescFromC<const char[S]> { static const constexpr TypeDesc value() { return TypeDesc::STRING; } };
469 #ifdef INCLUDED_IMATHVEC_H
470 template<> struct TypeDescFromC<Imath::V3f> { static const constexpr TypeDesc value() { return TypeVector; } };
471 template<> struct TypeDescFromC<Imath::V2f> { static const constexpr TypeDesc value() { return TypeVector2; } };
472 template<> struct TypeDescFromC<Imath::V4f> { static const constexpr TypeDesc value() { return TypeVector4; } };
473 template<> struct TypeDescFromC<Imath::V2i> { static const constexpr TypeDesc value() { return TypeVector2i; } };
474 #endif
475 #ifdef INCLUDED_IMATHCOLOR_H
476 template<> struct TypeDescFromC<Imath::Color3f> { static const constexpr TypeDesc value() { return TypeColor; } };
477 #endif
478 #ifdef INCLUDED_IMATHMATRIX_H
479 template<> struct TypeDescFromC<Imath::M33f> { static const constexpr TypeDesc value() { return TypeMatrix33; } };
480 template<> struct TypeDescFromC<Imath::M44f> { static const constexpr TypeDesc value() { return TypeMatrix44; } };
481 template<> struct TypeDescFromC<Imath::M33d> { static const constexpr TypeDesc value() { return TypeDesc(TypeDesc::DOUBLE, TypeDesc::MATRIX33); } };
482 template<> struct TypeDescFromC<Imath::M44d> { static const constexpr TypeDesc value() { return TypeDesc(TypeDesc::DOUBLE, TypeDesc::MATRIX44); } };
483 #endif
484 #ifdef INCLUDED_IMATHBOX_H
485 template<> struct TypeDescFromC<Imath::Box2f> { static const constexpr TypeDesc value() { return TypeBox2; } };
486 template<> struct TypeDescFromC<Imath::Box2i> { static const constexpr TypeDesc value() { return TypeBox2i; } };
487 template<> struct TypeDescFromC<Imath::Box3f> { static const constexpr TypeDesc value() { return TypeBox3; } };
488 template<> struct TypeDescFromC<Imath::Box3i> { static const constexpr TypeDesc value() { return TypeBox3i; } };
489 #endif
490 
491 
492 class ustringhash; // forward declaration
493 
494 
495 
496 /// A template mechanism for getting C type of TypeDesc::BASETYPE.
497 ///
498 template<int b> struct CType {};
499 template<> struct CType<(int)TypeDesc::UINT8> { typedef unsigned char type; };
500 template<> struct CType<(int)TypeDesc::INT8> { typedef char type; };
501 template<> struct CType<(int)TypeDesc::UINT16> { typedef unsigned short type; };
502 template<> struct CType<(int)TypeDesc::INT16> { typedef short type; };
503 template<> struct CType<(int)TypeDesc::UINT> { typedef unsigned int type; };
504 template<> struct CType<(int)TypeDesc::INT> { typedef int type; };
505 template<> struct CType<(int)TypeDesc::UINT64> { typedef unsigned long long type; };
506 template<> struct CType<(int)TypeDesc::INT64> { typedef long long type; };
507 #if defined(_HALF_H_) || defined(IMATH_HALF_H_)
508 template<> struct CType<(int)TypeDesc::HALF> { typedef half type; };
509 #endif
510 template<> struct CType<(int)TypeDesc::FLOAT> { typedef float type; };
511 template<> struct CType<(int)TypeDesc::DOUBLE> { typedef double type; };
512 template<> struct CType<(int)TypeDesc::USTRINGHASH> { typedef ustringhash type; };
513 
514 
515 
516 /// Helper class for tostring() that contains a whole bunch of parameters
517 /// that control exactly how all the data types that can be described as
518 /// TypeDesc ought to be formatted as a string. Uses printf-like
519 /// conventions. This will someday be deprecated.
521  // Printf-like formatting specs for int, float, string, pointer data.
522  const char *int_fmt = "%d";
523  const char *float_fmt = "%g";
524  const char *string_fmt = "\"%s\"";
525  const char *ptr_fmt = "%p";
526  // Aggregates are multi-part types, like VEC3, etc. How do we mark the
527  // start, separation between elements, and end?
528  const char *aggregate_begin = "(";
529  const char *aggregate_end = ")";
530  const char *aggregate_sep = ",";
531  // For arrays, how do we mark the start, separation between elements,
532  // and end?
533  const char *array_begin = "{";
534  const char *array_end = "}";
535  const char *array_sep = ",";
536  // Miscellaneous control flags, OR the enum values together.
537  enum Flags { None=0, escape_strings=1, quote_single_string=2 };
538  int flags = escape_strings;
539  // Reserved space for future expansion without breaking the ABI.
540  const char *uint_fmt = "%u";
541  const char *reserved2 = "";
542  const char *reserved3 = "";
543  bool use_sprintf = true;
544 
545  enum Notation { STDFORMAT };
546 
547  tostring_formatting() = default;
548  tostring_formatting(const char *int_fmt, const char *float_fmt = "%g",
549  const char *string_fmt = "\"%s\"", const char *ptr_fmt = "%p",
550  const char *aggregate_begin = "(", const char *aggregate_end = ")",
551  const char *aggregate_sep = ",", const char *array_begin = "{",
552  const char *array_end = "}", const char *array_sep = ",",
553  int flags = escape_strings,
554  const char *uint_fmt = "%u");
555 
556  // Alternative ctr for std::format notation. You must pass STDFORMAT
557  // as the first argument.
558  tostring_formatting(Notation notation,
559  const char *int_fmt = "{}", const char *uint_fmt = "{}",
560  const char *float_fmt = "{}",
561  const char *string_fmt = "\"{}\"", const char *ptr_fmt = "{}",
562  const char *aggregate_begin = "(", const char *aggregate_end = ")",
563  const char *aggregate_sep = ",", const char *array_begin = "{",
564  const char *array_end = "}", const char *array_sep = ",",
565  int flags = escape_strings);
566 };
567 
568 
569 
570 /// Return a string containing the data values formatted according
571 /// to the type and the optional formatting control arguments. Will be
572 /// deprecated someday as printf formatting falls out of favor.
573 OIIO_UTIL_API std::string
574 tostring(TypeDesc type, const void* data, const tostring_formatting& fmt = {});
575 
576 
577 
578 /// Given data pointed to by src and described by srctype, copy it to the
579 /// memory pointed to by dst and described by dsttype, and return true if a
580 /// conversion is possible, false if it is not. If the types are equivalent,
581 /// this is a straightforward memory copy. If the types differ, there are
582 /// several non-equivalent type conversions that will nonetheless succeed:
583 /// * If dsttype is a string (and therefore dst points to a ustring or a
584 /// `char*`): it will always succeed, producing a string akin to calling
585 /// `tostring()`.
586 /// * If dsttype is int32 or uint32: other integer types will do their best
587 /// (caveat emptor if you mix signed/unsigned). Also a source string will
588 /// convert to int if and only if its characters form a valid integer.
589 /// * If dsttype is float: inteegers and other float types will do
590 /// their best conversion; strings will convert if and only if their
591 /// characters form a valid float number.
592 OIIO_UTIL_API bool
593 convert_type(TypeDesc srctype, const void* src,
594  TypeDesc dsttype, void* dst, int n = 1);
595 
596 
598 
599 
600 
601 // Supply a fmtlib compatible custom formatter for TypeDesc.
602 #if FMT_VERSION >= 100000
604 template<> struct formatter<OIIO::TypeDesc> : ostream_formatter {};
606 #else
608 template <>
609 struct formatter<OIIO::TypeDesc> {
610  // Parses format specification
611  // C++14: constexpr auto parse(format_parse_context& ctx) const {
612  auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) // c++11
613  {
614  // Get the presentation type, if any. Required to be 's'.
615  auto it = ctx.begin(), end = ctx.end();
616  if (it != end && (*it == 's')) ++it;
617  // Check if reached the end of the range:
618  if (it != end && *it != '}')
619  throw format_error("invalid format");
620  // Return an iterator past the end of the parsed range:
621  return it;
622  }
623 
624  template <typename FormatContext>
625  auto format(const OIIO::TypeDesc& t, FormatContext& ctx) OIIO_FMT_CUSTOM_FORMATTER_CONST
626  {
627  // C++14: auto format(const OIIO::TypeDesc& p, FormatContext& ctx) const {
628  // ctx.out() is an output iterator to write to.
629  return format_to(ctx.out(), "{}", t.c_str());
630  }
631 };
633 #endif
static const constexpr TypeDesc value()
Definition: typedesc.h:458
type
Definition: core.h:556
OIIO_HOSTDEVICE constexpr bool is_box3(BASETYPE b=FLOAT) const noexcept
Is this an array of aggregates that represents a 3D bounding box?
Definition: typedesc.h:322
32-bit IEEE floating point values, (C/C++ float).
Definition: typedesc.h:82
#define OIIO_CONSTEXPR14
Definition: platform.h:95
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
unsigned char reserved
Reserved for future expansion.
Definition: typedesc.h:128
static const TypeDesc TypeTimeCode
Definition: typedesc.h:358
GLbitfield flags
Definition: glcorearb.h:1596
OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix44(TypeDesc::FLOAT, TypeDesc::MATRIX44)
64-bit IEEE floating point values, (C/C++ double).
Definition: typedesc.h:83
16-bit IEEE floating point values (OpenEXR half).
Definition: typedesc.h:81
static const TypeDesc TypeString
Definition: typedesc.h:349
OIIO_HOSTDEVICE constexpr bool is_vec4(BASETYPE b=FLOAT) const noexcept
Is this a 4-vector aggregate (of the given type, float by default)?
Definition: typedesc.h:311
static const TypeDesc TypeFloat4
Definition: typedesc.h:360
OIIO_HOSTDEVICE constexpr bool equivalent(const TypeDesc &b) const noexcept
Member version of equivalent.
Definition: typedesc.h:294
unsigned char aggregate
What kind of AGGREGATE is it?
Definition: typedesc.h:126
OIIO_INLINE_CONSTEXPR TypeDesc TypeUstringhash(TypeDesc::USTRINGHASH)
OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix
Definition: typedesc.h:384
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt64(TypeDesc::UINT64)
HALF
Definition: ImfPixelType.h:23
Definition: ImathVec.h:32
imath_half_bits_t half
if we're in a C-only context, alias the half bits type to half
Definition: half.h:266
FLOAT
Definition: ImfPixelType.h:24
static const constexpr TypeDesc value()
Definition: typedesc.h:460
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLfloat * value
Definition: glcorearb.h:824
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt32(TypeDesc::INT)
OIIO_HOSTDEVICE constexpr TypeDesc(BASETYPE btype=UNKNOWN, AGGREGATE agg=SCALAR, VECSEMANTICS semantics=NOSEMANTICS, int arraylen=0) noexcept
Definition: typedesc.h:133
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt32(TypeDesc::UINT)
OIIO_HOSTDEVICE constexpr TypeDesc scalartype() const
Definition: typedesc.h:232
Vector: a spatial direction.
Definition: typedesc.h:115
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector2i(TypeDesc::INT, TypeDesc::VEC2)
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
unknown type
Definition: typedesc.h:57
GLdouble s
Definition: glad.h:3009
bool_constant< std::is_floating_point< T >::value||is_float128< T >::value > is_floating_point
Definition: format.h:862
static const constexpr TypeDesc value()
Definition: typedesc.h:467
9 values representing a 3x3 matrix.
Definition: typedesc.h:103
static const TypeDesc TypePoint
Definition: typedesc.h:352
const char * c_str() const
OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix33(TypeDesc::FLOAT, TypeDesc::MATRIX33)
OIIO_UTIL_API std::string tostring(TypeDesc type, const void *data, const char *float_fmt, const char *string_fmt="%s", const char aggregate_delim[2]="()", const char *aggregate_sep=",", const char array_delim[2]="{}", const char *array_sep=",")
int arraylen
Array length, 0 = not array, -1 = unsized.
Definition: typedesc.h:129
String-related utilities, all in namespace Strutil.
The hash of a ustring.
Definition: typedesc.h:86
#define OIIO_UTIL_API
Definition: export.h:71
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2(TypeDesc::FLOAT, TypeDesc::VEC2, TypeDesc::BOX, 2)
OutGridT const XformOp bool bool
A VEC2 representing a rational number val[0] / val[1]
Definition: typedesc.h:121
#define FMT_END_NAMESPACE
Definition: core.h:179
OIIO_INLINE_CONSTEXPR TypeDesc TypePoint(TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::POINT)
OIIO_HOSTDEVICE friend constexpr bool equivalent(const TypeDesc &a, const TypeDesc &b) noexcept
Definition: typedesc.h:288
OIIO_INLINE_CONSTEXPR TypeDesc TypeRational(TypeDesc::INT, TypeDesc::VEC2, TypeDesc::RATIONAL)
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt(TypeDesc::INT)
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 size_t numelements() const noexcept
Definition: typedesc.h:180
auto parse(format_parse_context &ctx) -> decltype(ctx.begin())
Definition: typedesc.h:612
OIIO_INLINE_CONSTEXPR TypeDesc TypeUnknown(TypeDesc::UNKNOWN)
std::ostream & operator<<(std::ostream &ostr, const DataType &a)
Definition: DataType.h:133
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt(TypeDesc::UINT)
static const TypeDesc TypeHalf
Definition: typedesc.h:351
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
static const TypeDesc TypeKeyCode
Definition: typedesc.h:359
OIIO_HOSTDEVICE constexpr bool is_vec2(BASETYPE b=FLOAT) const noexcept
Is this a 2-vector aggregate (of the given type, float by default)?
Definition: typedesc.h:301
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 size_t basevalues() const noexcept
Definition: typedesc.h:189
16 values representing a 4x4 matrix.
Definition: typedesc.h:104
GLdouble n
Definition: glcorearb.h:2008
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt8(TypeDesc::INT8)
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
OIIO_HOSTDEVICE void unarray(void) noexcept
Definition: typedesc.h:329
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat4(TypeDesc::FLOAT, TypeDesc::VEC4)
static const TypeDesc TypeNormal
Definition: typedesc.h:354
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt16(TypeDesc::INT16)
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat(TypeDesc::FLOAT)
static const TypeDesc TypeMatrix44
Definition: typedesc.h:357
#define OIIO_DASSERT_MSG
Definition: dassert.h:56
OIIO_HOSTDEVICE constexpr bool is_sized_array() const noexcept
Does this TypeDesc describe an array, whose length is specified?
Definition: typedesc.h:201
static const constexpr TypeDesc value()
Definition: typedesc.h:456
signed 32-bit int values (C/C++ int).
Definition: typedesc.h:73
static const TypeDesc TypeFloat
Definition: typedesc.h:347
GLuint GLuint end
Definition: glcorearb.h:475
2 values representing a 2D vector.
Definition: typedesc.h:100
static const constexpr TypeDesc value()
Definition: typedesc.h:466
3 values representing a 3D vector.
Definition: typedesc.h:101
OIIO_HOSTDEVICE constexpr bool is_vec3(BASETYPE b=FLOAT) const noexcept
Is this a 3-vector aggregate (of the given type, float by default)?
Definition: typedesc.h:306
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
#define OIIO_HOSTDEVICE
Definition: platform.h:529
OIIO_INLINE_CONSTEXPR TypeDesc TypeTimeCode(TypeDesc::UINT, TypeDesc::SCALAR, TypeDesc::TIMECODE, 2)
OIIO_HOSTDEVICE constexpr bool is_unsized_array() const noexcept
Definition: typedesc.h:198
A pointer value.
Definition: typedesc.h:85
OIIO_HOSTDEVICE size_t size() const noexcept
Definition: typedesc.h:205
OIIO_INLINE_CONSTEXPR TypeDesc TypeString(TypeDesc::STRING)
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
OIIO_UTIL_API bool convert_type(TypeDesc srctype, const void *src, TypeDesc dsttype, void *dst, int n=1)
4 values representing a 4D vector.
Definition: typedesc.h:102
GLdouble t
Definition: glad.h:2397
Definition: oidn.hpp:29
static const TypeDesc TypeVector
Definition: typedesc.h:353
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2i(TypeDesc::INT, TypeDesc::VEC2, TypeDesc::BOX, 2)
Character string.
Definition: typedesc.h:84
Normal: a surface normal.
Definition: typedesc.h:116
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector(TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::VECTOR)
auto format(const OIIO::TypeDesc &t, FormatContext &ctx) OIIO_FMT_CUSTOM_FORMATTER_CONST
Definition: typedesc.h:625
GLenum GLenum dst
Definition: glcorearb.h:1793
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
Definition: format.h:818
#define SCALAR(T)
Simplify checking for scalar types.
Definition: GA_Handle.h:511
IMATH_NAMESPACE::V2f IMATH_NAMESPACE::Box2i std::string this attribute is obsolete as of OpenEXR v3 float
OIIO_INLINE_CONSTEXPR TypeDesc TypeColor(TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::COLOR)
static const TypeDesc TypeMatrix
Definition: typedesc.h:355
static const TypeDesc TypeColor
Definition: typedesc.h:348
#define OIIO_FMT_CUSTOM_FORMATTER_CONST
Definition: fmt.h:76
Definition: ImathVec.h:31
static const TypeDesc TypeMatrix33
Definition: typedesc.h:356
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3(TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::BOX, 2)
OIIO_INLINE_CONSTEXPR TypeDesc TypeHalf(TypeDesc::HALF)
Point: a spatial location.
Definition: typedesc.h:114
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt8(TypeDesc::UINT8)
OIIO_INLINE_CONSTEXPR TypeDesc TypeNormal(TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::NORMAL)
unsigned char basetype
C data type at the heart of our type.
Definition: typedesc.h:125
static const constexpr TypeDesc value()
Definition: typedesc.h:461
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
void/no type
Definition: typedesc.h:58
static const constexpr TypeDesc value()
Definition: typedesc.h:459
FMT_INLINE auto format_to(OutputIt out, format_string< T...> fmt, T &&...args) -> OutputIt
Definition: core.h:2843
static const constexpr TypeDesc value()
Definition: typedesc.h:457
static const constexpr TypeDesc value()
Definition: typedesc.h:455
unsigned char vecsemantics
Hint: What does the aggregate represent?
Definition: typedesc.h:127
OIIO_UTIL_API const char * c_str(string_view str)
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt64(TypeDesc::INT64)
Definition: ImathBox.h:37
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector4
Definition: typedesc.h:388
OIIO_HOSTDEVICE constexpr TypeDesc(BASETYPE btype, AGGREGATE agg, int arraylen) noexcept
Definition: typedesc.h:148
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3i(TypeDesc::INT, TypeDesc::VEC3, TypeDesc::BOX, 2)
#define FMT_BEGIN_NAMESPACE
Definition: core.h:176
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
VECSEMANTICS
Definition: typedesc.h:110
#define OIIO_NAMESPACE_END
Definition: oiioversion.h:127
OIIO_HOSTDEVICE constexpr TypeDesc(BASETYPE btype, int arraylen) noexcept
Construct an array of a non-aggregate BASETYPE.
Definition: typedesc.h:143
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector2(TypeDesc::FLOAT, TypeDesc::VEC2, TypeDesc::VECTOR)
Definition: ImathVec.h:33
unsigned long long type
Definition: typedesc.h:505
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 TypeDesc elementtype() const noexcept
Definition: typedesc.h:222
OIIO_INLINE_CONSTEXPR TypeDesc TypeKeyCode(TypeDesc::INT, TypeDesc::SCALAR, TypeDesc::KEYCODE, 7)
A VEC2[2] or VEC3[2] that represents a 2D or 3D bounds (min/max)
Definition: typedesc.h:122
static const TypeDesc TypeInt
Definition: typedesc.h:350
OIIO_HOSTDEVICE constexpr bool is_array() const noexcept
Does this TypeDesc describe an array?
Definition: typedesc.h:194
OIIO_HOSTDEVICE size_t elementsize() const noexcept
Definition: typedesc.h:228
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat2(TypeDesc::FLOAT, TypeDesc::VEC2)
static const constexpr TypeDesc value()
Definition: typedesc.h:462
static const TypeDesc TypeRational
Definition: typedesc.h:361
OIIO_INLINE_CONSTEXPR TypeDesc TypePointer(TypeDesc::PTR)
OIIO_HOSTDEVICE constexpr bool is_box2(BASETYPE b=FLOAT) const noexcept
Is this an array of aggregates that represents a 2D bounding box?
Definition: typedesc.h:316
UINT
Definition: ImfPixelType.h:22
Definition: format.h:1821
32-bit unsigned int values (C/C++ unsigned int).
Definition: typedesc.h:71
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt16(TypeDesc::UINT16)
static const constexpr TypeDesc value()
Definition: typedesc.h:468
#define OIIO_NAMESPACE_BEGIN
Definition: oiioversion.h:126
GLenum src
Definition: glcorearb.h:1793