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.


struct  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< int >
struct  TypeDescFromC< float >
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  tostring_formatting
struct  formatter< OIIO::TypeDesc >




OIIO_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_API std::string tostring (TypeDesc type, const void *data, const tostring_formatting &fmt={})
OIIO_API bool convert_type (TypeDesc srctype, const void *src, TypeDesc dsttype, void *dst, int n=1)

Detailed Description

The TypeDesc class is used to describe simple data types.

Definition in file typedesc.h.

Macro Definition Documentation


Definition at line 33 of file typedesc.h.

Function Documentation

OIIO_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_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_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.