aboutsummaryrefslogtreecommitdiff
path: root/src/StringUtils.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-01-23 18:33:28 +0100
committerdec05eba <dec05eba@protonmail.com>2022-01-23 18:33:28 +0100
commit8a05b8cdd48acca84fc52981d8cb989c849ea3cc (patch)
tree74f12222c6c063954d768bbe0437fa8dca85fddb /src/StringUtils.cpp
parent4ac963533bd7e538febf001cc158fcbd46f0267a (diff)
Youtube: show timestamps for video comments with timestamp at end of line, remove unused signature code for now
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r--src/StringUtils.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 8d8b62e..81ea1eb 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -90,6 +90,27 @@ namespace QuickMedia {
return str.substr(start, end - start + 1);
}
+ void strip(const char *str, size_t size, size_t *new_size) {
+ if(size == 0) {
+ *new_size = 0;
+ return;
+ }
+
+ int start = 0;
+ for(; start < (int)size; ++start) {
+ if(!is_whitespace(str[start]))
+ break;
+ }
+
+ int end = (int)size - 1;
+ for(; end >= start; --end) {
+ if(!is_whitespace(str[end]))
+ break;
+ }
+
+ *new_size = end - start + 1;
+ }
+
bool string_starts_with(const std::string &str, const char *sub) {
size_t sub_len = strlen(sub);
return sub_len == 0 || (str.size() >= sub_len && memcmp(str.c_str(), sub, sub_len) == 0);