13#pragma warning(disable:2586)
21 using PropBase = std::variant<int64, double, bool, string, DVect2,
27 using PropBase::PropBase;
29 enum class Type { Int, Double, Bool,
String, DVect2,
30 DVect3, I64Vect2, I64Vect3,
Matrix, DAVect2,
33 Type type()
const {
return static_cast<Type
>(index()); }
40 bool canConvert()
const {
static_assert(
sizeof(T)==0);
return false; }
45 bool canConvertType()
const {
return canConvert<decltype(std::get<static_cast<int>(t)>(*this))>(); }
49 T to()
const {
static_assert(
sizeof(T)==0);
return false; }
53 auto toType()
const {
return to<decltype(std::get<static_cast<int>(t)>(*this))>(); }
58 typename std::tuple<T,bool> toTest()
const;
62 typename std::variant_alternative_t<static_cast<int>(t),
Property> toTestType()
const;
68 template <>
BASE_EXPORT bool Property::canConvert<int64>()
const;
69 template <>
BASE_EXPORT bool Property::canConvert<double>()
const;
70 template <>
BASE_EXPORT bool Property::canConvert<bool>()
const;
71 template <>
BASE_EXPORT bool Property::canConvert<string>()
const;
72 template <>
BASE_EXPORT bool Property::canConvert<DVect2>()
const;
73 template <>
BASE_EXPORT bool Property::canConvert<DVect3>()
const;
74 template <>
BASE_EXPORT bool Property::canConvert<I64Vect2>()
const;
75 template <>
BASE_EXPORT bool Property::canConvert<I64Vect3>()
const;
76 template <>
BASE_EXPORT bool Property::canConvert<itasca::Mat>()
const;
77 template <>
BASE_EXPORT bool Property::canConvert<DAVect2>()
const;
78 template <>
BASE_EXPORT bool Property::canConvert<DAVect3>()
const;
79 template <>
BASE_EXPORT bool Property::canConvert<Quat2>()
const;
80 template <>
BASE_EXPORT bool Property::canConvert<Quat3>()
const;
81 template <>
BASE_EXPORT bool Property::canConvert<SymTensor>()
const;
83 template <>
BASE_EXPORT int64 Property::to<int64>()
const;
84 template <>
BASE_EXPORT double Property::to<double>()
const;
85 template <>
BASE_EXPORT bool Property::to<bool>()
const;
86 template <>
BASE_EXPORT string Property::to<string>()
const;
87 template <>
BASE_EXPORT DVect2 Property::to<DVect2>()
const;
88 template <>
BASE_EXPORT DVect3 Property::to<DVect3>()
const;
89 template <>
BASE_EXPORT I64Vect2 Property::to<I64Vect2>()
const;
90 template <>
BASE_EXPORT I64Vect3 Property::to<I64Vect3>()
const;
92 template <>
BASE_EXPORT DAVect2 Property::to<DAVect2>()
const;
93 template <>
BASE_EXPORT DAVect3 Property::to<DAVect3>()
const;
100 template <
typename T>
101 typename std::tuple<T,bool> Property::toTest()
const {
102 bool b = canConvert<T>();
108 template <Property::Type t>
109 typename std::variant_alternative_t<static_cast<int>(t),Property> Property::toTestType()
const {
110 using target_type =
decltype(std::get<static_cast<int>(t)>(*this));
111 using return_type = std::tuple<target_type,bool>;
112 bool b = canConvert<target_type>();
113 if (b)
return return_type(to<target_type>(),
true);
114 return return_type(target_type{},
false);
127 template <Property::Type t>
128 const auto &get(
const Property &v) {
return std::get<static_cast<int>(t)>(v); }
137 PropDesc(
const string &name,Property::Type type,UVect2 size) : name_(name), type_(type), size_(size) { }
140 Property::Type type_ = Property::Type::Int;
141 UVect2 size_ = UVect2(0);
QString helper functions, plus some additions.
A template-based matrix class, size fixed at compile time. Defaults to symmetric sized matrix.
Definition matrix.h:22
2D quaternion-like utility class. In this case only the angle (in radians) is stored as opposed to th...
Definition quat.h:20
3D quaternion utility class.
Definition quat.h:108
A symmetric 2nd order tensor.
Definition symtensor.h:22
std::basic_string< char8 > String
std::string of type Char
Definition basebool.h:9
#define BASE_EXPORT
Definition basedef.h:24
2D and 3D quaternion utility classes.
Definition property.h:135
2D and 3D vector utility classes.