Skip to main content

Module coerce

Module coerce 

Source
Expand description

Plain host values written by name, coerced against the declared type (#342).

A tagged value says exactly what it is: Text or Enum, Integer or Real, IFCLABEL('x') or 'x'. A host’s plain value does not: Python’s "STANDARD" could be either of the first pair, 1 either of the second. IfcModel::set_attribute_by_name_plain settles it from the attribute’s declared EXPRESS type in the release the header declares (ifc::attribute_type), and refuses what the declaration cannot settle.

§The rules

Plain valueDeclared typeWritten
anythrough a defined typeas for the type it aliases, bare: IfcLabel takes 'x'
stringSTRINGtext
stringan enumerationthe item it names (any case), else type-mismatch
integerINTEGER, NUMBERinteger
integerREALreal, when exact (within 2^53), else type-mismatch
floatREAL, NUMBERreal
boolBOOLEAN, LOGICAL.T. / .F.
listan aggregateeach element coerced against the element type
entity handlean entitya reference, when the target exists (missing-reference) and is of the type or a subtype (type-mismatch)
entity handlea SELECTa reference, when an entity member accepts the target
othera SELECTthe one member that accepts it, as a typed parameter (IFCLABEL('x')); several: ambiguous-value, naming them
nullany$

Anything else is type-mismatch: a float for an INTEGER, a string for a REAL, any plain value for BINARY (write a binary explicitly). A declared type the tables do not resolve is unsupported. Typed parameters appear only in a SELECT, as ISO 10303-21 §12.1.8 writes them; everywhere else the value is bare (§12.1.6, §12.1.7).

Plain::Exact carries a tagged value through unchanged, nested in a list too, so a caller keeps exact control where it wants it.

Enums§

Plain
A host value before coercion: what a host language holds without saying which IFC type it means.