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

Method MappedFile

Tools/MappedFile.cpp:28–48  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

26{
27 //-------------------------------------------------------------------------
28 MappedFile::MappedFile(const std::filesystem::path& path)
29 {
30 boost::iostreams::mapped_file mappedFile(path.string(), boost::iostreams::mapped_file::readonly);
31
32 if (!mappedFile)
33 THROW(L"Cannot create mapped file: " + path.wstring());
34
35 auto begin = mappedFile.const_begin();
36 const auto end = mappedFile.const_end();
37 for (auto it = begin; it != end; ++it)
38 {
39 if (*it == '\n')
40 {
41 const auto endOfLine = (it != begin && *(it - 1) == '\r') ? it - 1 : it;
42 lines_.push_back({ begin, endOfLine });
43 begin = it + 1;
44 }
45 }
46 if (begin != end)
47 lines_.push_back({begin, end});
48 }
49
50 //-------------------------------------------------------------------------
51 const std::vector<std::string>& MappedFile::GetLines() const

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected