19 prop_template.
i = value;
21 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
27 prop_template.
f = value;
29 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
35 prop_template.
d = value;
37 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
44 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
53 prop_template.array.type = subtype;
55 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
65 memcpy(
IDP_Array(property), values, values_len * value_size);
79 static_assert(std::is_same_v<PrimitiveType, int32_t> || std::is_same_v<PrimitiveType, float> ||
80 std::is_same_v<PrimitiveType, double>,
81 "Allowed values for PrimitiveType are int32_t, float and double.");
82 static_assert(!std::is_same_v<PrimitiveType, int32_t> || id_property_subtype ==
IDP_INT,
83 "PrimitiveType and id_property_type do not match (int32_t).");
84 static_assert(!std::is_same_v<PrimitiveType, float> || id_property_subtype ==
IDP_FLOAT,
85 "PrimitiveType and id_property_type do not match (float).");
86 static_assert(!std::is_same_v<PrimitiveType, double> || id_property_subtype ==
IDP_DOUBLE,
87 "PrimitiveType and id_property_type do not match (double).");
91 std::unique_ptr<IDProperty, IDPropertyDeleter>
property =
array_create(
92 prop_name.
c_str(), id_property_subtype, values_len);
94 property.get(),
static_cast<const void *
>(values.
data()), values_len,
sizeof(
PrimitiveType));
101 return create_array<int32_t, IDP_INT>(prop_name, values);
107 return create_array<float, IDP_FLOAT>(prop_name, values);
113 return create_array<double, IDP_DOUBLE>(prop_name, values);
120 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
struct IDProperty * IDP_New(char type, const IDPropertyTemplate *val, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
struct IDProperty * IDP_NewString(const char *st, const char *name, int maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
ID and Library types, which are fundamental for sdna.
constexpr const T * data() const
constexpr int64_t size() const
constexpr int64_t size() const
constexpr const char * c_str() const
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRefNull prop_name)
Allocate a new IDProperty of type IDP_GROUP.
static void array_values_set(IDProperty *property, const void *values, size_t values_len, size_t value_size)
static std::unique_ptr< IDProperty, IDPropertyDeleter > array_create(const StringRefNull prop_name, eIDPropertyType subtype, size_t array_len)
std::unique_ptr< IDProperty, IDPropertyDeleter > create_array(StringRefNull prop_name, Span< PrimitiveType > values)
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRefNull prop_name, int32_t value)
Allocate a new IDProperty of type IDP_INT, set its name and value.
struct IDPropertyTemplate::@27 array