mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 08:13:14 +00:00
Initialize file schema to nullptr, wire up guid map
This commit is contained in:
@@ -1343,7 +1343,9 @@ IfcFile::IfcFile(const std::string& fn, bool mmap) {
|
|||||||
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s);
|
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
IfcFile::IfcFile(const std::string& path, filetype ty) {
|
IfcFile::IfcFile(const std::string& path, filetype ty)
|
||||||
|
: schema_(nullptr)
|
||||||
|
{
|
||||||
// @todo allow for rocksdb from path
|
// @todo allow for rocksdb from path
|
||||||
if (ty == FT_AUTODETECT) {
|
if (ty == FT_AUTODETECT) {
|
||||||
ty = guess_file_type(path);
|
ty = guess_file_type(path);
|
||||||
@@ -1355,9 +1357,12 @@ IfcFile::IfcFile(const std::string& path, filetype ty) {
|
|||||||
std::get<impl::in_memory_file_storage>(storage_).file = this;
|
std::get<impl::in_memory_file_storage>(storage_).file = this;
|
||||||
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
|
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
|
||||||
|
|
||||||
// @todo unify these names, it's already confusing enough as it stands
|
if (std::get<impl::in_memory_file_storage>(storage_).good_) {
|
||||||
byid_ = decltype(byid_)(&std::get<impl::in_memory_file_storage>(storage_).byid_);
|
// @todo unify these names, it's already confusing enough as it stands
|
||||||
byref_excl_ = decltype(byref_excl_)(&std::get<impl::in_memory_file_storage>(storage_).byref_excl_);
|
byid_ = decltype(byid_)(&std::get<impl::in_memory_file_storage>(storage_).byid_);
|
||||||
|
byref_excl_ = decltype(byref_excl_)(&std::get<impl::in_memory_file_storage>(storage_).byref_excl_);
|
||||||
|
byguid_ = decltype(byguid_)(&std::get<impl::in_memory_file_storage>(storage_).byguid_);
|
||||||
|
}
|
||||||
// byidentity_ = decltype(byidentity_)(&std::get<impl::in_memory_file_storage>(storage_).byidentity_);
|
// byidentity_ = decltype(byidentity_)(&std::get<impl::in_memory_file_storage>(storage_).byidentity_);
|
||||||
} else if (ty == FT_ROCKSDB) {
|
} else if (ty == FT_ROCKSDB) {
|
||||||
// @todo this can only be used for databases that already exist, because otherwise there is no way to specify the schema
|
// @todo this can only be used for databases that already exist, because otherwise there is no way to specify the schema
|
||||||
@@ -1366,6 +1371,7 @@ IfcFile::IfcFile(const std::string& path, filetype ty) {
|
|||||||
|
|
||||||
byid_ = decltype(byid_)(&std::get<impl::rocks_db_file_storage>(storage_).instance_by_name_);
|
byid_ = decltype(byid_)(&std::get<impl::rocks_db_file_storage>(storage_).instance_by_name_);
|
||||||
byref_excl_ = decltype(byref_excl_)(&std::get<impl::rocks_db_file_storage>(storage_).byref_excl_);
|
byref_excl_ = decltype(byref_excl_)(&std::get<impl::rocks_db_file_storage>(storage_).byref_excl_);
|
||||||
|
byguid_ = decltype(byguid_)(&std::get<impl::rocks_db_file_storage>(storage_).byguid_);
|
||||||
// byidentity_ = decltype(byidentity_)(&std::get<impl::rocks_db_file_storage>(storage_).instance_cache_);
|
// byidentity_ = decltype(byidentity_)(&std::get<impl::rocks_db_file_storage>(storage_).instance_cache_);
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error("Unsupported file format");
|
throw std::runtime_error("Unsupported file format");
|
||||||
@@ -1376,21 +1382,27 @@ IfcFile::IfcFile(const std::string& path, filetype ty) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IfcFile::IfcFile(std::istream& stream, int length) {
|
IfcFile::IfcFile(std::istream& stream, int length)
|
||||||
|
: schema_(nullptr)
|
||||||
|
{
|
||||||
IfcSpfStream s(stream, length);
|
IfcSpfStream s(stream, length);
|
||||||
storage_.emplace<1>();
|
storage_.emplace<1>();
|
||||||
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
|
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
|
||||||
ifcroot_type_ = schema_->declaration_by_name("IfcRoot");
|
ifcroot_type_ = schema_->declaration_by_name("IfcRoot");
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcFile::IfcFile(void* data, int length) {
|
IfcFile::IfcFile(void* data, int length)
|
||||||
|
: schema_(nullptr)
|
||||||
|
{
|
||||||
IfcSpfStream s(data, length);
|
IfcSpfStream s(data, length);
|
||||||
storage_.emplace<1>();
|
storage_.emplace<1>();
|
||||||
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
|
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
|
||||||
ifcroot_type_ = schema_->declaration_by_name("IfcRoot");
|
ifcroot_type_ = schema_->declaration_by_name("IfcRoot");
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcFile::IfcFile(IfcParse::IfcSpfStream* s) {
|
IfcFile::IfcFile(IfcParse::IfcSpfStream* s)
|
||||||
|
: schema_(nullptr)
|
||||||
|
{
|
||||||
storage_.emplace<1>();
|
storage_.emplace<1>();
|
||||||
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(s, schema_, max_id_);
|
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(s, schema_, max_id_);
|
||||||
ifcroot_type_ = schema_->declaration_by_name("IfcRoot");
|
ifcroot_type_ = schema_->declaration_by_name("IfcRoot");
|
||||||
@@ -1463,7 +1475,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::IfcSpfSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema == 0) {
|
if (schema == nullptr) {
|
||||||
Logger::Message(Logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
|
Logger::Message(Logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user