ifcparse: fix clang-tidy warning readability-qualified-auto

This commit is contained in:
Dirk Olbrich
2023-10-24 16:11:26 +02:00
committed by Thomas Krijnen
parent c29e7b32ad
commit 8b145248c6
4 changed files with 28 additions and 28 deletions
+2 -2
View File
@@ -154,13 +154,13 @@ class IFC_PARSE_API IfcBaseType : public IfcBaseClass {
namespace IfcUtil { namespace IfcUtil {
template <typename T> template <typename T>
T IfcBaseEntity::get_value(const std::string& name) const { T IfcBaseEntity::get_value(const std::string& name) const {
auto attr = get(name); auto* attr = get(name);
return (T)*attr; return (T)*attr;
} }
template <typename T> template <typename T>
T IfcBaseEntity::get_value(const std::string& name, const T& default_value) const { T IfcBaseEntity::get_value(const std::string& name, const T& default_value) const {
auto attr = get(name); auto* attr = get(name);
if (attr->isNull()) { if (attr->isNull()) {
return default_value; return default_value;
} }
+12 -12
View File
@@ -755,7 +755,7 @@ size_t IfcParse::IfcFile::load(unsigned entity_instance_name, const IfcParse::en
if (TokenFunc::isKeyword(next)) { if (TokenFunc::isKeyword(next)) {
try { try {
auto ea = new EntityArgument(next); auto* ea = new EntityArgument(next);
addEntity(((IfcUtil::IfcBaseClass*)*ea)); addEntity(((IfcUtil::IfcBaseClass*)*ea));
filler.push_back(ea); filler.push_back(ea);
} catch (IfcException& e) { } catch (IfcException& e) {
@@ -873,7 +873,7 @@ ArgumentList::operator aggregate_of_aggregate_of_instance::ptr() const {
aggregate_of_instance::ptr e = *arg_list; aggregate_of_instance::ptr e = *arg_list;
l->push(e); l->push(e);
} else { } else {
auto token = dynamic_cast<const TokenArgument*>(arg); const auto* token = dynamic_cast<const TokenArgument*>(arg);
int startpos = token != nullptr ? token->token.startPos : 0; int startpos = token != nullptr ? token->token.startPos : 0;
std::string string_rep = this->toString(); std::string string_rep = this->toString();
throw IfcInvalidTokenException(startpos, string_rep, "nested aggregate"); throw IfcInvalidTokenException(startpos, string_rep, "nested aggregate");
@@ -1051,7 +1051,7 @@ void IfcParse::IfcFile::try_read_semicolon() {
void IfcParse::IfcFile::register_inverse(unsigned id_from, const IfcParse::entity* from_entity, Token t, int attribute_index) { void IfcParse::IfcFile::register_inverse(unsigned id_from, const IfcParse::entity* from_entity, Token t, int attribute_index) {
// Assume a check on token type has already been performed // Assume a check on token type has already been performed
auto e = from_entity; const auto* e = from_entity;
byref_excl[t.value_int].push_back(id_from); byref_excl[t.value_int].push_back(id_from);
while (e != nullptr) { while (e != nullptr) {
byref[{t.value_int, e->index_in_schema(), attribute_index}].push_back(id_from); byref[{t.value_int, e->index_in_schema(), attribute_index}].push_back(id_from);
@@ -1060,7 +1060,7 @@ void IfcParse::IfcFile::register_inverse(unsigned id_from, const IfcParse::entit
} }
void IfcParse::IfcFile::register_inverse(unsigned id_from, const IfcParse::entity* from_entity, IfcUtil::IfcBaseClass* inst, int attribute_index) { void IfcParse::IfcFile::register_inverse(unsigned id_from, const IfcParse::entity* from_entity, IfcUtil::IfcBaseClass* inst, int attribute_index) {
auto e = from_entity; const auto* e = from_entity;
byref_excl[inst->data().id()].push_back(id_from); byref_excl[inst->data().id()].push_back(id_from);
while (e != nullptr) { while (e != nullptr) {
byref[{inst->data().id(), e->index_in_schema(), attribute_index}].push_back(id_from); byref[{inst->data().id(), e->index_in_schema(), attribute_index}].push_back(id_from);
@@ -1069,7 +1069,7 @@ void IfcParse::IfcFile::register_inverse(unsigned id_from, const IfcParse::entit
} }
void IfcParse::IfcFile::unregister_inverse(unsigned id_from, const IfcParse::entity* from_entity, IfcUtil::IfcBaseClass* inst, int attribute_index) { void IfcParse::IfcFile::unregister_inverse(unsigned id_from, const IfcParse::entity* from_entity, IfcUtil::IfcBaseClass* inst, int attribute_index) {
auto e = from_entity; const auto* e = from_entity;
while (e != nullptr) { while (e != nullptr) {
std::vector<int>& ids = byref[{inst->data().id(), e->index_in_schema(), attribute_index}]; std::vector<int>& ids = byref[{inst->data().id(), e->index_in_schema(), attribute_index}];
std::vector<int>::iterator it = std::find(ids.begin(), ids.end(), id_from); std::vector<int>::iterator it = std::find(ids.begin(), ids.end(), id_from);
@@ -1799,7 +1799,7 @@ class traversal_recorder {
return list_; return list_;
} }
aggregate_of_instance::ptr l(new aggregate_of_instance); aggregate_of_instance::ptr l(new aggregate_of_instance);
for (auto& p : instances_by_level_) { for (const auto& p : instances_by_level_) {
l->push(p.second); l->push(p.second);
} }
return l; return l;
@@ -2174,8 +2174,8 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
void IfcFile::process_deletion_() { void IfcFile::process_deletion_() {
for (auto& id : batch_deletion_ids_.get<0>()) { for (const auto& id : batch_deletion_ids_.get<0>()) {
auto entity = instance_by_id(id); auto* entity = instance_by_id(id);
aggregate_of_instance::ptr references = instances_by_reference(id); aggregate_of_instance::ptr references = instances_by_reference(id);
@@ -2425,7 +2425,7 @@ IfcFile::~IfcFile() {
for (const auto& pair : byidentity) { for (const auto& pair : byidentity) {
entities_to_delete.insert(pair.second); entities_to_delete.insert(pair.second);
} }
for (auto entity : entities_to_delete) { for (auto* entity : entities_to_delete) {
delete entity; delete entity;
} }
delete stream; delete stream;
@@ -2521,7 +2521,7 @@ std::vector<int> IfcFile::get_inverse_indices(int instance_id) {
auto refs = instances_by_reference(instance_id); auto refs = instances_by_reference(instance_id);
for (auto& r : *refs) { for (const auto& r : *refs) {
auto it = mapping.find(r->data().id()); auto it = mapping.find(r->data().id());
if (it == mapping.end() || it->second.empty()) { if (it == mapping.end() || it->second.empty()) {
throw IfcException("Internal error"); throw IfcException("Internal error");
@@ -2667,7 +2667,7 @@ void IfcParse::IfcFile::build_inverses_(IfcUtil::IfcBaseClass* inst) {
std::function<void(IfcUtil::IfcBaseClass*, int)> fn = [this, inst](IfcUtil::IfcBaseClass* attr, int idx) { std::function<void(IfcUtil::IfcBaseClass*, int)> fn = [this, inst](IfcUtil::IfcBaseClass* attr, int idx) {
if (attr->declaration().as_entity() != nullptr) { if (attr->declaration().as_entity() != nullptr) {
unsigned entity_attribute_id = attr->data().id(); unsigned entity_attribute_id = attr->data().id();
auto decl = inst->declaration().as_entity(); const auto* decl = inst->declaration().as_entity();
byref_excl[entity_attribute_id].push_back(inst->data().id()); byref_excl[entity_attribute_id].push_back(inst->data().id());
while (decl != nullptr) { while (decl != nullptr) {
byref[{entity_attribute_id, decl->index_in_schema(), idx}].push_back(inst->data().id()); byref[{entity_attribute_id, decl->index_in_schema(), idx}].push_back(inst->data().id());
@@ -2680,7 +2680,7 @@ void IfcParse::IfcFile::build_inverses_(IfcUtil::IfcBaseClass* inst) {
} }
void IfcParse::IfcFile::build_inverses() { void IfcParse::IfcFile::build_inverses() {
for (auto& pair : *this) { for (const auto& pair : *this) {
build_inverses_(pair.second); build_inverses_(pair.second);
} }
} }
+2 -2
View File
@@ -112,10 +112,10 @@ bool IfcParse::named_type::is(const IfcParse::declaration& decl) const {
} }
IfcParse::entity::~entity() { IfcParse::entity::~entity() {
for (auto attribute : attributes_) { for (const auto* attribute : attributes_) {
delete attribute; delete attribute;
} }
for (auto inverse_attribute : inverse_attributes_) { for (const auto* inverse_attribute : inverse_attributes_) {
delete inverse_attribute; delete inverse_attribute;
} }
} }
+12 -12
View File
@@ -200,14 +200,14 @@ std::vector<T> split(const std::string& value) {
} }
Argument* parse_attribute_value(const IfcParse::parameter_type* ty, const std::string& value) { Argument* parse_attribute_value(const IfcParse::parameter_type* ty, const std::string& value) {
auto v = new IfcWrite::IfcWriteArgument(); auto* v = new IfcWrite::IfcWriteArgument();
auto cpp_type = IfcUtil::from_parameter_type(ty); auto cpp_type = IfcUtil::from_parameter_type(ty);
if (cpp_type == IfcUtil::Argument_STRING) { if (cpp_type == IfcUtil::Argument_STRING) {
v->set(value); v->set(value);
} else if (cpp_type == IfcUtil::Argument_ENUMERATION) { } else if (cpp_type == IfcUtil::Argument_ENUMERATION) {
auto enum_type = ty->as_named_type()->declared_type()->as_enumeration_type(); const auto* enum_type = ty->as_named_type()->declared_type()->as_enumeration_type();
std::vector<std::string>::const_iterator it = std::find( std::vector<std::string>::const_iterator it = std::find(
enum_type->enumeration_items().begin(), enum_type->enumeration_items().begin(),
@@ -248,7 +248,7 @@ static void end_element(void* user, const xmlChar* tag) {
if (!state->stack.empty() && state->stack.back().ntype() == stack_node::node_aggregate) { if (!state->stack.empty() && state->stack.back().ntype() == stack_node::node_aggregate) {
const auto& back = state->stack.back(); const auto& back = state->stack.back();
auto& elems = state->stack.back().aggregate_elements; auto& elems = state->stack.back().aggregate_elements;
auto li = new IfcParse::ArgumentList(elems.size()); auto* li = new IfcParse::ArgumentList(elems.size());
size_t i = 0; size_t i = 0;
for (auto& elem : elems) { for (auto& elem : elems) {
li->arguments()[i++] = elem; li->arguments()[i++] = elem;
@@ -289,7 +289,7 @@ static void process_characters(void* user, const xmlChar* ch, int len) {
} }
if (!state->stack.empty() && state->stack.back().inst() != nullptr && (state->stack.back().inst()->declaration().as_type_declaration() != nullptr)) { if (!state->stack.empty() && state->stack.back().inst() != nullptr && (state->stack.back().inst()->declaration().as_type_declaration() != nullptr)) {
auto pt = state->stack.back().inst()->declaration().as_type_declaration()->declared_type(); const auto* pt = state->stack.back().inst()->declaration().as_type_declaration()->declared_type();
Argument* val = nullptr; Argument* val = nullptr;
try { try {
val = parse_attribute_value(pt, txt); val = parse_attribute_value(pt, txt);
@@ -323,17 +323,17 @@ static void process_characters(void* user, const xmlChar* ch, int len) {
Logger::Error("Unrecognized header entry " + tagname); Logger::Error("Unrecognized header entry " + tagname);
} }
} else if (state_type == stack_node::node_instance_attribute) { } else if (state_type == stack_node::node_instance_attribute) {
auto pt = state->stack.back().inst()->declaration().as_entity()->attribute_by_index(state->stack.back().idx())->type_of_attribute(); const auto* pt = state->stack.back().inst()->declaration().as_entity()->attribute_by_index(state->stack.back().idx())->type_of_attribute();
auto cpp_type = IfcUtil::from_parameter_type(pt); auto cpp_type = IfcUtil::from_parameter_type(pt);
if (cpp_type != IfcUtil::Argument_ENTITY_INSTANCE) { if (cpp_type != IfcUtil::Argument_ENTITY_INSTANCE) {
auto val = parse_attribute_value(pt, txt); auto* val = parse_attribute_value(pt, txt);
if (val != nullptr) { if (val != nullptr) {
state->stack.back().inst()->data().setArgument(state->stack.back().idx(), val); state->stack.back().inst()->data().setArgument(state->stack.back().idx(), val);
} }
} }
} else if (state_type == stack_node::node_aggregate_element) { } else if (state_type == stack_node::node_aggregate_element) {
auto pt = state->stack.back().aggregate_elem_type(); const auto* pt = state->stack.back().aggregate_elem_type();
auto val = parse_attribute_value(pt, txt); auto* val = parse_attribute_value(pt, txt);
if (val != nullptr) { if (val != nullptr) {
(*(state->stack.rbegin() + 1)).aggregate_elements.push_back(val); (*(state->stack.rbegin() + 1)).aggregate_elements.push_back(val);
} }
@@ -453,7 +453,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
} }
} }
auto untyped = new IfcEntityInstanceData(decl); auto* untyped = new IfcEntityInstanceData(decl);
const IfcParse::entity* entity = decl->as_entity(); const IfcParse::entity* entity = decl->as_entity();
if (entity != nullptr) { if (entity != nullptr) {
@@ -464,8 +464,8 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
auto idx = entity->attribute_index(pair.first); auto idx = entity->attribute_index(pair.first);
if (idx != -1) { if (idx != -1) {
auto attr = entity->attribute_by_index(idx); const auto* attr = entity->attribute_by_index(idx);
auto val = parse_attribute_value(attr->type_of_attribute(), pair.second); auto* val = parse_attribute_value(attr->type_of_attribute(), pair.second);
if (val != nullptr) { if (val != nullptr) {
untyped->setArgument(idx, val); untyped->setArgument(idx, val);
} }
@@ -587,7 +587,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
} }
} else { } else {
if (IfcUtil::from_parameter_type(attribute_type) == IfcUtil::Argument_ENTITY_INSTANCE) { if (IfcUtil::from_parameter_type(attribute_type) == IfcUtil::Argument_ENTITY_INSTANCE) {
if (auto entity = attribute_type->as_named_type()->declared_type()->as_entity()) { if (const auto* entity = attribute_type->as_named_type()->declared_type()->as_entity()) {
auto inst_or_reference = create_instance(entity); auto inst_or_reference = create_instance(entity);
Argument* attr; Argument* attr;
IfcUtil::IfcBaseClass* newinst; IfcUtil::IfcBaseClass* newinst;