mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 22:50:56 +00:00
Initialization of header and file
This commit is contained in:
@@ -727,7 +727,7 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, std::shared_ptr<I
|
|||||||
Logger::Status(ss.str(), false);
|
Logger::Status(ss.str(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto data = ps.construct(owner, current_id, references_to_resolve_, entity_type, std::nullopt, -1, coerce_attribute_count);
|
auto data = ps.construct(owner_, current_id, references_to_resolve_, entity_type, std::nullopt, -1, coerce_attribute_count);
|
||||||
|
|
||||||
return_value.emplace(
|
return_value.emplace(
|
||||||
(size_t)current_id,
|
(size_t)current_id,
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ private:
|
|||||||
FileReader* stream_;
|
FileReader* stream_;
|
||||||
IfcSpfLexer* lexer_;
|
IfcSpfLexer* lexer_;
|
||||||
IfcSpfHeader* header_;
|
IfcSpfHeader* header_;
|
||||||
|
IfcParse::IfcFile* owner_;
|
||||||
boost::circular_buffer<Token> token_stream_;
|
boost::circular_buffer<Token> token_stream_;
|
||||||
const IfcParse::schema_definition* schema_;
|
const IfcParse::schema_definition* schema_;
|
||||||
IfcParse::impl::in_memory_file_storage storage_;
|
IfcParse::impl::in_memory_file_storage storage_;
|
||||||
@@ -103,7 +104,6 @@ private:
|
|||||||
std::vector<unsigned> bypassed_instances_;
|
std::vector<unsigned> bypassed_instances_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IfcParse::IfcFile* owner = nullptr;
|
|
||||||
bool coerce_attribute_count = true;
|
bool coerce_attribute_count = true;
|
||||||
|
|
||||||
operator bool() const {
|
operator bool() const {
|
||||||
@@ -145,13 +145,13 @@ private:
|
|||||||
|
|
||||||
void pushPage(const std::string& page);
|
void pushPage(const std::string& page);
|
||||||
|
|
||||||
InstanceStreamer();
|
InstanceStreamer(IfcParse::IfcFile* f = nullptr);
|
||||||
|
|
||||||
InstanceStreamer(const std::string& fn, bool mmap=false);
|
InstanceStreamer(const std::string& fn, bool mmap = false, IfcParse::IfcFile* f = nullptr);
|
||||||
|
|
||||||
InstanceStreamer(void* data, int length);
|
InstanceStreamer(void* data, int length, IfcParse::IfcFile* f = nullptr);
|
||||||
|
|
||||||
InstanceStreamer(const IfcParse::schema_definition* schema, IfcParse::IfcSpfLexer* lexer);
|
InstanceStreamer(const IfcParse::schema_definition* schema, IfcParse::IfcSpfLexer* lexer, IfcParse::IfcFile* f = nullptr);
|
||||||
|
|
||||||
void bypassTypes(const std::set<std::string>& type_names);
|
void bypassTypes(const std::set<std::string>& type_names);
|
||||||
|
|
||||||
|
|||||||
+16
-11
@@ -1264,6 +1264,7 @@ IfcFile::IfcFile(const std::string& path, filetype ty, bool readonly)
|
|||||||
IfcFile::IfcFile(std::istream& stream, int length)
|
IfcFile::IfcFile(std::istream& stream, int length)
|
||||||
: schema_(nullptr)
|
: schema_(nullptr)
|
||||||
, max_id_(0)
|
, max_id_(0)
|
||||||
|
, header_(new IfcParse::IfcSpfHeader(this))
|
||||||
{
|
{
|
||||||
FileReader s(FileReader::caller_fed_tag{});
|
FileReader s(FileReader::caller_fed_tag{});
|
||||||
|
|
||||||
@@ -1284,7 +1285,8 @@ IfcFile::IfcFile(std::istream& stream, int length)
|
|||||||
|
|
||||||
IfcFile::IfcFile(void* data, int length)
|
IfcFile::IfcFile(void* data, int length)
|
||||||
: schema_(nullptr)
|
: schema_(nullptr)
|
||||||
, max_id_(0)
|
, max_id_(0),
|
||||||
|
header_(new IfcParse::IfcSpfHeader(this))
|
||||||
{
|
{
|
||||||
FileReader s(std::string((char*)data, length), FileReader::caller_fed_tag{});
|
FileReader s(std::string((char*)data, length), FileReader::caller_fed_tag{});
|
||||||
|
|
||||||
@@ -1409,23 +1411,25 @@ void IfcParse::InstanceStreamer::pushPage(const std::string& page)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcParse::InstanceStreamer::InstanceStreamer()
|
IfcParse::InstanceStreamer::InstanceStreamer(IfcParse::IfcFile* f)
|
||||||
: stream_(new FileReader(FileReader::caller_fed_tag{}))
|
: stream_(new FileReader(FileReader::caller_fed_tag{}))
|
||||||
, lexer_(new IfcSpfLexer(stream_))
|
, lexer_(new IfcSpfLexer(stream_))
|
||||||
, token_stream_(3, Token{})
|
, token_stream_(3, Token{})
|
||||||
, schema_(nullptr)
|
, schema_(nullptr)
|
||||||
, progress_(0)
|
, progress_(0)
|
||||||
|
, owner_(f)
|
||||||
{
|
{
|
||||||
init_locale();
|
init_locale();
|
||||||
good_ = file_open_status::NO_HEADER;
|
good_ = file_open_status::NO_HEADER;
|
||||||
|
storage_.file = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcParse::InstanceStreamer::InstanceStreamer(const std::string& fn, bool mmap)
|
IfcParse::InstanceStreamer::InstanceStreamer(const std::string& fn, bool mmap, IfcParse::IfcFile* f)
|
||||||
: stream_(mmap ? new FileReader(fn, FileReader::mmap_tag{}) : new FileReader(fn))
|
: stream_(mmap ? new FileReader(fn, FileReader::mmap_tag{}) : new FileReader(fn))
|
||||||
, lexer_(new IfcSpfLexer(stream_))
|
, lexer_(new IfcSpfLexer(stream_))
|
||||||
, token_stream_(3, Token{})
|
, token_stream_(3, Token{})
|
||||||
, schema_(nullptr)
|
, schema_(nullptr)
|
||||||
, progress_(0)
|
, progress_(0), owner_(f)
|
||||||
{
|
{
|
||||||
init_locale();
|
init_locale();
|
||||||
|
|
||||||
@@ -1439,19 +1443,20 @@ IfcParse::InstanceStreamer::InstanceStreamer(const std::string& fn, bool mmap)
|
|||||||
} catch (const IfcParse::IfcException&) {
|
} catch (const IfcParse::IfcException&) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage_.file = nullptr;
|
storage_.file = f;
|
||||||
storage_.schema = schema_;
|
storage_.schema = schema_;
|
||||||
storage_.tokens = lexer_;
|
storage_.tokens = lexer_;
|
||||||
storage_.references_to_resolve = &references_to_resolve_;
|
storage_.references_to_resolve = &references_to_resolve_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcParse::InstanceStreamer::InstanceStreamer(void* data, int length)
|
IfcParse::InstanceStreamer::InstanceStreamer(void* data, int length, IfcParse::IfcFile* f)
|
||||||
: stream_(new FileReader(std::string((char*) data, length), FileReader::caller_fed_tag{}))
|
: stream_(new FileReader(std::string((char*) data, length), FileReader::caller_fed_tag{}))
|
||||||
, lexer_(new IfcSpfLexer(stream_))
|
, lexer_(new IfcSpfLexer(stream_))
|
||||||
, token_stream_(3, Token{})
|
, token_stream_(3, Token{})
|
||||||
, schema_(nullptr)
|
, schema_(nullptr)
|
||||||
, progress_(0)
|
, progress_(0)
|
||||||
|
, owner_(f)
|
||||||
{
|
{
|
||||||
init_locale();
|
init_locale();
|
||||||
|
|
||||||
@@ -1465,24 +1470,25 @@ IfcParse::InstanceStreamer::InstanceStreamer(void* data, int length)
|
|||||||
} catch (const IfcParse::IfcException&) {
|
} catch (const IfcParse::IfcException&) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage_.file = nullptr;
|
storage_.file = f;
|
||||||
storage_.schema = schema_;
|
storage_.schema = schema_;
|
||||||
storage_.tokens = lexer_;
|
storage_.tokens = lexer_;
|
||||||
storage_.references_to_resolve = &references_to_resolve_;
|
storage_.references_to_resolve = &references_to_resolve_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcParse::InstanceStreamer::InstanceStreamer(const IfcParse::schema_definition* schema, IfcParse::IfcSpfLexer* lexer)
|
IfcParse::InstanceStreamer::InstanceStreamer(const IfcParse::schema_definition* schema, IfcParse::IfcSpfLexer* lexer, IfcParse::IfcFile* f)
|
||||||
: stream_(nullptr)
|
: stream_(nullptr)
|
||||||
, lexer_(lexer)
|
, lexer_(lexer)
|
||||||
, header_(nullptr)
|
, header_(nullptr)
|
||||||
, token_stream_(3, Token{})
|
, token_stream_(3, Token{})
|
||||||
, schema_(schema)
|
, schema_(schema)
|
||||||
, progress_(0)
|
, progress_(0)
|
||||||
|
, owner_(f)
|
||||||
{
|
{
|
||||||
init_locale();
|
init_locale();
|
||||||
|
|
||||||
storage_.file = nullptr;
|
storage_.file = f;
|
||||||
storage_.schema = schema_;
|
storage_.schema = schema_;
|
||||||
storage_.tokens = lexer_;
|
storage_.tokens = lexer_;
|
||||||
storage_.references_to_resolve = &references_to_resolve_;
|
storage_.references_to_resolve = &references_to_resolve_;
|
||||||
@@ -1533,8 +1539,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
|||||||
|
|
||||||
auto ifcroot_type_ = schema->declaration_by_name("IfcRoot");
|
auto ifcroot_type_ = schema->declaration_by_name("IfcRoot");
|
||||||
|
|
||||||
InstanceStreamer streamer(schema, tokens);
|
InstanceStreamer streamer(schema, tokens, file);
|
||||||
streamer.owner = file;
|
|
||||||
streamer.bypassTypes(typed_to_bypass);
|
streamer.bypassTypes(typed_to_bypass);
|
||||||
|
|
||||||
Logger::Status("Scanning file...");
|
Logger::Status("Scanning file...");
|
||||||
|
|||||||
Reference in New Issue
Block a user