aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-17 19:11:27 +0200
committerStefan Boberg <[email protected]>2021-09-17 19:11:27 +0200
commita47396e06a8c6ebc2a44135c47d4820e6984c225 (patch)
treee719ed435a2de51e477822d98b0c71083edcca6a /zencore/include
parentImplemented basics for Windows server support (not yet 100% - needs to proper... (diff)
parentAdded upstream cache policy command line option (read|write,readonly,writeonl... (diff)
downloadzen-a47396e06a8c6ebc2a44135c47d4820e6984c225.tar.xz
zen-a47396e06a8c6ebc2a44135c47d4820e6984c225.zip
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/string.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h
index 2b5f20f86..bb9b1c896 100644
--- a/zencore/include/zencore/string.h
+++ b/zencore/include/zencore/string.h
@@ -622,6 +622,45 @@ ToLower(const std::string_view& InString)
//////////////////////////////////////////////////////////////////////////
+template<typename Fn>
+uint32_t
+ForEachStrTok(const std::string_view& Str, char Delim, Fn&& Func)
+{
+ auto It = Str.begin();
+ auto End = Str.end();
+ uint32_t Count = 0;
+
+ while (It != End)
+ {
+ if (*It == Delim)
+ {
+ It++;
+ continue;
+ }
+
+ std::string_view Remaining{It, End};
+ size_t Idx = Remaining.find(Delim, 0);
+
+ if (Idx == std::string_view::npos)
+ {
+ Idx = Remaining.size();
+ }
+
+ Count++;
+ std::string_view Token{It, It + Idx};
+ if (!Func(Token))
+ {
+ break;
+ }
+
+ It = It + Idx;
+ }
+
+ return Count;
+}
+
+//////////////////////////////////////////////////////////////////////////
+
void string_forcelink(); // internal
} // namespace zen