diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 14:48:02 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 14:48:02 +0100 |
commit | 6dfa3fb34fb0a2ea028fd46e77296e26b092fb99 (patch) | |
tree | 51257e54561550c91dbec262fe143d4dbe41f059 /frontend/strings.cpp | |
parent | 862186ae7cbbd922057fa5f6b49509c36f9ade36 (diff) |
use string instead of argument vector for commands
Diffstat (limited to 'frontend/strings.cpp')
-rw-r--r-- | frontend/strings.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/frontend/strings.cpp b/frontend/strings.cpp index 70fed85..687309d 100644 --- a/frontend/strings.cpp +++ b/frontend/strings.cpp @@ -58,3 +58,16 @@ string str_title(const string & input) { return out; } +string str_consume_arg(string & argv) { + const char * delim = " \t"; + size_t start = argv.find_first_not_of(delim); + if (start == string::npos) start = 0; + size_t end = argv.find_first_of(delim, start); + if (end == string::npos) end = argv.size(); + string out = argv.substr(start, end - start); + size_t nextarg = argv.find_first_not_of(delim, end); + if (nextarg == string::npos) nextarg = end; + argv = argv.substr(nextarg); + return out; +} + |