VRay SDK for C++
Loading...
Searching...
No Matches
VRay::Value Class Reference

A generic value holder used by Plugin parameters. More...

#include <vraysdk.hpp>

Public Member Functions

 Value () noexcept
 Default constructor initializes Value to TYPE_ERROR.
 
 Value (bool value) noexcept
 
 Value (ColorList &&value) noexcept
 
 Value (const AColor &value) noexcept
 
 Value (const char *value)
 
 Value (const Color &value) noexcept
 
 Value (const Color *values, size_t count)
 
template<size_t count>
 Value (const Color(&arr)[count])
 
 Value (const ColorList &value)
 
 Value (const float *values, size_t count)
 
template<size_t count>
 Value (const float(&arr)[count])
 
 Value (const FloatList &value)
 
 Value (const int *values, size_t count)
 
template<size_t count>
 Value (const int(&arr)[count])
 
 Value (const IntList &value)
 
 Value (const Matrix &value) noexcept
 
 Value (const Plugin *values, size_t count)
 
template<size_t count>
 Value (const Plugin(&arr)[count])
 
 Value (const PluginList &value)
 
 Value (const PluginRef &value) noexcept
 
 Value (const std::string &value)
 
 Value (const StringList &value)
 
 Value (const Transform &value) noexcept
 
 Value (const Transform *values, size_t count)
 
template<size_t count>
 Value (const Transform(&arr)[count])
 
 Value (const TransformList &value)
 
 Value (const Value &value)
 
 Value (const Value *values, size_t count)
 
template<size_t count>
 Value (const Value(&arr)[count])
 
 Value (const ValueList &value)
 
 Value (const Vector &value) noexcept
 
 Value (const Vector *values, size_t count)
 
template<size_t count>
 Value (const Vector(&arr)[count])
 
 Value (const VectorList &value)
 
 Value (double value) noexcept
 
 Value (float value) noexcept
 
 Value (FloatList &&value) noexcept
 
 Value (int value) noexcept
 
 Value (IntList &&value) noexcept
 
 Value (PluginList &&value) noexcept
 
 Value (std::string &&value) noexcept
 
 Value (StringList &&value) noexcept
 
 Value (TransformList &&value) noexcept
 
 Value (Value &&value) noexcept
 
template<size_t count>
 Value (Value(&&arr)[count])
 
 Value (ValueList &&value) noexcept
 
 Value (VectorList &&value) noexcept
 
template<typename T >
T & as ()
 
template<typename T >
const T & as () const
 
template<typename T >
get () const
 
AColor getAColor () const
 Returns zero AColor if the value is not AColor. Keep in mind the value can be an AColor and still be zero.
 
bool getBool () const
 Works if the value is int, float, double or boolean. Otherwise returns false.
 
Color getColor () const
 Works if the value is Color or AColor. Otherwise returns zero color.
 
ColorList getColorList () const
 
size_t getCount () const
 Returns number of list elements if the value is a list type.
 
double getDouble () const
 Works if the value is int, float, double or boolean. Otherwise returns 0.0.
 
float getFloat () const
 Works if the value is int, float, double or boolean. Otherwise returns 0.0f.
 
FloatList getFloatList () const
 
int getInt () const
 Works if the value is int, float, double or boolean. Otherwise returns 0.
 
IntList getIntList () const
 
Matrix getMatrix () const
 Returns default constructed (uninitialized) Matrix if the value is not Matrix.
 
Plugin getPlugin () const
 Returns invalid Plugin if the value is not Plugin. Keep in mind the value can be a Plugin and still be invalid.
 
PluginList getPluginList () const
 
PluginRef getPluginRef () const
 Returns invalid PluginRef if the value is not Plugin. Keep in mind the value can be a Plugin and still be invalid.
 
std::string getString () const
 Returns empty string if the value is not string. Keep in mind the value can be a string and still be empty.
 
StringList getStringList () const
 
const char * getStringType () const
 Returns a string representation of the type.
 
Transform getTransform () const
 Returns default constructed (uninitialized) Transform if the value is not Transform.
 
TransformList getTransformList () const
 
Type getType () const noexcept
 Get the actual type of the stored value.
 
ValueList getValueList () const
 
Vector getVector () const
 Returns zero Vector if the value is not Vector. Keep in mind the value can be a Vector and still be zero.
 
VectorList getVectorList () const
 
bool isBad () const
 True if there was an error and the value can't be used. Checks against TYPE_ERROR.
 
bool isList () const
 False if this holds a single value.
 
bool isOK () const
 True if the value can be used. Checks against TYPE_ERROR and TYPE_UNSPECIFIED.
 
bool operator!= (const Value &value) const noexcept
 
Valueoperator= (const Value &value)
 
Valueoperator= (Value &&value) noexcept
 
bool operator== (const Value &value) const noexcept
 
Valueoperator[] (int i)
 
const Value operator[] (int i) const
 
void set (bool value)
 Stores the passed value and sets the appropriate type.
 
void set (ColorList &&value)
 Stores the passed value and sets the appropriate type.
 
void set (const AColor &value)
 Stores the passed value and sets the appropriate type.
 
void set (const char *value)
 Stores the passed value and sets the appropriate type.
 
void set (const Color &value)
 Stores the passed value and sets the appropriate type.
 
void set (const Color *values, size_t count)
 Stores the passed value array and sets the appropriate type.
 
void set (const ColorList &value)
 Stores the passed value and sets the appropriate type.
 
void set (const float *values, size_t count)
 Stores the passed value array and sets the appropriate type.
 
void set (const FloatList &value)
 Stores the passed value and sets the appropriate type.
 
void set (const int *values, size_t count)
 Stores the passed value array and sets the appropriate type.
 
void set (const IntList &value)
 Stores the passed value and sets the appropriate type.
 
void set (const Matrix &value)
 Stores the passed value and sets the appropriate type.
 
void set (const Plugin &value)
 Stores the passed value and sets the appropriate type.
 
void set (const PluginList &value)
 Stores the passed value and sets the appropriate type.
 
void set (const PluginRef &value)
 Stores the passed value and sets the appropriate type.
 
void set (const std::string &value)
 Stores the passed value and sets the appropriate type.
 
void set (const std::string *values, size_t count)
 Stores the passed value array and sets the appropriate type.
 
void set (const StringList &value)
 Stores the passed value and sets the appropriate type.
 
void set (const Transform &value)
 Stores the passed value and sets the appropriate type.
 
void set (const Transform *values, size_t count)
 Stores the passed value array and sets the appropriate type.
 
void set (const TransformList &value)
 Stores the passed value and sets the appropriate type.
 
void set (const ValueList &value)
 Stores the passed value and sets the appropriate type.
 
void set (const Vector &value)
 Stores the passed value and sets the appropriate type.
 
void set (const Vector *values, size_t count)
 Stores the passed value array and sets the appropriate type.
 
void set (const VectorList &value)
 Stores the passed value and sets the appropriate type.
 
void set (double value)
 Stores the passed value and sets the appropriate type.
 
void set (float value)
 Stores the passed value and sets the appropriate type.
 
void set (FloatList &&value)
 Stores the passed value and sets the appropriate type.
 
void set (int value)
 Stores the passed value and sets the appropriate type.
 
void set (IntList &&value)
 Stores the passed value and sets the appropriate type.
 
void set (PluginList &&value)
 Stores the passed value and sets the appropriate type.
 
void set (std::string &&value)
 Stores the passed value and sets the appropriate type.
 
void set (StringList &&value)
 Stores the passed value and sets the appropriate type.
 
void set (TransformList &&value)
 Stores the passed value and sets the appropriate type.
 
void set (ValueList &&value)
 Stores the passed value and sets the appropriate type.
 
void set (VectorList &&value)
 Stores the passed value and sets the appropriate type.
 
void swap (Value &value) noexcept
 
std::string toString () const
 Returns the value as string.
 

Static Public Member Functions

static Value Unspecified () noexcept
 Static constructor initializes Value to TYPE_UNSPECIFIED.
 

Protected Member Functions

 Value (Type type) noexcept
 
 Value (VRayRenderer *renderer, InstanceId id, int outIdx) noexcept
 
template<typename T , Type TYPE>
void constructListWithIterators_ (const T *first, const T *last)
 
template<typename T , Type TYPE>
void constructOnly_ () noexcept
 
template<typename T , Type TYPE, bool noExcept>
void constructWithValue_ (T &&value) noexcept(noExcept)
 
void copyValue (const Value &value)
 
void destroyValue () noexcept
 
template<typename T , Type TYPE>
getValue_ () const
 
template<typename T >
T & interpretAs_ ()
 
template<typename T >
const T & interpretAs_ () const
 
void moveValue (Value &&value) noexcept
 
template<typename T , Type TYPE>
void setToValue_ (T &&value)
 
void swapValue (Value &value) noexcept
 
template<typename T , Type TYPE>
T & viewAs_ ()
 
template<typename T , Type TYPE>
const T & viewAs_ () const
 

Protected Attributes

union {
   void *   alignment
 
   char   val [VRAY_MAXIMUM4(sizeof(Transform),
       sizeof(std::string), sizeof(ValueList),
       sizeof(PluginRef))]
 
}; 
 
Type type
 

Friends

class Internal::BinaryValueBuilder
 
class Internal::BinaryValueParser
 
struct Internal::MeshFileDataParser
 
std::ostream & operator<< (std::ostream &stream, const Value &value)
 

Detailed Description

A generic value holder used by Plugin parameters.

Member Function Documentation

◆ as() [1/2]

template<typename T >
T & VRay::Value::as ( )

Returns a mutable reference to the value interpreted as T type. Use only when you're sure of the type. If VRAY_NOTHROW is defined this is done without checking. Otherwise an exception is thrown.

◆ as() [2/2]

template<typename T >
const T & VRay::Value::as ( ) const

Returns an unmutable reference to the value interpreted as T type. Use only when you're sure of the type. If VRAY_NOTHROW is defined this is done without checking. Otherwise an exception is thrown.

◆ get()

template<typename T >
T VRay::Value::get ( ) const

Returns a copy of the value if it is indeed of type T. Otherwise an exception is thrown. Color and AColor get converted between, integral types too. If VRAY_NOTHROW is defined a default constructed T is returned.

◆ getColorList()

ColorList VRay::Value::getColorList ( ) const

Returns empty list if the value is not ColorList. Keep in mind the value can be a ColorList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ getFloatList()

FloatList VRay::Value::getFloatList ( ) const

Returns empty list if the value is not FloatList. Keep in mind the value can be a FloatList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ getIntList()

IntList VRay::Value::getIntList ( ) const

Returns empty list if the value is not IntList. Keep in mind the value can be an IntList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ getPluginList()

PluginList VRay::Value::getPluginList ( ) const

Returns empty list if the value is not PluginList. Keep in mind the value can be a PluginList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ getStringList()

StringList VRay::Value::getStringList ( ) const

Returns empty list if the value is not StringList. Keep in mind the value can be a StringList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ getTransformList()

TransformList VRay::Value::getTransformList ( ) const

Returns empty list if the value is not TransformList. Keep in mind the value can be a TransformList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ getValueList()

ValueList VRay::Value::getValueList ( ) const

Returns empty list if the value is not ValueList. Keep in mind the value can be a ValueList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ getVectorList()

VectorList VRay::Value::getVectorList ( ) const

Returns empty list if the value is not VectorList. Keep in mind the value can be a VectorList and still be empty. To avoid copy constructing a large list, use the as() method.

◆ operator[]() [1/2]

Value & VRay::Value::operator[] ( int  i)

If the value is a general list, returns a reference to the i-th element. Otherwise throws an exception (if they are enabled) or itself if exceptions are disabled.

◆ operator[]() [2/2]

const Value VRay::Value::operator[] ( int  i) const

If the value is a any type of list, returns a copy of the i-th element. Otherwise throws an exception (if they are enabled) or an empty (error) value if exceptions are disabled.


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