mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Check for valid stream before streaming
This commit is contained in:
+12
-10
@@ -137,18 +137,20 @@ public:
|
|||||||
, progress_(0)
|
, progress_(0)
|
||||||
{
|
{
|
||||||
good_ = file_open_status::NO_HEADER;
|
good_ = file_open_status::NO_HEADER;
|
||||||
header_ = new IfcParse::IfcSpfHeader(lexer_);
|
if (*stream_) {
|
||||||
if (header_->tryRead() && header_->file_schema()->schema_identifiers().size() == 1) {
|
header_ = new IfcParse::IfcSpfHeader(lexer_);
|
||||||
try {
|
if (header_->tryRead() && header_->file_schema()->schema_identifiers().size() == 1) {
|
||||||
schema_ = IfcParse::schema_by_name(header_->file_schema()->schema_identifiers().front());
|
try {
|
||||||
good_ = file_open_status::SUCCESS;
|
schema_ = IfcParse::schema_by_name(header_->file_schema()->schema_identifiers().front());
|
||||||
} catch (const IfcParse::IfcException&) {
|
good_ = file_open_status::SUCCESS;
|
||||||
|
} catch (const IfcParse::IfcException&) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
storage_.file = nullptr;
|
||||||
|
storage_.schema = schema_;
|
||||||
|
storage_.tokens = lexer_;
|
||||||
|
storage_.references_to_resolve = &references_to_resolve_;
|
||||||
}
|
}
|
||||||
storage_.file = nullptr;
|
|
||||||
storage_.schema = schema_;
|
|
||||||
storage_.tokens = lexer_;
|
|
||||||
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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user