#1311 better error handling during parse for schema and header

This commit is contained in:
Thomas Krijnen
2021-02-15 11:11:14 +01:00
parent 459faec01a
commit bfc695c756
3 changed files with 68 additions and 16 deletions
+33 -2
View File
@@ -33,6 +33,36 @@
namespace IfcParse {
class IFC_PARSE_API file_open_status {
public:
enum file_open_enum {
SUCCESS,
READ_ERROR,
NO_HEADER,
UNSUPPORTED_SCHEMA
};
private:
file_open_enum error_;
public:
file_open_status(file_open_enum error)
: error_(error)
{}
operator file_open_enum() const {
return error_;
}
file_open_enum value() const {
return error_;
}
operator bool() const {
return error_ == SUCCESS;
}
};
/// This class provides several static convenience functions and variables
/// and provide access to the entities in an IFC file
class IFC_PARSE_API IfcFile {
@@ -78,7 +108,8 @@ public:
private:
typedef std::map<IfcUtil::IfcBaseClass*, IfcUtil::IfcBaseClass*> entity_entity_map_t;
bool parsing_complete_, good_;
bool parsing_complete_;
file_open_status good_ = file_open_status::SUCCESS;
const IfcParse::schema_definition* schema_;
const IfcParse::declaration* ifcroot_type_;
@@ -116,7 +147,7 @@ public:
virtual ~IfcFile();
bool good() const { return good_; }
file_open_status good() const { return good_; }
/// Returns the first entity in the file, this probably is the entity
/// with the lowest id (EXPRESS ENTITY_INSTANCE_NAME)