aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/include')
-rw-r--r--src/zencore/include/zencore/filesystem.h5
-rw-r--r--src/zencore/include/zencore/string.h53
2 files changed, 55 insertions, 3 deletions
diff --git a/src/zencore/include/zencore/filesystem.h b/src/zencore/include/zencore/filesystem.h
index b4906aebf..938a05b59 100644
--- a/src/zencore/include/zencore/filesystem.h
+++ b/src/zencore/include/zencore/filesystem.h
@@ -368,6 +368,11 @@ public:
std::vector<std::filesystem::path> DirectoryNames;
std::vector<uint32_t> DirectoryAttributes;
};
+ virtual bool AsyncAllowDirectory(const std::filesystem::path& Parent, const std::filesystem::path& DirectoryName) const
+ {
+ ZEN_UNUSED(Parent, DirectoryName);
+ return true;
+ }
virtual void AsyncVisitDirectory(const std::filesystem::path& RelativeRoot, DirectoryContent&& Content) = 0;
};
diff --git a/src/zencore/include/zencore/string.h b/src/zencore/include/zencore/string.h
index 93f8add0a..4379f2f80 100644
--- a/src/zencore/include/zencore/string.h
+++ b/src/zencore/include/zencore/string.h
@@ -821,19 +821,66 @@ ForEachStrTok(const std::string_view& Str, char Delim, Fn&& Func)
while (It != End)
{
- if (*It == Delim)
+ std::string_view Remaining{It, size_t(ptrdiff_t(End - It))};
+ size_t Idx = Remaining.find(Delim, 0);
+ if (Idx == 0)
{
It++;
continue;
}
+ size_t DelimSize = 0;
+
+ if (Idx == std::string_view::npos)
+ {
+ Idx = Remaining.size();
+ }
+ else
+ {
+ DelimSize = 1;
+ }
+
+ Count++;
+ std::string_view Token{It, Idx};
+ if (!Func(Token))
+ {
+ break;
+ }
+
+ It = It + (Idx + DelimSize);
+ }
+
+ return Count;
+}
+
+template<typename Fn>
+uint32_t
+ForEachStrTok(const std::string_view& Str, const char* Delims, Fn&& Func)
+{
+ const char* It = Str.data();
+ const char* End = It + Str.length();
+ uint32_t Count = 0;
+
+ while (It != End)
+ {
std::string_view Remaining{It, size_t(ptrdiff_t(End - It))};
- size_t Idx = Remaining.find(Delim, 0);
+ size_t Idx = Remaining.find_first_of(Delims, 0);
+ if (Idx == 0)
+ {
+ It++;
+ continue;
+ }
+
+ size_t DelimSize = 0;
if (Idx == std::string_view::npos)
{
Idx = Remaining.size();
}
+ else
+ {
+ DelimSize = 1;
+ }
Count++;
std::string_view Token{It, Idx};
@@ -842,7 +889,7 @@ ForEachStrTok(const std::string_view& Str, char Delim, Fn&& Func)
break;
}
- It = It + Idx;
+ It = It + (Idx + DelimSize);
}
return Count;