Implement misc::string_matches

This commit is contained in:
2025-05-09 13:37:40 -05:00
parent ebf6e39a7d
commit 5900c3cd33
2 changed files with 9 additions and 1 deletions

View File

@@ -6,5 +6,5 @@
namespace misc {
std::vector<std::string> string_expand(const std::string& input, char delimiter = ' ');
bool string_matches(const std::string& x, const std::vector<std::string>& v);
}

View File

@@ -1,5 +1,7 @@
#include <misc.hpp>
#include <sstream>
#include <vector>
#include <algorithm>
std::vector<std::string> misc::string_expand(const std::string& input, char delimiter)
{
@@ -12,4 +14,10 @@ std::vector<std::string> misc::string_expand(const std::string& input, char deli
}
return result;
}
auto misc::string_matches(const std::string &x, const std::vector<std::string> &v) -> bool {
return std::find(v.begin(), v.end(), x) != v.end();
}