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

Function serialize

src/serializers/RocksDbSerializer.cpp:34–50  ·  view source on GitHub ↗

@nb copied from IfcEntityInstanceData.cpp but operating on unresolved instances

Source from the content-addressed store, hash-verified

32namespace {
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 {

Callers 1

write_streaming_Method · 0.70

Calls 9

resizeMethod · 0.80
indexMethod · 0.80
dataMethod · 0.80
putMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
writeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected