Add TextSplit

This commit is contained in:
Rob Loach
2022-06-26 02:35:51 -04:00
parent 5a63ca9ac2
commit fe84792ced
2 changed files with 15 additions and 0 deletions

View File

@@ -342,6 +342,15 @@ RLAPI inline std::string TextInsert(const std::string& text, const std::string&
return "";
}
/**
* Split text into multiple strings
*/
RLAPI inline std::vector<std::string> TextSplit(const std::string& text, char delimiter) {
int count;
const char** split = ::TextSplit(text.c_str(), delimiter, &count);
return std::vector<std::string>(split, split + count);
}
/**
* Find first text occurrence within a string
*/

View File

@@ -94,6 +94,12 @@ int main(int argc, char *argv[]) {
AssertEqual(output, "World");
}
{
std::vector<std::string> output = raylib::TextSplit("Hello|How|Are|You", '|');
AssertEqual(output.size(), 4);
AssertEqual(output[1], "How");
}
// Wave
{
raylib::Wave wave(path + "/resources/weird.wav");