Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
47
libs/drape/tm_read_resources.hpp
Normal file
47
libs/drape/tm_read_resources.hpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/reader_streambuf.hpp"
|
||||
|
||||
#include "base/buffer_vector.hpp"
|
||||
#include "base/logging.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
namespace dp::impl
|
||||
{
|
||||
|
||||
template <typename ToDo>
|
||||
inline void ParsePatternsList(std::string const & patternsFile, ToDo && toDo)
|
||||
{
|
||||
ReaderStreamBuf buffer(GetPlatform().GetReader(patternsFile));
|
||||
std::istream is(&buffer);
|
||||
|
||||
std::string line;
|
||||
while (std::getline(is, line))
|
||||
{
|
||||
buffer_vector<double, 8> pattern;
|
||||
strings::Tokenize(line, " ", [&](std::string_view token)
|
||||
{
|
||||
double d = 0.0;
|
||||
VERIFY(strings::to_double(token, d), ());
|
||||
pattern.push_back(d);
|
||||
});
|
||||
|
||||
bool isValid = true;
|
||||
for (size_t i = 0; i < pattern.size(); i++)
|
||||
{
|
||||
if (fabs(pattern[i]) < 1e-5)
|
||||
{
|
||||
LOG(LWARNING, ("Pattern was skipped", line));
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
toDo(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dp::impl
|
||||
Loading…
Add table
Add a link
Reference in a new issue