MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / dispatch_token

Function dispatch_token

src/ifcparse/IfcFile.cpp:59–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58 template <typename Fn>
59 void dispatch_token(boost::optional<size_t> instance_id, int attribute_id, IfcParse::Token t, IfcParse::declaration* decl, Fn fn) {
60 if (t.type == IfcParse::Token_BINARY) {
61 fn(IfcParse::TokenFunc::asBinary(t));
62 } else if (IfcParse::TokenFunc::isBool(t)) {
63 fn(IfcParse::TokenFunc::asBool(t));
64 } else if (IfcParse::TokenFunc::isLogical(t)) {
65 fn(IfcParse::TokenFunc::asLogical(t));
66 } else if (t.type == IfcParse::Token_ENUMERATION) {
67 auto& s = IfcParse::TokenFunc::asStringRef(t);
68 if (decl && decl->as_enumeration_type()) {
69 try {
70 fn(EnumerationReference(decl->as_enumeration_type(), decl->as_enumeration_type()->lookup_enum_offset(s)));
71 } catch (IfcParse::IfcException& e) {
72 Logger::Error("An enumeration literal '" + s + "' is not valid for type '" + decl->name() + "' at offset " + std::to_string(t.startPos));
73 }
74 } else {
75 Logger::Error("An enumeration literal '" + s + "' is not expected at attribute index '" + std::to_string(attribute_id) + "' at offset " + std::to_string(t.startPos));
76 }
77 } else if (t.type == IfcParse::Token_FLOAT) {
78 fn(IfcParse::TokenFunc::asFloat(t));
79 } else if (t.type == IfcParse::Token_IDENTIFIER) {
80 fn(IfcParse::reference_or_simple_type{ IfcParse::InstanceReference{ IfcParse::TokenFunc::asIdentifier(t), t.startPos } });
81 } else if (t.type == IfcParse::Token_INT) {
82 fn(IfcParse::TokenFunc::asInt(t));
83 } else if (t.type == IfcParse::Token_STRING) {
84 fn(IfcParse::TokenFunc::asStringRef(t));
85 } else if (t.type == IfcParse::Token_OPERATOR && t.value_char == '*') {
86 // This is only in place for the validator
87 fn(Derived{});
88 }
89 }
90
91 template <size_t Depth, typename Fn>
92 void construct_(boost::optional<size_t> instance_id, int attribute_id, IfcParse::parse_context& p, const IfcParse::aggregation_type* aggr, Fn fn) {

Callers 2

construct_Function · 0.85
constructMethod · 0.85

Calls 4

fnFunction · 0.85
to_stringFunction · 0.85
ErrorFunction · 0.70
nameMethod · 0.45

Tested by

no test coverage detected