MaterialX 1.38.10
Loading...
Searching...
No Matches
Value Class Referenceabstract

A generic, discriminated value, whose type may be queried dynamically. More...

#include <Value.h>

Inheritance diagram for Value:
TypedValue< T >

Public Types

enum  FloatFormat { FloatFormatDefault = 0 , FloatFormatFixed = 1 , FloatFormatScientific = 2 }
 Float formats to use when converting values to strings.
 

Public Member Functions

virtual ValuePtr copy () const =0
 Create a deep copy of the value. More...
 

Static Public Member Functions

template<class T >
static ValuePtr createValue (const T &data)
 Create a new value from an object of any valid MaterialX type.
 
static ValuePtr createValue (const char *data)
 
static ValuePtr createValueFromStrings (const string &value, const string &type)
 Create a new value instance from value and type strings. More...
 

Data Accessors

using CreatorFunction = ValuePtr(*)(const string &)
 
using CreatorMap = std::unordered_map< string, CreatorFunction >
 
template<class T >
class ValueRegistry
 
template<class T >
bool isA () const
 Return true if this value is of the given type.
 
template<class T >
const T & asA () const
 Return our underlying data as an object of the given type. More...
 
virtual const string & getTypeString () const =0
 Return the type string for this value. More...
 
virtual string getValueString () const =0
 Return the value string for this value. More...
 
static void setFloatFormat (FloatFormat format)
 Set float formatting for converting values to strings. More...
 
static void setFloatPrecision (int precision)
 Set float precision for converting values to strings.
 
static FloatFormat getFloatFormat ()
 Return the current float format.
 
static int getFloatPrecision ()
 Return the current float precision.
 

Detailed Description

A generic, discriminated value, whose type may be queried dynamically.

Member Function Documentation

◆ asA()

const T & asA

Return our underlying data as an object of the given type.

If the given type doesn't match our own data type, then an exception is thrown.

◆ copy()

virtual ValuePtr copy ( ) const
pure virtual

Create a deep copy of the value.

Implemented in TypedValue< T >.

◆ createValueFromStrings()

ValuePtr createValueFromStrings ( const string &  value,
const string &  type 
)
static

Create a new value instance from value and type strings.

Returns
A shared pointer to a typed value, or an empty shared pointer if the conversion to the given data type cannot be performed.

◆ getTypeString()

virtual const string & getTypeString ( ) const
pure virtual

Return the type string for this value.

Implemented in TypedValue< T >.

◆ getValueString()

virtual string getValueString ( ) const
pure virtual

Return the value string for this value.

Implemented in TypedValue< T >.

◆ setFloatFormat()

static void setFloatFormat ( FloatFormat  format)
inlinestatic

Set float formatting for converting values to strings.

Formats to use are FloatFormatFixed, FloatFormatScientific or FloatFormatDefault to set default format.


The documentation for this class was generated from the following files: