HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
typedesc.h File Reference
#include <cmath>
#include <cstddef>
#include <iostream>
#include <limits>
#include <OpenImageIO/dassert.h>
#include <OpenImageIO/export.h>
#include <OpenImageIO/oiioversion.h>
#include <OpenImageIO/string_view.h>
#include <OpenImageIO/strutil.h>
+ Include dependency graph for typedesc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TypeDesc
 
struct  BaseTypeFromC< T >
 
struct  BaseTypeFromC< unsigned char >
 
struct  BaseTypeFromC< char >
 
struct  BaseTypeFromC< unsigned short >
 
struct  BaseTypeFromC< short >
 
struct  BaseTypeFromC< unsigned int >
 
struct  BaseTypeFromC< int >
 
struct  BaseTypeFromC< unsigned long long >
 
struct  BaseTypeFromC< long long >
 
struct  BaseTypeFromC< float >
 
struct  BaseTypeFromC< double >
 
struct  BaseTypeFromC< const char * >
 
struct  BaseTypeFromC< char * >
 
struct  BaseTypeFromC< std::string >
 
struct  BaseTypeFromC< string_view >
 
struct  BaseTypeFromC< ustring >
 
struct  BaseTypeFromC< char[S]>
 
struct  BaseTypeFromC< const char[S]>
 
struct  TypeDescFromC< T >
 
struct  TypeDescFromC< int32_t >
 
struct  TypeDescFromC< uint32_t >
 
struct  TypeDescFromC< int16_t >
 
struct  TypeDescFromC< uint16_t >
 
struct  TypeDescFromC< int8_t >
 
struct  TypeDescFromC< uint8_t >
 
struct  TypeDescFromC< float >
 
struct  TypeDescFromC< double >
 
struct  TypeDescFromC< char[S]>
 
struct  TypeDescFromC< const char[S]>
 
struct  CType< b >
 
struct  CType<(int) TypeDesc::UINT8 >
 
struct  CType<(int) TypeDesc::INT8 >
 
struct  CType<(int) TypeDesc::UINT16 >
 
struct  CType<(int) TypeDesc::INT16 >
 
struct  CType<(int) TypeDesc::UINT >
 
struct  CType<(int) TypeDesc::INT >
 
struct  CType<(int) TypeDesc::UINT64 >
 
struct  CType<(int) TypeDesc::INT64 >
 
struct  CType<(int) TypeDesc::FLOAT >
 
struct  CType<(int) TypeDesc::DOUBLE >
 
struct  CType<(int) TypeDesc::USTRINGHASH >
 
struct  tostring_formatting
 
struct  formatter< OIIO::TypeDesc >
 

Macros

#define OIIO_TYPEDESC_VECTOR2   1
 

Functions

OIIO_INLINE_CONSTEXPR TypeDesc TypeUnknown (TypeDesc::UNKNOWN)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat (TypeDesc::FLOAT)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeColor (TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::COLOR)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypePoint (TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::POINT)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector (TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::VECTOR)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeNormal (TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::NORMAL)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix33 (TypeDesc::FLOAT, TypeDesc::MATRIX33)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix44 (TypeDesc::FLOAT, TypeDesc::MATRIX44)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat2 (TypeDesc::FLOAT, TypeDesc::VEC2)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector2 (TypeDesc::FLOAT, TypeDesc::VEC2, TypeDesc::VECTOR)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat4 (TypeDesc::FLOAT, TypeDesc::VEC4)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeString (TypeDesc::STRING)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt (TypeDesc::INT)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt (TypeDesc::UINT)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt32 (TypeDesc::INT)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt32 (TypeDesc::UINT)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt16 (TypeDesc::INT16)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt16 (TypeDesc::UINT16)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt8 (TypeDesc::INT8)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt8 (TypeDesc::UINT8)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt64 (TypeDesc::INT64)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt64 (TypeDesc::UINT64)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector2i (TypeDesc::INT, TypeDesc::VEC2)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2 (TypeDesc::FLOAT, TypeDesc::VEC2, TypeDesc::BOX, 2)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3 (TypeDesc::FLOAT, TypeDesc::VEC3, TypeDesc::BOX, 2)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2i (TypeDesc::INT, TypeDesc::VEC2, TypeDesc::BOX, 2)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3i (TypeDesc::INT, TypeDesc::VEC3, TypeDesc::BOX, 2)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeHalf (TypeDesc::HALF)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeTimeCode (TypeDesc::UINT, TypeDesc::SCALAR, TypeDesc::TIMECODE, 2)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeKeyCode (TypeDesc::INT, TypeDesc::SCALAR, TypeDesc::KEYCODE, 7)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeRational (TypeDesc::INT, TypeDesc::VEC2, TypeDesc::RATIONAL)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypePointer (TypeDesc::PTR)
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeUstringhash (TypeDesc::USTRINGHASH)
 
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=",")
 
OIIO_UTIL_API std::string tostring (TypeDesc type, const void *data, const tostring_formatting &fmt={})
 
OIIO_UTIL_API bool convert_type (TypeDesc srctype, const void *src, TypeDesc dsttype, void *dst, int n=1)
 

Variables

OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix = TypeMatrix44
 
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector4 = TypeFloat4
 

Detailed Description

The TypeDesc class is used to describe simple data types.

Definition in file typedesc.h.

Macro Definition Documentation

#define OIIO_TYPEDESC_VECTOR2   1

Definition at line 33 of file typedesc.h.

Function Documentation

OIIO_UTIL_API bool convert_type ( TypeDesc  srctype,
const void src,
TypeDesc  dsttype,
void dst,
int  n = 1 
)

Given data pointed to by src and described by srctype, copy it to the memory pointed to by dst and described by dsttype, and return true if a conversion is possible, false if it is not. If the types are equivalent, this is a straightforward memory copy. If the types differ, there are several non-equivalent type conversions that will nonetheless succeed:

  • If dsttype is a string (and therefore dst points to a ustring or a char*): it will always succeed, producing a string akin to calling tostring().
  • If dsttype is int32 or uint32: other integer types will do their best (caveat emptor if you mix signed/unsigned). Also a source string will convert to int if and only if its characters form a valid integer.
  • If dsttype is float: inteegers and other float types will do their best conversion; strings will convert if and only if their characters form a valid float number.
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 = "," 
)
OIIO_UTIL_API std::string tostring ( TypeDesc  type,
const void data,
const tostring_formatting fmt = {} 
)

Return a string containing the data values formatted according to the type and the optional formatting control arguments. Will be deprecated someday as printf formatting falls out of favor.

OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2 ( TypeDesc::FLOAT  ,
TypeDesc::VEC2  ,
TypeDesc::BOX  ,
 
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox2i ( TypeDesc::INT  ,
TypeDesc::VEC2  ,
TypeDesc::BOX  ,
 
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3 ( TypeDesc::FLOAT  ,
TypeDesc::VEC3  ,
TypeDesc::BOX  ,
 
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeBox3i ( TypeDesc::INT  ,
TypeDesc::VEC3  ,
TypeDesc::BOX  ,
 
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeColor ( TypeDesc::FLOAT  ,
TypeDesc::VEC3  ,
TypeDesc::COLOR   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat ( TypeDesc::FLOAT  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat2 ( TypeDesc::FLOAT  ,
TypeDesc::VEC2   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeFloat4 ( TypeDesc::FLOAT  ,
TypeDesc::VEC4   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeHalf ( TypeDesc::HALF  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt ( TypeDesc::INT  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt16 ( TypeDesc::INT16  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt32 ( TypeDesc::INT  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt64 ( TypeDesc::INT64  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeInt8 ( TypeDesc::INT8  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeKeyCode ( TypeDesc::INT  ,
TypeDesc::SCALAR  ,
TypeDesc::KEYCODE  ,
 
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix33 ( TypeDesc::FLOAT  ,
TypeDesc::MATRIX33   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix44 ( TypeDesc::FLOAT  ,
TypeDesc::MATRIX44   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeNormal ( TypeDesc::FLOAT  ,
TypeDesc::VEC3  ,
TypeDesc::NORMAL   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypePoint ( TypeDesc::FLOAT  ,
TypeDesc::VEC3  ,
TypeDesc::POINT   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypePointer ( TypeDesc::PTR  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeRational ( TypeDesc::INT  ,
TypeDesc::VEC2  ,
TypeDesc::RATIONAL   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeString ( TypeDesc::STRING  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeTimeCode ( TypeDesc::UINT  ,
TypeDesc::SCALAR  ,
TypeDesc::TIMECODE  ,
 
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt ( TypeDesc::UINT  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt16 ( TypeDesc::UINT16  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt32 ( TypeDesc::UINT  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt64 ( TypeDesc::UINT64  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeUInt8 ( TypeDesc::UINT8  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeUnknown ( TypeDesc::UNKNOWN  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeUstringhash ( TypeDesc::USTRINGHASH  )
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector ( TypeDesc::FLOAT  ,
TypeDesc::VEC3  ,
TypeDesc::VECTOR   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector2 ( TypeDesc::FLOAT  ,
TypeDesc::VEC2  ,
TypeDesc::VECTOR   
)
OIIO_INLINE_CONSTEXPR TypeDesc TypeVector2i ( TypeDesc::INT  ,
TypeDesc::VEC2   
)

Variable Documentation

OIIO_INLINE_CONSTEXPR TypeDesc TypeMatrix = TypeMatrix44

Definition at line 384 of file typedesc.h.

OIIO_INLINE_CONSTEXPR TypeDesc TypeVector4 = TypeFloat4

Definition at line 388 of file typedesc.h.