Use std::vector<string> instead of QStringList in main()

In an effort to convert core to C++ structures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-25 10:58:27 +01:00 committed by bstoeger
parent c6cd10a43f
commit 4af2ec88bd
8 changed files with 80 additions and 58 deletions

View file

@ -172,6 +172,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
string-format.cpp
strtod.c
subsurface-float.h
subsurface-string.cpp
subsurface-string.h
subsurfacestartup.cpp
subsurfacestartup.h

View file

@ -0,0 +1,17 @@
// SPDX-License-Identifier: GPL-2.0
#include "subsurface-string.h"
std::string join(const std::vector<std::string> &l, const std::string &separator, bool skip_empty)
{
std::string res;
bool first = true;
for (const std::string &s: l) {
if (skip_empty && l.empty())
continue;
if (!first)
res += separator;
res += s;
first = false;
}
return res;
}

View file

@ -66,6 +66,7 @@ extern double strtod_flags(const char *str, const char **ptr, unsigned int flags
}
#include <string>
#include <vector>
// Sadly, starts_with only with C++20!
inline bool starts_with(const std::string &s, const char *s2)
@ -73,6 +74,8 @@ inline bool starts_with(const std::string &s, const char *s2)
return s.rfind(s2, 0) == 0;
}
std::string join(const std::vector<std::string> &l, const std::string &separator, bool skip_empty = false);
#endif
#endif // SUBSURFACE_STRING_H