mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
Retain exact attribute counts in rdb as parsed
This commit is contained in:
@@ -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::vector<const IfcParse::parameter_type*> parameter_types;
|
||||||
std::unique_ptr<IfcParse::named_type> transient_named_type;
|
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));
|
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())
|
? (std::min)(parameter_types.size(), tokens_.size())
|
||||||
: tokens_.size()
|
: tokens_.size())
|
||||||
|
: tokens_.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
auto it = tokens_.begin();
|
auto it = tokens_.begin();
|
||||||
@@ -635,7 +637,7 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
|
|||||||
Logger::Status(ss.str(), false);
|
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(
|
return_value.emplace(
|
||||||
(size_t)current_id,
|
(size_t)current_id,
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ private:
|
|||||||
int yielded_header_instances_ = 0;
|
int yielded_header_instances_ = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool coerce_attribute_count = true;
|
||||||
|
|
||||||
operator bool() const {
|
operator bool() const {
|
||||||
return good_ && !lexer_->stream->eof;
|
return good_ && !lexer_->stream->eof;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ namespace IfcParse {
|
|||||||
|
|
||||||
void push(IfcUtil::IfcBaseClass* inst);
|
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 {
|
namespace impl {
|
||||||
|
|||||||
@@ -96,6 +96,10 @@ void RocksDbSerializer::write_streaming_() {
|
|||||||
|
|
||||||
IfcParse::InstanceStreamer streamer(input_filename);
|
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) {
|
while (streamer) {
|
||||||
auto inst = streamer.read_instance();
|
auto inst = streamer.read_instance();
|
||||||
if (inst) {
|
if (inst) {
|
||||||
|
|||||||
Reference in New Issue
Block a user