aboutsummaryrefslogtreecommitdiff
path: root/src/StringUtils.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-03 09:01:14 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-03 10:42:30 +0200
commitbe20a78ab01b924fc1261ff3c71361feb440e592 (patch)
treef4c54eac158ee92b5dca42d6967fa1b2b5135cde /src/StringUtils.cpp
parent522c6ea14cd2c1569ce5ff24c0241edba1835308 (diff)
xv: fix missing search results, incorrect title to thumbnail matches
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r--src/StringUtils.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 6a8d3f2..5706499 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -171,6 +171,31 @@ namespace QuickMedia {
return true;
}
+ bool to_num_hex(const char *str, size_t size, int &num) {
+ size_t i = 0;
+ const bool is_negative = size > 0 && str[0] == '-';
+ if(is_negative)
+ i = 1;
+
+ num = 0;
+ for(; i < size; ++i) {
+ const signed char c = str[i];
+ if(c - '0' <= 9)
+ num = (num << 4) | (c - '0');
+ else if(c - 'a' <= 'f' - 'a')
+ num = (num << 4) | (10 + (c - 'a'));
+ else if(c - 'A' <= 'F' - 'A')
+ num = (num << 4) | (10 + (c - 'A'));
+ else
+ return false;
+ }
+
+ if(is_negative)
+ num = -num;
+
+ return true;
+ }
+
// Returns relative time as a string (approximation)
std::string seconds_to_relative_time_str(time_t seconds) {
seconds = std::max(0L, seconds);