Property¶
-
class Property¶
This class holds the data used in properties by the
Atom
and theFrame
classes. A property can have various types: bool, double, string orVector3D
.Public Types
Public Functions
-
inline Property(bool value)¶
Create a property holding a boolean value.
auto property = Property(false); assert(property.kind() == Property::BOOL); assert(property.as_bool() == false);
-
inline Property(double value)¶
Create a property holding a double value.
auto property = Property(45.2); assert(property.kind() == Property::DOUBLE); assert(property.as_double() == 45.2); // Various overload convert integers to double assert(Property(45).kind() == Property::DOUBLE); // int assert(Property(45l).kind() == Property::DOUBLE); // long assert(Property(45ll).kind() == Property::DOUBLE); // long long assert(Property(45u).kind() == Property::DOUBLE); // unsigned assert(Property(45ul).kind() == Property::DOUBLE); // unsigned long assert(Property(45ull).kind() == Property::DOUBLE); // unsigned long long
-
inline Property(Vector3D value)¶
Create a property holding a
Vector3D
value.auto property = Property(Vector3D(11, 22, 33)); assert(property.kind() == Property::VECTOR3D); assert(property.as_vector3d() == Vector3D(11, 22, 33));
-
inline Property(std::string value)¶
Create a property holding a string value.
// from a std::string auto property = Property(std::string("foo")); assert(property.kind() == Property::STRING); assert(property.as_string() == "foo"); // from a const char* property = Property("bar"); assert(property.kind() == Property::STRING); assert(property.as_string() == "bar");
-
inline Property(const char *value)¶
Create a property holding a string value from a const char*.
// from a std::string auto property = Property(std::string("foo")); assert(property.kind() == Property::STRING); assert(property.as_string() == "foo"); // from a const char* property = Property("bar"); assert(property.kind() == Property::STRING); assert(property.as_string() == "bar");
-
inline Property(int value)¶
Create a property holding a double value from an int.
auto property = Property(45.2); assert(property.kind() == Property::DOUBLE); assert(property.as_double() == 45.2); // Various overload convert integers to double assert(Property(45).kind() == Property::DOUBLE); // int assert(Property(45l).kind() == Property::DOUBLE); // long assert(Property(45ll).kind() == Property::DOUBLE); // long long assert(Property(45u).kind() == Property::DOUBLE); // unsigned assert(Property(45ul).kind() == Property::DOUBLE); // unsigned long assert(Property(45ull).kind() == Property::DOUBLE); // unsigned long long
-
inline Property(long value)¶
Create a property holding a double value from a long.
auto property = Property(45.2); assert(property.kind() == Property::DOUBLE); assert(property.as_double() == 45.2); // Various overload convert integers to double assert(Property(45).kind() == Property::DOUBLE); // int assert(Property(45l).kind() == Property::DOUBLE); // long assert(Property(45ll).kind() == Property::DOUBLE); // long long assert(Property(45u).kind() == Property::DOUBLE); // unsigned assert(Property(45ul).kind() == Property::DOUBLE); // unsigned long assert(Property(45ull).kind() == Property::DOUBLE); // unsigned long long
-
inline Property(long long value)¶
Create a property holding a double value from a long long.
auto property = Property(45.2); assert(property.kind() == Property::DOUBLE); assert(property.as_double() == 45.2); // Various overload convert integers to double assert(Property(45).kind() == Property::DOUBLE); // int assert(Property(45l).kind() == Property::DOUBLE); // long assert(Property(45ll).kind() == Property::DOUBLE); // long long assert(Property(45u).kind() == Property::DOUBLE); // unsigned assert(Property(45ul).kind() == Property::DOUBLE); // unsigned long assert(Property(45ull).kind() == Property::DOUBLE); // unsigned long long
-
inline Property(unsigned value)¶
Create a property holding a double value from an unsigned.
auto property = Property(45.2); assert(property.kind() == Property::DOUBLE); assert(property.as_double() == 45.2); // Various overload convert integers to double assert(Property(45).kind() == Property::DOUBLE); // int assert(Property(45l).kind() == Property::DOUBLE); // long assert(Property(45ll).kind() == Property::DOUBLE); // long long assert(Property(45u).kind() == Property::DOUBLE); // unsigned assert(Property(45ul).kind() == Property::DOUBLE); // unsigned long assert(Property(45ull).kind() == Property::DOUBLE); // unsigned long long
-
inline Property(unsigned long value)¶
Create a property holding a double value from an unsigned long.
auto property = Property(45.2); assert(property.kind() == Property::DOUBLE); assert(property.as_double() == 45.2); // Various overload convert integers to double assert(Property(45).kind() == Property::DOUBLE); // int assert(Property(45l).kind() == Property::DOUBLE); // long assert(Property(45ll).kind() == Property::DOUBLE); // long long assert(Property(45u).kind() == Property::DOUBLE); // unsigned assert(Property(45ul).kind() == Property::DOUBLE); // unsigned long assert(Property(45ull).kind() == Property::DOUBLE); // unsigned long long
-
inline Property(unsigned long long value)¶
Create a property holding a double value from an unsigned long long.
auto property = Property(45.2); assert(property.kind() == Property::DOUBLE); assert(property.as_double() == 45.2); // Various overload convert integers to double assert(Property(45).kind() == Property::DOUBLE); // int assert(Property(45l).kind() == Property::DOUBLE); // long assert(Property(45ll).kind() == Property::DOUBLE); // long long assert(Property(45u).kind() == Property::DOUBLE); // unsigned assert(Property(45ul).kind() == Property::DOUBLE); // unsigned long assert(Property(45ull).kind() == Property::DOUBLE); // unsigned long long
-
inline Kind kind() const¶
Get the kind of property, i.e. the type of the held value
assert(Property(42).kind() == Property::DOUBLE); assert(Property(false).kind() == Property::BOOL); assert(Property("string").kind() == Property::STRING); assert(Property(Vector3D(1, 2, 3)).kind() == Property::VECTOR3D);
-
bool as_bool() const¶
Get the boolean value stored in this Property
auto property = Property(false); assert(property.as_bool() == false);
- Throws:
PropertyError – if this property does not hold a boolean value
-
double as_double() const¶
Get the double value stored in this Property
auto property = Property(45.2); assert(property.as_double() == 45.2);
- Throws:
PropertyError – if this property does not hold a double value
-
Vector3D as_vector3d() const¶
Get the Vector3D value stored in this Property
auto property = Property(Vector3D(11, 22, 33)); assert(property.as_vector3d() == Vector3D(11, 22, 33));
- Throws:
PropertyError – if this property does not hold a Vector3D value
-
const std::string &as_string() const¶
Get the string value stored in this Property
// from a std::string auto property = Property("foo"); assert(property.as_string() == "foo");
- Throws:
PropertyError – if this property does not hold a string value
-
inline Property(bool value)¶