How to use String::Split
-
I feel a bit silly asking this. But im trying to use the split function on maxon::string. And nothing seems to work.
Like array is a value receiver? but im getting loads of strange template errors.String cat = ninfo->mCategory; maxon::Array<const String&> parts; cat.Split(String("/"), true, parts); if(parts.GetCount()) info(parts[0]);
-
Hello @ECHekman,
Thank you for reaching out to us. When you run into compiler errors, you should always include them, because how should we otherwise help you? Sure, I could throw your code into our code base, guess some things, and then try to compile it, but the guessing and compiling is unnecessary and makes our answers more imprecise.
But this should work:
iferr_scope; maxon::String myString = "Hello/World"_s; maxon::BaseArray<maxon::String> parts; // could also be const myString.Split("/"_s, true, parts) iferr_return; if (MAXON_UNLIKELY(parts.GetCount() < 1)) return maxon::IllegalStateError(MAXON_SOURCE_LOCATION, "Splitting path failed."_s);
FYI: There is also UrlInterface::GetComponents.
Cheers,
Ferdinand