22 prop_template.
i = value;
24 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
32 prop_template.
i = value;
34 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
42 prop_template.
f = value;
44 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
52 prop_template.
d = value;
54 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
62 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
73 prop_template.
id = value;
75 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
85 prop_template.array.type = subtype;
87 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
97 memcpy(
IDP_Array(property), values, values_len * value_size);
112 static_assert(std::is_same_v<PrimitiveType, int32_t> || std::is_same_v<PrimitiveType, float> ||
113 std::is_same_v<PrimitiveType, double>,
114 "Allowed values for PrimitiveType are int32_t, float and double.");
115 static_assert(!std::is_same_v<PrimitiveType, int32_t> || id_property_subtype ==
IDP_INT,
116 "PrimitiveType and id_property_type do not match (int32_t).");
117 static_assert(!std::is_same_v<PrimitiveType, float> || id_property_subtype ==
IDP_FLOAT,
118 "PrimitiveType and id_property_type do not match (float).");
119 static_assert(!std::is_same_v<PrimitiveType, double> || id_property_subtype ==
IDP_DOUBLE,
120 "PrimitiveType and id_property_type do not match (double).");
122 const int64_t values_len = values.size();
124 std::unique_ptr<IDProperty, IDPropertyDeleter>
property =
array_create(
125 prop_name.
c_str(), id_property_subtype, values_len, flags);
127 property.get(),
static_cast<const void *
>(values.data()), values_len,
sizeof(
PrimitiveType));
157 return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
IDProperty * IDP_New(char type, const IDPropertyTemplate *val, const char *name, eIDPropertyFlag flags={}) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
IDProperty * IDP_NewString(const char *st, const char *name, eIDPropertyFlag flags={}) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
ID and Library types, which are fundamental for SDNA.
constexpr const char * c_str() const
std::unique_ptr< IDProperty, IDPropertyDeleter > create_array(StringRefNull prop_name, Span< PrimitiveType > values, const eIDPropertyFlag flags)
static void array_values_set(IDProperty *property, const void *values, size_t values_len, size_t value_size)
std::unique_ptr< IDProperty, IDPropertyDeleter > create_bool(StringRefNull prop_name, bool value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_BOOLEAN, set its name and value.
static std::unique_ptr< IDProperty, IDPropertyDeleter > array_create(const StringRefNull prop_name, eIDPropertyType subtype, size_t array_len, const eIDPropertyFlag flags)
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRefNull prop_name, int32_t value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_INT, set its name and value.
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRefNull prop_name, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_GROUP.
struct IDPropertyTemplate::@30 array