mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
c6cd10a43f
commit
4af2ec88bd
8 changed files with 80 additions and 58 deletions
|
@ -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
|
||||
|
|
17
core/subsurface-string.cpp
Normal file
17
core/subsurface-string.cpp
Normal 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;
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue