BKE IDProp: Add utils to get string version of an IDProp type/subtype.
This commit is contained in:
committed by
Bastien Montagne
parent
8481696337
commit
a6d3feda8e
@@ -319,6 +319,9 @@ void IDP_repr_fn(const IDProperty *prop,
|
||||
void *user_data);
|
||||
void IDP_print(const IDProperty *prop);
|
||||
|
||||
const char *IDP_type_str(eIDPropertyType type, short sub_type);
|
||||
const char *IDP_type_str(const IDProperty *prop);
|
||||
|
||||
void IDP_BlendWrite(BlendWriter *writer, const IDProperty *prop);
|
||||
void IDP_BlendReadData_impl(BlendDataReader *reader,
|
||||
IDProperty **prop,
|
||||
|
||||
@@ -262,4 +262,53 @@ void IDP_print(const IDProperty *prop)
|
||||
MEM_freeN(repr);
|
||||
}
|
||||
|
||||
const char *IDP_type_str(const eIDPropertyType type, const short sub_type)
|
||||
{
|
||||
switch (type) {
|
||||
case IDP_STRING:
|
||||
switch (sub_type) {
|
||||
case IDP_STRING_SUB_UTF8:
|
||||
return "String";
|
||||
case IDP_STRING_SUB_BYTE:
|
||||
return "Bytes";
|
||||
default:
|
||||
return "String";
|
||||
}
|
||||
case IDP_INT:
|
||||
return "Int";
|
||||
case IDP_FLOAT:
|
||||
return "Float";
|
||||
case IDP_ARRAY:
|
||||
switch (sub_type) {
|
||||
case IDP_INT:
|
||||
return "Array (Int)";
|
||||
case IDP_FLOAT:
|
||||
return "Array (Float)";
|
||||
case IDP_DOUBLE:
|
||||
return "Array (Double)";
|
||||
case IDP_BOOLEAN:
|
||||
return "Array (Boolean)";
|
||||
default:
|
||||
return "Array";
|
||||
}
|
||||
case IDP_GROUP:
|
||||
return "Group";
|
||||
case IDP_ID:
|
||||
return "ID";
|
||||
case IDP_DOUBLE:
|
||||
return "Double";
|
||||
case IDP_IDPARRAY:
|
||||
return "Array of Properties";
|
||||
case IDP_BOOLEAN:
|
||||
return "Boolean";
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
const char *IDP_type_str(const IDProperty *prop)
|
||||
{
|
||||
return IDP_type_str(eIDPropertyType(prop->type), prop->subtype);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
Reference in New Issue
Block a user