diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-28 15:41:35 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-28 15:41:35 +0100 |
commit | 3562802cacc8dbd0c155146acfdb8d04c6440009 (patch) | |
tree | f2139c64c6713d1c59df4b8601c11fca52fa62f5 /frontend/strings.cpp | |
parent | a070c649ddbe70a22f6265b9f5b48f6bde7eac08 (diff) |
implement transcript-style log
Diffstat (limited to 'frontend/strings.cpp')
-rw-r--r-- | frontend/strings.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/frontend/strings.cpp b/frontend/strings.cpp index 0d4dee0..bb4a419 100644 --- a/frontend/strings.cpp +++ b/frontend/strings.cpp @@ -1,9 +1,10 @@ #include "strings.h" +#include "print.h" using namespace std; void print_string(const char * str) { - printf("%s\n", wrap_string(str).c_str()); + lprtf("%s\n", wrap_string(str).c_str()); } string wrap_string(const char * str) { @@ -26,3 +27,18 @@ string wrap_string(const char * str) { return out; } +vector<string> split_string(const string & src, const string & delim) { + vector<string> out; + size_t start = 0; + size_t end = src.find(delim); + + while (end != string::npos) { + out.push_back(src.substr(start, end - start)); + start = end + delim.length(); + end = src.find(delim, start); + } + out.push_back(src.substr(start)); + + return out; +} + |