MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / Serialize

Method Serialize

Exporter/Binary/CoverageDataSerializer.cpp:96–124  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

94
95 //-------------------------------------------------------------------------
96 void CoverageDataSerializer::Serialize(
97 const Plugin::CoverageData& coverageData,
98 const std::filesystem::path& output) const
99 {
100 pb::CoverageData coverageDataProtoBuff;
101 Tools::CreateParentFolderIfNeeded(output);
102
103 std::ofstream ofs(output.string(), std::ios::binary);
104 if (!ofs)
105 throw InvalidOutputFileException(output, "binary");
106
107 google::protobuf::io::OstreamOutputStream outputStream(&ofs);
108 google::protobuf::io::CodedOutputStream codedOutputStream(&outputStream);
109
110 codedOutputStream.WriteVarint32(CoverageDataSerializer::FileTypeId);
111
112 FillCoverageDataProtoBuffFrom(coverageData, coverageDataProtoBuff);
113 WriteMessage(coverageDataProtoBuff, codedOutputStream);
114
115 // Here we serialize manually modules because protobuff's limit.
116 // See https://developers.google.com/protocol-buffers/docs/techniques#large-data
117 for (const auto& module : coverageData.GetModules())
118 {
119 pb::ModuleCoverage moduleProtoBuff;
120 InitializeModuleProtoBuffFrom(*module, moduleProtoBuff);
121
122 WriteMessage(moduleProtoBuff, codedOutputStream);
123 }
124 }
125}

Callers 2

TESTFunction · 0.80
ExportMethod · 0.80

Calls 4

WriteMessageFunction · 0.85

Tested by 1

TESTFunction · 0.64