Retain exact attribute counts in rdb as parsed

This commit is contained in:
Thomas Krijnen
2025-08-28 11:15:05 +02:00
parent 2c6956ec02
commit b6712602e2
4 changed files with 13 additions and 5 deletions
+6 -4
View File
@@ -225,7 +225,7 @@ namespace {
}
}
IfcEntityInstanceData IfcParse::parse_context::construct(int name, unresolved_references& references_to_resolve, const IfcParse::declaration* decl, boost::optional<size_t> expected_size, int resolve_reference_index) {
IfcEntityInstanceData IfcParse::parse_context::construct(int name, unresolved_references& references_to_resolve, const IfcParse::declaration* decl, boost::optional<size_t> expected_size, int resolve_reference_index, bool coerce_attribute_count) {
std::vector<const IfcParse::parameter_type*> parameter_types;
std::unique_ptr<IfcParse::named_type> transient_named_type;
@@ -257,9 +257,11 @@ IfcEntityInstanceData IfcParse::parse_context::construct(int name, unresolved_re
return IfcEntityInstanceData(in_memory_attribute_storage(0));
}
in_memory_attribute_storage storage(decl != nullptr
in_memory_attribute_storage storage(coerce_attribute_count
? (decl != nullptr
? (std::min)(parameter_types.size(), tokens_.size())
: tokens_.size()
: tokens_.size())
: tokens_.size()
);
auto it = tokens_.begin();
@@ -635,7 +637,7 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
Logger::Status(ss.str(), false);
}
auto data = ps.construct(current_id, references_to_resolve_, entity_type, boost::none, -1);
auto data = ps.construct(current_id, references_to_resolve_, entity_type, boost::none, -1, coerce_attribute_count);
return_value.emplace(
(size_t)current_id,
+2
View File
@@ -101,6 +101,8 @@ private:
int yielded_header_instances_ = 0;
public:
bool coerce_attribute_count = true;
operator bool() const {
return good_ && !lexer_->stream->eof;
}
+1 -1
View File
@@ -184,7 +184,7 @@ namespace IfcParse {
void push(IfcUtil::IfcBaseClass* inst);
IfcEntityInstanceData construct(int name, unresolved_references& references_to_resolve, const IfcParse::declaration* decl, boost::optional<size_t> expected_size, int resolve_reference_index);
IfcEntityInstanceData construct(int name, unresolved_references& references_to_resolve, const IfcParse::declaration* decl, boost::optional<size_t> expected_size, int resolve_reference_index, bool coerce_attribute_count=true);
};
namespace impl {
+4
View File
@@ -96,6 +96,10 @@ void RocksDbSerializer::write_streaming_() {
IfcParse::InstanceStreamer streamer(input_filename);
// We do not want to coerce attribute counts here, because we want
// to store exactly what is in the file for validation purposes
streamer.coerce_attribute_count = false;
while (streamer) {
auto inst = streamer.read_instance();
if (inst) {