Skip to main content

ifc_xml/
profile.rs

1//! Supported ifcXML release profiles.
2
3/// A release-specific ifcXML namespace/profile contract.
4///
5/// A profile fixes the namespace and schema token, not the layout: native
6/// output under a profile is not valid against the release XSD. The XSD's
7/// own configuration is a separate layout ([`crate::XmlLayout::Xsd`]),
8/// which this crate reads and writes.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10#[non_exhaustive]
11pub enum XmlProfile {
12    /// IFC4 ADD2 TC1, whose namespace the official XSD (`IFC4.xsd`) declares.
13    Ifc4Add2Tc1,
14    /// IFC4.3 ADD2, whose namespace its official XSD (`IFC4X3_ADD2.xsd`)
15    /// declares.
16    Ifc4x3Add2,
17}
18
19impl XmlProfile {
20    /// The exact XML namespace declared by the release XSD.
21    #[must_use]
22    pub const fn namespace(self) -> &'static str {
23        match self {
24            Self::Ifc4Add2Tc1 => {
25                "https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/XML"
26            }
27            Self::Ifc4x3Add2 => "https://standards.buildingsmart.org/IFC/RELEASE/IFC4/3/ADD2",
28        }
29    }
30
31    /// Every namespace an XSD-configuration document of this release may
32    /// declare, [`Self::namespace`] first.
33    ///
34    /// IFC4 ADD2 TC1 also accepts `http://www.buildingsmart-tech.org/ifcXML/IFC4/Add2`:
35    /// the release's own published examples (Annex E of the ADD2 TC1
36    /// documentation) declare it, as the XSD did before its namespace moved
37    /// to the `standards.buildingsmart.org` URL. Only the XSD layout reader
38    /// accepts it, and its writer writes [`Self::namespace`]; this crate's
39    /// own layout is checked against [`Self::namespace`] alone.
40    #[must_use]
41    pub const fn namespaces(self) -> &'static [&'static str] {
42        match self {
43            Self::Ifc4Add2Tc1 => &[
44                "https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/XML",
45                "http://www.buildingsmart-tech.org/ifcXML/IFC4/Add2",
46            ],
47            Self::Ifc4x3Add2 => &["https://standards.buildingsmart.org/IFC/RELEASE/IFC4/3/ADD2"],
48        }
49    }
50
51    /// The canonical IFC schema token carried by this codec's root metadata.
52    #[must_use]
53    pub const fn schema_token(self) -> &'static str {
54        match self {
55            Self::Ifc4Add2Tc1 => "IFC4",
56            Self::Ifc4x3Add2 => "IFC4X3_ADD2",
57        }
58    }
59
60    /// The schema release this profile's documents are written against.
61    #[cfg(feature = "schema")]
62    #[must_use]
63    pub const fn version(self) -> ifc_schema::SchemaVersion {
64        match self {
65            Self::Ifc4Add2Tc1 => ifc_schema::SchemaVersion::Ifc4,
66            Self::Ifc4x3Add2 => ifc_schema::SchemaVersion::Ifc4x3,
67        }
68    }
69}