uemis: replace C-strings by std::string and std::string_view

The string code of uemis-downloader.cpp was broken in more ways
than can be listed here. Notably, it brazenly refused to free any
memory allocated for the parameters buffer.

Using std::string and std::string_view should plug all those
memory holes. That made it necessary to do some major refactoring.

This was done blind and therefore will break.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-04-29 07:02:54 +02:00 committed by bstoeger
parent 16e19b550b
commit 58b3583b3b
9 changed files with 384 additions and 403 deletions

View file

@ -59,16 +59,17 @@ extern double ascii_strtod(const char *str, const char **ptr);
}
#include <string>
#include <string_view>
#include <vector>
// Sadly, starts_with only with C++20!
inline bool starts_with(const std::string &s, const char *s2)
inline bool starts_with(std::string_view s, const char *s2)
{
return s.rfind(s2, 0) == 0;
}
// Sadly, std::string::contains only with C++23!
inline bool contains(const std::string &s, char c)
inline bool contains(std::string_view s, char c)
{
return s.find(c) != std::string::npos;
}