MCPcopy Create free account
hub / github.com/comaps/comaps / GetWriter

Method GetWriter

libs/coding/files_container.cpp:370–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370std::unique_ptr<FilesContainerWriter> FilesContainerW::GetWriter(Tag const & tag)
371{
372 ASSERT(!m_finished, ());
373
374 InfoContainer::const_iterator it = find_if(m_info.begin(), m_info.end(), EqualTag(tag));
375 if (it != m_info.end())
376 {
377 if (it + 1 == m_info.end())
378 {
379 m_info.pop_back();
380
381 if (m_info.empty())
382 StartNew();
383 else
384 m_needRewrite = true;
385 }
386 else
387 {
388 DeleteSection(it->m_tag);
389 }
390 }
391
392 if (m_needRewrite)
393 {
394 m_needRewrite = false;
395
396 ASSERT(!m_info.empty(), ());
397
398 uint64_t const curr = m_info.back().m_offset + m_info.back().m_size;
399 auto writer = std::make_unique<TruncatingFileWriter>(m_name);
400 writer->Seek(curr);
401 writer->WritePaddingByPos(kSectionAlignment);
402
403 m_info.emplace_back(tag, writer->Pos());
404 ASSERT_EQUAL(m_info.back().m_offset % kSectionAlignment, 0, ());
405 return writer;
406 }
407 else
408 {
409 SaveCurrentSize();
410
411 auto writer = std::make_unique<FilesContainerWriter>(m_name, FileWriter::OP_APPEND);
412 writer->WritePaddingByPos(kSectionAlignment);
413
414 m_info.emplace_back(tag, writer->Pos());
415 ASSERT_EQUAL(m_info.back().m_offset % kSectionAlignment, 0, ());
416 return writer;
417 }
418}
419
420void FilesContainerW::Write(std::string const & fPath, Tag const & tag)
421{

Callers 15

BuildRoadAccessInfoFunction · 0.80
BuildCitiesBoundariesFunction · 0.80
BuildWorldRoadsFunction · 0.80
SerializeCityRoadsFunction · 0.80
SerializeMaxspeedsMethod · 0.80
BuildRoutingIndexFunction · 0.80
SerializeCrossMwmFunction · 0.80
operator()Method · 0.80
WritePolygonsInfoMethod · 0.80
WriteMetalinesSectionFunction · 0.80

Calls 12

ASSERTFunction · 0.85
EqualTagClass · 0.85
DeleteSectionFunction · 0.85
backMethod · 0.80
WritePaddingByPosMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
pop_backMethod · 0.45
emptyMethod · 0.45
SeekMethod · 0.45
emplace_backMethod · 0.45
PosMethod · 0.45

Tested by 4

WriteRegionDataForTestsFunction · 0.64
UNIT_TESTFunction · 0.64
ReplaceInContainerFunction · 0.64
UNIT_TESTFunction · 0.64