summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2018-02-28 10:06:47 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2018-02-28 10:06:47 +0100
commit9c3ce0048a4572e602dc9f23c36940993db4959b (patch)
tree89eaa553944ce36acae3b125de15340bb269dd87 /tools.h
parent3a3a2339947cb9ca9b319e180e0521079be8551d (diff)
downloadvdr-9c3ce0048a4572e602dc9f23c36940993db4959b.tar.gz
vdr-9c3ce0048a4572e602dc9f23c36940993db4959b.tar.bz2
When remote timers are fetched from a peer VDR, we no longer blindly delete and re-add them, but rather compare them and make only the minimum necessary changes
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools.h b/tools.h
index aaba602f..ffbd6825 100644
--- a/tools.h
+++ b/tools.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.h 4.13 2017/06/25 11:45:38 kls Exp $
+ * $Id: tools.h 4.14 2018/02/28 10:06:47 kls Exp $
*/
#ifndef __TOOLS_H
@@ -226,6 +226,12 @@ cString strgetval(const char *s, const char *name, char d = '=');
///< If an other delimiter shall be used (like, e.g., ':'), it can be given
///< as the third parameter.
///< If name occurs more than once in s, only the first occurrence is taken.
+char *strshift(char *s, int n);
+ ///< Shifts the given string to the left by the given number of bytes, thus
+ ///< removing the first n bytes from s.
+ ///< If n is greater than the length of s, the resulting string will be empty.
+ ///< If n is <= 0 s will be unchanged.
+ ///< Returns s.
bool startswith(const char *s, const char *p);
bool endswith(const char *s, const char *p);
bool isempty(const char *s);
@@ -781,6 +787,12 @@ inline int CompareStringsIgnoreCase(const void *a, const void *b)
return strcasecmp(*(const char **)a, *(const char **)b);
}
+inline int CompareStringsNumerically(const void *a, const void *b)
+{
+ int d = atoi(*(const char **)a) - atoi(*(const char **)b);
+ return d ? d : CompareStrings(a, b);
+}
+
class cStringList : public cVector<char *> {
public:
cStringList(int Allocated = 10): cVector<char *>(Allocated) {}
@@ -793,6 +805,10 @@ public:
else
cVector<char *>::Sort(CompareStrings);
}
+ void SortNumerically(void)
+ {
+ cVector<char *>::Sort(CompareStringsNumerically);
+ }
virtual void Clear(void);
};