use ifc_model::Model;
use ifc_schema::SchemaVersion;
use crate::report::{Finding, Path, Report};
pub fn check(model: &Model, report: &mut Report) {
let header = model.header();
match header.schema_token() {
None => report.push(Finding::error(
"header.schema.missing",
Path::File,
"FILE_SCHEMA declares no schema; the file cannot be validated \
against anything",
)),
Some(token) if SchemaVersion::from_header_token(token).is_none() => {
report.push(Finding::warning(
"header.schema.unknown",
Path::File,
format!(
"schema {token:?} is not one this build recognizes; \
structural checks will be skipped"
),
));
}
Some(_) => {}
}
let level = &header.implementation_level;
if !level.is_empty() && level != "2;1" {
report.push(Finding::warning(
"header.implementation_level",
Path::File,
format!("implementation level is {level:?}; ISO 10303-21 specifies \"2;1\""),
));
}
}
#[must_use]
pub fn declared_version(model: &Model) -> Option<SchemaVersion> {
model
.header()
.schema_token()
.and_then(SchemaVersion::from_header_token)
}