LuxCore
2.0
|
A generic container for values. More...
#include <properties.h>
Public Member Functions | |
Property () | |
Constructs a new empty property. More... | |
Property (const std::string &propName) | |
Constructs a new empty property with a given name. More... | |
Property (const std::string &propName, const PropertyValue &val) | |
Constructs a new property with a given name and value. More... | |
Property (const std::string &propName, const PropertyValues &vals) | |
Constructs a new property with a given name and values. More... | |
~Property () | |
const std::string & | GetName () const |
Returns the name of a property. More... | |
Property | AddedNamePrefix (const std::string &prefix) const |
Return a new property with a prefix added to the name. More... | |
Property | Renamed (const std::string &newName) const |
Return a new property with a new name. More... | |
unsigned int | GetSize () const |
Returns the number of values associated to this property. More... | |
Property & | Clear () |
Removes any values associated to the property. More... | |
template<class T > | |
T | Get (const unsigned int index) const |
Returns the value at the specified position. More... | |
const PropertyValue::DataType | GetValueType (const unsigned int index) const |
Returns the type of the value at the specified position. More... | |
template<class T > | |
T | Get () const |
Parses all values as a representation of the specified type. More... | |
template<class T > | |
Property & | Set (const unsigned int index, const T &val) |
Sets the value at the specified position. More... | |
template<class T > | |
Property & | Add (const T &val) |
Adds an item at the end of the list of values associated with the property. More... | |
std::string | GetValuesString () const |
Returns a string with all values associated to the property. More... | |
void | FromString (std::string &s) |
Initialize the property from a string (ex. "a.b.c = 1 2") More... | |
std::string | ToString () const |
Returns a string with the name of the property followed by " = " and by all values associated to the property. More... | |
template<class T0 > | |
Property & | operator() (const T0 &val0) |
Adds a value to a property. More... | |
template<class T0 , class T1 > | |
Property & | operator() (const T0 &val0, const T1 &val1) |
Adds a value to a property. More... | |
template<class T0 , class T1 , class T2 > | |
Property & | operator() (const T0 &val0, const T1 &val1, const T2 &val2) |
Adds a value to a property. More... | |
template<class T0 , class T1 , class T2 , class T3 > | |
Property & | operator() (const T0 &val0, const T1 &val1, const T2 &val2, const T3 &val3) |
Adds a value to a property. More... | |
template<class T0 > | |
Property & | operator() (const std::vector< T0 > &vals) |
Adds a vector of values to a property. More... | |
template<class T > | |
Property & | operator= (const T &val) |
Initializes a property with (only) the given value. More... | |
Property & | Add (const char *val) |
Required to work around the problem of char* to bool conversion (instead of char* to string). More... | |
Property & | Add (char *val) |
Required to work around the problem of char* to bool conversion (instead of char* to string). More... | |
Property & | operator() (const char *val) |
Property & | operator() (char *val) |
Required to work around the problem of char* to bool conversion (instead of char* to string). More... | |
Property & | operator= (const char *val) |
Required to work around the problem of char* to bool conversion (instead of char* to string). More... | |
Property & | operator= (char *val) |
Required to work around the problem of char* to bool conversion (instead of char* to string). More... | |
template<> | |
CPP_API bool | Get () const |
template<> | |
CPP_API int | Get () const |
template<> | |
CPP_API unsigned int | Get () const |
template<> | |
CPP_API float | Get () const |
template<> | |
CPP_API double | Get () const |
template<> | |
CPP_API unsigned long long | Get () const |
template<> | |
CPP_API const Blob & | Get () const |
Static Public Member Functions | |
static unsigned int | CountFields (const std::string &name) |
static std::string | ExtractField (const std::string &name, const unsigned int index) |
static std::string | ExtractPrefix (const std::string &name, const unsigned int count) |
Private Attributes | |
std::string | name |
PropertyValues | values |
A generic container for values.
A Property is a container associating a vector of values to a string name. The vector of values can include items with different data types. Check PropertyValue for a list of allowed types.
Definition at line 153 of file properties.h.
luxrays::Property::Property | ( | ) |
Constructs a new empty property.
Constructs a new empty property where the property name is initialized to the empty string (i.e. "") and the vector of values is empty too.
luxrays::Property::Property | ( | const std::string & | propName | ) |
Constructs a new empty property with a given name.
Constructs a new empty property where the property name is initialized to propName
and the vector of values is empty too.
propName | is the name of the new property. |
luxrays::Property::Property | ( | const std::string & | propName, |
const PropertyValue & | val | ||
) |
Constructs a new property with a given name and value.
Constructs a new property where the property name is initialized to propName
and the vector of values has one single element with the value of val
.
propName | is the name of the new property. |
val | is the value of the new property. |
luxrays::Property::Property | ( | const std::string & | propName, |
const PropertyValues & | vals | ||
) |
Constructs a new property with a given name and values.
Constructs a new property where the property name is initialized to propName
and the vector of values is initialize with the values of vals
.
propName | is the name of the new property. |
vals | is the value of the new property. |
luxrays::Property::~Property | ( | ) |
|
inline |
Adds an item at the end of the list of values associated with the property.
val | is the value to append. |
Definition at line 318 of file properties.h.
Referenced by operator()().
|
inline |
Required to work around the problem of char* to bool conversion (instead of char* to string).
Definition at line 428 of file properties.h.
|
inline |
Required to work around the problem of char* to bool conversion (instead of char* to string).
Definition at line 436 of file properties.h.
|
inline |
Return a new property with a prefix added to the name.
prefix | is the string to add to the name. |
Definition at line 208 of file properties.h.
References values.
Property& luxrays::Property::Clear | ( | ) |
Removes any values associated to the property.
|
static |
|
static |
|
static |
void luxrays::Property::FromString | ( | std::string & | s | ) |
Initialize the property from a string (ex. "a.b.c = 1 2")
|
inline |
Returns the value at the specified position.
index | is the position of the value to return. |
std::runtime_error | if the index is out of bound. |
Definition at line 249 of file properties.h.
|
inline |
Parses all values as a representation of the specified type.
The current list of supported data types is:
std::runtime_error | if the property has the wrong number of values for the specified data type. |
Definition at line 289 of file properties.h.
CPP_API bool luxrays::Property::Get | ( | ) | const |
CPP_API int luxrays::Property::Get | ( | ) | const |
CPP_API unsigned int luxrays::Property::Get | ( | ) | const |
CPP_API float luxrays::Property::Get | ( | ) | const |
CPP_API double luxrays::Property::Get | ( | ) | const |
CPP_API unsigned long long luxrays::Property::Get | ( | ) | const |
CPP_API const Blob& luxrays::Property::Get | ( | ) | const |
|
inline |
Returns the name of a property.
Definition at line 200 of file properties.h.
|
inline |
Returns the number of values associated to this property.
Definition at line 232 of file properties.h.
std::string luxrays::Property::GetValuesString | ( | ) | const |
Returns a string with all values associated to the property.
|
inline |
Returns the type of the value at the specified position.
index | is the position of the value. |
std::runtime_error | if the index is out of bound. |
Definition at line 264 of file properties.h.
|
inline |
Adds a value to a property.
It can be used to write expressions like:
Property("test1.prop1")("aa")
val0 | is the value to assign. |
Definition at line 350 of file properties.h.
|
inline |
Adds a value to a property.
It can be used to write expressions like:
Property("test1.prop1")(1.f, 2.f)
val0 | is the value to assign as first item. |
val1 | is the value to assign as second item. |
Definition at line 365 of file properties.h.
References Add().
|
inline |
Adds a value to a property.
It can be used to write expressions like:
Property("test1.prop1")(1.f, 2.f, 3.f)
val0 | is the value to assign as first item. |
val1 | is the value to assign as second item. |
val2 | is the value to assign as third item. |
Definition at line 381 of file properties.h.
References Add().
|
inline |
Adds a value to a property.
It can be used to write expressions like:
Property("test1.prop1")(1.f, 2.f, 3.f, 4.f)
val0 | is the value to assign as first item. |
val1 | is the value to assign as second item. |
val2 | is the value to assign as third item. |
val3 | is the value to assign as forth item. |
Definition at line 398 of file properties.h.
References Add().
|
inline |
Adds a vector of values to a property.
vals | is the value to assign. |
Definition at line 408 of file properties.h.
|
inline |
Definition at line 440 of file properties.h.
|
inline |
Required to work around the problem of char* to bool conversion (instead of char* to string).
Definition at line 447 of file properties.h.
|
inline |
Initializes a property with (only) the given value.
Definition at line 419 of file properties.h.
|
inline |
Required to work around the problem of char* to bool conversion (instead of char* to string).
Definition at line 454 of file properties.h.
|
inline |
Required to work around the problem of char* to bool conversion (instead of char* to string).
Definition at line 462 of file properties.h.
|
inline |
Return a new property with a new name.
prefix | is the string to use for the new name. |
Definition at line 221 of file properties.h.
References values.
|
inline |
Sets the value at the specified position.
index | is the position of the value to set. |
val | is the new value to set. |
std::runtime_error | if the index is out of bound. |
Definition at line 302 of file properties.h.
std::string luxrays::Property::ToString | ( | ) | const |
Returns a string with the name of the property followed by " = " and by all values associated to the property.
Referenced by luxrays::operator<<().
|
private |
Definition at line 472 of file properties.h.
|
private |
Definition at line 473 of file properties.h.
Referenced by AddedNamePrefix(), and Renamed().