13#pragma warning(disable:2586)
17 using PropBase = std::variant<int64, double, bool, string, DVect2,
18 DVect3, I64Vect2, I64Vect3, itasca::Mat, DAVect2,
19 DAVect3, Quat2, Quat3, SymTensor>;
22 using PropBase::PropBase;
24 enum class Type { Int, Double, Bool, String, DVect2,
25 DVect3, I64Vect2, I64Vect3,
Matrix, DAVect2,
28 Type type()
const {
return static_cast<Type
>(index()); }
35 bool canConvert()
const {
static_assert(
sizeof(T)==0);
return false; }
40 bool canConvertType()
const {
return canConvert<decltype(std::get<static_cast<int>(t)>(*this))>(); }
44 T to()
const {
static_assert(
sizeof(T)==0);
return false; }
48 auto toType()
const {
return to<decltype(std::get<static_cast<int>(t)>(*this))>(); }
53 typename std::tuple<T,bool> toTest()
const;
57 typename std::variant_alternative_t<static_cast<int>(t),
Property> toTestType()
const;
63 template <>
BASE_EXPORT bool Property::canConvert<int64>()
const;
64 template <>
BASE_EXPORT bool Property::canConvert<double>()
const;
65 template <>
BASE_EXPORT bool Property::canConvert<bool>()
const;
66 template <>
BASE_EXPORT bool Property::canConvert<string>()
const;
67 template <>
BASE_EXPORT bool Property::canConvert<DVect2>()
const;
68 template <>
BASE_EXPORT bool Property::canConvert<DVect3>()
const;
69 template <>
BASE_EXPORT bool Property::canConvert<I64Vect2>()
const;
70 template <>
BASE_EXPORT bool Property::canConvert<I64Vect3>()
const;
71 template <>
BASE_EXPORT bool Property::canConvert<itasca::Mat>()
const;
72 template <>
BASE_EXPORT bool Property::canConvert<DAVect2>()
const;
73 template <>
BASE_EXPORT bool Property::canConvert<DAVect3>()
const;
74 template <>
BASE_EXPORT bool Property::canConvert<Quat2>()
const;
75 template <>
BASE_EXPORT bool Property::canConvert<Quat3>()
const;
76 template <>
BASE_EXPORT bool Property::canConvert<SymTensor>()
const;
78 template <>
BASE_EXPORT int64 Property::to<int64>()
const;
79 template <>
BASE_EXPORT double Property::to<double>()
const;
80 template <>
BASE_EXPORT bool Property::to<bool>()
const;
81 template <>
BASE_EXPORT string Property::to<string>()
const;
82 template <>
BASE_EXPORT DVect2 Property::to<DVect2>()
const;
83 template <>
BASE_EXPORT DVect3 Property::to<DVect3>()
const;
84 template <>
BASE_EXPORT I64Vect2 Property::to<I64Vect2>()
const;
85 template <>
BASE_EXPORT I64Vect3 Property::to<I64Vect3>()
const;
87 template <>
BASE_EXPORT DAVect2 Property::to<DAVect2>()
const;
88 template <>
BASE_EXPORT DAVect3 Property::to<DAVect3>()
const;
96 typename std::tuple<T,bool> Property::toTest()
const {
97 bool b = canConvert<T>();
103 template <Property::Type t>
104 typename std::variant_alternative_t<static_cast<int>(t),
Property> Property::toTestType()
const {
105 using target_type =
decltype(std::get<static_cast<int>(t)>(*this));
106 using return_type = std::tuple<target_type,bool>;
107 bool b = canConvert<target_type>();
108 if (b)
return return_type(to<target_type>(),
true);
109 return return_type(target_type{},
false);
122 template <Property::Type t>
123 const auto &get(
const Property &v) {
return std::get<static_cast<int>(t)>(v); }
127 BASE_EXPORT string ts<base::Property>(
const base::Property &p,
int width,
char notation,
int precision,
char fill);
132 PropDesc(
const string &name,Property::Type type,UVect2 size) : name_(name), type_(type), size_(size) { }
135 Property::Type type_ = Property::Type::Int;
136 UVect2 size_ = UVect2(0);
137 BASE_EXPORT bool operator<(
const PropDesc &p)
const;
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:109
A symmetric 2nd order tensor.
Definition symtensor.h:22
#define BASE_EXPORT
Definition basedef.h:24
constexpr D to(const T &t)
This template function serves as an alternative to static_cast<T>().
Definition to.h:28
2D and 3D quaternion utility classes.
2D and 3D vector utility classes.