[coding] FileContainer::Write(void const *, size_t, Tag)

This commit is contained in:
LaGrunge 2019-08-16 15:14:17 +03:00 committed by mpimenov
parent 44a51b838f
commit 5e39f8a55c
3 changed files with 10 additions and 5 deletions

View file

@ -448,16 +448,20 @@ void FilesContainerW::Write(ModelReaderPtr reader, Tag const & tag)
rw::ReadAndWrite(src, *writer);
}
void FilesContainerW::Write(void const * buffer, size_t size, Tag const & tag)
{
if (size != 0)
GetWriter(tag)->Write(buffer, size);
}
void FilesContainerW::Write(vector<char> const & buffer, Tag const & tag)
{
if (!buffer.empty())
GetWriter(tag)->Write(buffer.data(), buffer.size());
Write(buffer.data(), buffer.size(), tag);
}
void FilesContainerW::Write(vector<uint8_t> const & buffer, Tag const & tag)
{
if (!buffer.empty())
GetWriter(tag)->Write(buffer.data(), buffer.size());
Write(buffer.data(), buffer.size(), tag);
}
void FilesContainerW::Finish()

View file

@ -245,6 +245,7 @@ public:
void Write(std::string const & fPath, Tag const & tag);
void Write(ModelReaderPtr reader, Tag const & tag);
void Write(void const * buffer, size_t size, Tag const & tag);
void Write(std::vector<char> const & buffer, Tag const & tag);
void Write(std::vector<uint8_t> const & buffer, Tag const & tag);

View file

@ -79,7 +79,7 @@ bool BuildLocalityIndexFromDataFile(string const & dataFile,
FilesContainerW writer(outFileName, FileWriter::OP_WRITE_TRUNCATE);
writer.Write(idxFileName, localityIndexFileTag);
writer.Write(std::vector<char>(dataVersionJson.begin(), dataVersionJson.end()), dataVersionTag);
writer.Write(dataVersionJson.c_str(), dataVersionJson.size(), dataVersionTag);
FileWriter::DeleteFileX(idxFileName);
}
catch (Reader::Exception const & e)