diff options
| author | ilotterytea <iltsu@alright.party> | 2025-02-02 22:36:45 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-02-02 22:36:45 +0500 |
| commit | d7b3911ad879cc85a12e3e4979fc8d8f4b526960 (patch) | |
| tree | 0939ad7270128097f5d09905536f9775f574ff23 | |
| parent | 46ed8f00724daf9565f4f1a46a58304acfe2247b (diff) | |
feat: util for splitting text
| -rw-r--r-- | src/utils/string.cpp | 18 | ||||
| -rw-r--r-- | src/utils/string.hpp | 7 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/utils/string.cpp b/src/utils/string.cpp new file mode 100644 index 0000000..bb590ca --- /dev/null +++ b/src/utils/string.cpp @@ -0,0 +1,18 @@ +#include "string.hpp" + +#include <sstream> + +namespace silly::editor::utils { + std::vector<std::string> split_text(const std::string &text, char delimiter) { + std::vector<std::string> parts; + + std::istringstream iss(text); + std::string part; + + while (std::getline(iss, part, delimiter)) { + parts.push_back(part); + } + + return parts; + } +}
\ No newline at end of file diff --git a/src/utils/string.hpp b/src/utils/string.hpp new file mode 100644 index 0000000..cfee5b7 --- /dev/null +++ b/src/utils/string.hpp @@ -0,0 +1,7 @@ +#pragma once +#include <string> +#include <vector> + +namespace silly::editor::utils { + std::vector<std::string> split_text(const std::string &text, char delimiter); +}
\ No newline at end of file |
