mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-11-30 17:19:27 +00:00
Add TextSplit
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user