diff --git a/include/allegro_flare/attributes.h b/include/allegro_flare/attributes.h index 9bdc220ff..67f291b90 100644 --- a/include/allegro_flare/attributes.h +++ b/include/allegro_flare/attributes.h @@ -144,6 +144,8 @@ class Attributes static std::vector get_known_datatypes(); private: + static std::vector denied_custom_types; + int __find_attribute_index(std::string key); int __find_attribute_index(std::string key, std::string value); int __find_or_create_attribute_index(std::string key); diff --git a/src/attributes.cpp b/src/attributes.cpp index 6154f26fd..49e8d655c 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -97,6 +97,9 @@ std::vector DatatypeDefinition::definitions; +std::vector Attributes::denied_custom_types = {"int", "float", "bool", "string"}; + + Attributes::Attributes() { @@ -496,15 +499,17 @@ bool Attributes::pull_value(std::string key) bool Attributes::create_datatype_definition( - std::string datatype_identifier, + std::string identifier, bool (*to_val_func)(void *val, std::string str), std::string (*to_str_func)(void *val)) { - DatatypeDefinition *definition = DatatypeDefinition::find_definition(datatype_identifier); - DatatypeDefinition::definitions.push_back(DatatypeDefinition(datatype_identifier, to_val_func, to_str_func)); + std::vector &denied_types = Attributes::denied_custom_types; + if (std::find(denied_types.begin(), denied_types.end(), identifier) != denied_types.end()) return false; + DatatypeDefinition *definition = DatatypeDefinition::find_definition(identifier); if (definition) return false; - DatatypeDefinition::definitions.push_back(DatatypeDefinition(datatype_identifier, to_val_func, to_str_func)); + + DatatypeDefinition::definitions.push_back(DatatypeDefinition(identifier, to_val_func, to_str_func)); return true; } @@ -521,8 +526,10 @@ bool Attributes::datatype_is_known(std::string datatype) std::vector Attributes::get_known_datatypes() { - // TODO - std::vector result; + std::vector result = Attributes::denied_custom_types; + for (unsigned i=0; i