@nb copied from IfcEntityInstanceData.cpp but operating on unresolved instances
| 32 | namespace { |
| 33 | // @nb copied from IfcEntityInstanceData.cpp but operating on unresolved instances |
| 34 | bool serialize(std::string& val, const IfcParse::reference_or_simple_type& t) |
| 35 | { |
| 36 | auto s = sizeof(size_t); |
| 37 | val.resize(s + 2); |
| 38 | val[0] = TypeEncoder::encode_type<IfcUtil::IfcBaseClass*>(); |
| 39 | // 1 = entity - stored by id (entity name) |
| 40 | // 2 = type - stored by identity (internal counter in class) |
| 41 | val[1] = t.index() == 0 ? 'i' : 't'; |
| 42 | size_t iden; |
| 43 | if (auto* name = std::get_if<IfcParse::InstanceReference>(&t)) { |
| 44 | iden = *name; |
| 45 | } else if (auto* inst = std::get_if<IfcUtil::IfcBaseClass*>(&t)) { |
| 46 | iden = (*inst)->identity(); |
| 47 | } |
| 48 | memcpy(val.data() + 2, &iden, s); |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | bool serialize(std::string& val, const std::vector<IfcParse::reference_or_simple_type>& t) |
| 53 | { |