diff --git a/library/Core.cpp b/library/Core.cpp index 5375daa3c..478693dbf 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -61,8 +61,6 @@ using namespace std; #include "LuaTools.h" #include "DFHackVersion.h" -#include "MiscUtils.h" - using namespace DFHack; #include "df/plotinfost.h" diff --git a/library/include/MiscUtils.h b/library/include/MiscUtils.h index c9a5f66d6..d14bdb6e9 100644 --- a/library/include/MiscUtils.h +++ b/library/include/MiscUtils.h @@ -404,6 +404,22 @@ DFHACK_EXPORT bool split_string(std::vector *out, bool squash_empty = false); DFHACK_EXPORT std::string join_strings(const std::string &separator, const std::vector &items); +template +inline std::string join_strings(const std::string &separator, T &items) { + std::stringstream ss; + + bool first = true; + for (auto &item : items) { + if (first) + first = false; + else + ss << separator; + ss << item; + } + + return ss.str(); +} + DFHACK_EXPORT std::string toUpper(const std::string &str); DFHACK_EXPORT std::string toLower(const std::string &str); DFHACK_EXPORT std::string to_search_normalized(const std::string &str);