Skip to content

Commit dc93c7d

Browse files
authored
Merge pull request #196 from RobLoach/TextSplit
Add TextSplit
2 parents 5a63ca9 + 0dc14c0 commit dc93c7d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/Functions.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ RLAPI inline std::string TextInsert(const std::string& text, const std::string&
342342
return "";
343343
}
344344

345+
/**
346+
* Split text into multiple strings
347+
*/
348+
RLAPI inline std::vector<std::string> TextSplit(const std::string& text, char delimiter) {
349+
int count;
350+
const char** split = ::TextSplit(text.c_str(), delimiter, &count);
351+
return std::vector<std::string>(split, split + count);
352+
}
353+
345354
/**
346355
* Find first text occurrence within a string
347356
*/

tests/raylib_cpp_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ int main(int argc, char *argv[]) {
9494
AssertEqual(output, "World");
9595
}
9696

97+
// TextSplit
98+
{
99+
std::vector<std::string> output = raylib::TextSplit("Hello|How|Are|You", '|');
100+
AssertEqual(output.size(), 4);
101+
AssertEqual(output[1], "How");
102+
}
103+
97104
// Wave
98105
{
99106
raylib::Wave wave(path + "/resources/weird.wav");

0 commit comments

Comments
 (0)