mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
ifcparse: fix clang-tidy warning readability-qualified-auto
This commit is contained in:
committed by
Thomas Krijnen
parent
c29e7b32ad
commit
8b145248c6
@@ -154,13 +154,13 @@ class IFC_PARSE_API IfcBaseType : public IfcBaseClass {
|
||||
namespace IfcUtil {
|
||||
template <typename T>
|
||||
T IfcBaseEntity::get_value(const std::string& name) const {
|
||||
auto attr = get(name);
|
||||
auto* attr = get(name);
|
||||
return (T)*attr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T IfcBaseEntity::get_value(const std::string& name, const T& default_value) const {
|
||||
auto attr = get(name);
|
||||
auto* attr = get(name);
|
||||
if (attr->isNull()) {
|
||||
return default_value;
|
||||
}
|
||||
|
||||
+12
-12
@@ -755,7 +755,7 @@ size_t IfcParse::IfcFile::load(unsigned entity_instance_name, const IfcParse::en
|
||||
|
||||
if (TokenFunc::isKeyword(next)) {
|
||||
try {
|
||||
auto ea = new EntityArgument(next);
|
||||
auto* ea = new EntityArgument(next);
|
||||
addEntity(((IfcUtil::IfcBaseClass*)*ea));
|
||||
filler.push_back(ea);
|
||||
} catch (IfcException& e) {
|
||||
@@ -873,7 +873,7 @@ ArgumentList::operator aggregate_of_aggregate_of_instance::ptr() const {
|
||||
aggregate_of_instance::ptr e = *arg_list;
|
||||
l->push(e);
|
||||
} else {
|
||||
auto token = dynamic_cast<const TokenArgument*>(arg);
|
||||
const auto* token = dynamic_cast<const TokenArgument*>(arg);
|
||||
int startpos = token != nullptr ? token->token.startPos : 0;
|
||||
std::string string_rep = this->toString();
|
||||
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) {
|
||||
// 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);
|
||||
while (e != nullptr) {
|
||||
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) {
|
||||
auto e = from_entity;
|
||||
const auto* e = from_entity;
|
||||
byref_excl[inst->data().id()].push_back(id_from);
|
||||
while (e != nullptr) {
|
||||
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) {
|
||||
auto e = from_entity;
|
||||
const auto* e = from_entity;
|
||||
while (e != nullptr) {
|
||||
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);
|
||||
@@ -1799,7 +1799,7 @@ class traversal_recorder {
|
||||
return list_;
|
||||
}
|
||||
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);
|
||||
}
|
||||
return l;
|
||||
@@ -2174,8 +2174,8 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
|
||||
void IfcFile::process_deletion_() {
|
||||
|
||||
for (auto& id : batch_deletion_ids_.get<0>()) {
|
||||
auto entity = instance_by_id(id);
|
||||
for (const auto& id : batch_deletion_ids_.get<0>()) {
|
||||
auto* entity = instance_by_id(id);
|
||||
|
||||
aggregate_of_instance::ptr references = instances_by_reference(id);
|
||||
|
||||
@@ -2425,7 +2425,7 @@ IfcFile::~IfcFile() {
|
||||
for (const auto& pair : byidentity) {
|
||||
entities_to_delete.insert(pair.second);
|
||||
}
|
||||
for (auto entity : entities_to_delete) {
|
||||
for (auto* entity : entities_to_delete) {
|
||||
delete entity;
|
||||
}
|
||||
delete stream;
|
||||
@@ -2521,7 +2521,7 @@ std::vector<int> IfcFile::get_inverse_indices(int 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());
|
||||
if (it == mapping.end() || it->second.empty()) {
|
||||
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) {
|
||||
if (attr->declaration().as_entity() != nullptr) {
|
||||
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());
|
||||
while (decl != nullptr) {
|
||||
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() {
|
||||
for (auto& pair : *this) {
|
||||
for (const auto& pair : *this) {
|
||||
build_inverses_(pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@ bool IfcParse::named_type::is(const IfcParse::declaration& decl) const {
|
||||
}
|
||||
|
||||
IfcParse::entity::~entity() {
|
||||
for (auto attribute : attributes_) {
|
||||
for (const auto* attribute : attributes_) {
|
||||
delete attribute;
|
||||
}
|
||||
for (auto inverse_attribute : inverse_attributes_) {
|
||||
for (const auto* inverse_attribute : inverse_attributes_) {
|
||||
delete inverse_attribute;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
auto v = new IfcWrite::IfcWriteArgument();
|
||||
auto* v = new IfcWrite::IfcWriteArgument();
|
||||
|
||||
auto cpp_type = IfcUtil::from_parameter_type(ty);
|
||||
|
||||
if (cpp_type == IfcUtil::Argument_STRING) {
|
||||
v->set(value);
|
||||
} 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(
|
||||
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) {
|
||||
const auto& back = state->stack.back();
|
||||
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;
|
||||
for (auto& elem : elems) {
|
||||
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)) {
|
||||
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;
|
||||
try {
|
||||
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);
|
||||
}
|
||||
} 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);
|
||||
if (cpp_type != IfcUtil::Argument_ENTITY_INSTANCE) {
|
||||
auto val = parse_attribute_value(pt, txt);
|
||||
auto* val = parse_attribute_value(pt, txt);
|
||||
if (val != nullptr) {
|
||||
state->stack.back().inst()->data().setArgument(state->stack.back().idx(), val);
|
||||
}
|
||||
}
|
||||
} else if (state_type == stack_node::node_aggregate_element) {
|
||||
auto pt = state->stack.back().aggregate_elem_type();
|
||||
auto val = parse_attribute_value(pt, txt);
|
||||
const auto* pt = state->stack.back().aggregate_elem_type();
|
||||
auto* val = parse_attribute_value(pt, txt);
|
||||
if (val != nullptr) {
|
||||
(*(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();
|
||||
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);
|
||||
if (idx != -1) {
|
||||
auto attr = entity->attribute_by_index(idx);
|
||||
auto val = parse_attribute_value(attr->type_of_attribute(), pair.second);
|
||||
const auto* attr = entity->attribute_by_index(idx);
|
||||
auto* val = parse_attribute_value(attr->type_of_attribute(), pair.second);
|
||||
if (val != nullptr) {
|
||||
untyped->setArgument(idx, val);
|
||||
}
|
||||
@@ -587,7 +587,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
Argument* attr;
|
||||
IfcUtil::IfcBaseClass* newinst;
|
||||
|
||||
Reference in New Issue
Block a user