ifc_schema/lib.rs
1//! `ifc-schema` — the IFC schema **as data**, not as 2,500 generated structs.
2//!
3//! # The decision
4//!
5//! IfcOpenShell generates a class per IFC entity per schema version. That is a
6//! very large amount of code, and it must be regenerated for every schema
7//! release. This crate instead reads the normative EXPRESS files into tables
8//! and answers questions against them.
9//!
10//! The evidence that this is the right call: IFC4x3 renames
11//! `IfcBuildingElement` to `IfcBuiltElement` and drops `IfcProxy` and the whole
12//! `*StandardCase` family. Generated types would fork the entire API surface;
13//! a table just holds different rows.
14//!
15//! # What this crate is for
16//!
17//! | Module | Role |
18//! | --- | --- |
19//! | [`version`] | Which schema a file declares |
20//! | [`express`] | Parser for the official `.exp` files |
21//! | [`entity`] | Entity descriptors: name, supertype, slots |
22//! | [`attribute`] | Attribute descriptors and declared types |
23//! | [`types`] | Defined types, enumerations, selects |
24//! | [`registry`] | The assembled, queryable schema |
25//! | `inheritance` | Supertype-chain walking |
26//!
27//! # Relationship to the model
28//!
29//! `ifc-model` does **not** depend on this crate.
30//! The model stores whatever a file contains, valid or not. The schema is what
31//! you consult to *interpret* what was stored, and it is optional: a file whose
32//! schema is unknown still parses, and its entities still round-trip.
33//!
34//! ```
35//! use ifc_schema::Schema;
36//!
37//! let schema = Schema::from_express(
38//! "SCHEMA IFC4;\n\
39//! ENTITY IfcRoot; GlobalId : IfcGloballyUniqueId; END_ENTITY;\n\
40//! ENTITY IfcWall SUBTYPE OF (IfcRoot); Name : IfcLabel; END_ENTITY;\n\
41//! END_SCHEMA;",
42//! );
43//!
44//! assert!(schema.is_a("IFCWALL", "IfcRoot"));
45//! assert_eq!(schema.attribute_names("IfcWall"), ["GlobalId", "Name"]);
46//! ```
47
48#[cfg(feature = "ifc4")]
49mod artifact;
50pub mod attribute;
51#[cfg(feature = "ifc4")]
52mod bundled;
53pub mod entity;
54pub mod express;
55mod inheritance;
56pub mod registry;
57pub mod types;
58pub mod version;
59
60#[cfg(feature = "ifc4")]
61pub use artifact::decode_schema as artifact_decode_schema;
62#[cfg(feature = "generation")]
63pub use artifact::encode_schema as artifact_encode_schema;
64pub use attribute::Attribute;
65#[cfg(feature = "ifc4")]
66pub use bundled::{for_version, ifc2x3, ifc4, ifc4x3};
67pub use entity::EntityDef;
68pub use registry::Schema;
69pub use types::{TypeDef, TypeKind};
70pub use version::SchemaVersion;