Check for valid stream before streaming

This commit is contained in:
Thomas Krijnen
2025-09-04 16:49:00 +02:00
parent 09f9b23153
commit 26467a1d0e
2 changed files with 14 additions and 10 deletions
+2
View File
@@ -137,6 +137,7 @@ public:
, progress_(0) , progress_(0)
{ {
good_ = file_open_status::NO_HEADER; good_ = file_open_status::NO_HEADER;
if (*stream_) {
header_ = new IfcParse::IfcSpfHeader(lexer_); header_ = new IfcParse::IfcSpfHeader(lexer_);
if (header_->tryRead() && header_->file_schema()->schema_identifiers().size() == 1) { if (header_->tryRead() && header_->file_schema()->schema_identifiers().size() == 1) {
try { try {
@@ -150,6 +151,7 @@ public:
storage_.tokens = lexer_; storage_.tokens = lexer_;
storage_.references_to_resolve = &references_to_resolve_; storage_.references_to_resolve = &references_to_resolve_;
} }
}
InstanceStreamer(const IfcParse::schema_definition* schema, IfcParse::IfcSpfLexer* lexer) InstanceStreamer(const IfcParse::schema_definition* schema, IfcParse::IfcSpfLexer* lexer)
: stream_(nullptr) : stream_(nullptr)
+2
View File
@@ -76,6 +76,8 @@ class IFC_PARSE_API IfcSpfStream {
bool is_eof_at(unsigned int) const; bool is_eof_at(unsigned int) const;
void increment_at(unsigned int&); void increment_at(unsigned int&);
char peek_at(unsigned int); char peek_at(unsigned int);
operator bool() const { return valid && !eof; }
}; };
} // namespace IfcParse } // namespace IfcParse