summaryrefslogtreecommitdiff
path: root/libcore
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2014-10-11 16:31:39 +0200
committerlouis <louis.braun@gmx.de>2014-10-11 16:31:39 +0200
commit0e0f05cfcb72e9d679a6681b9fcabd732856f942 (patch)
treee79b1772dbdd7fcb116f2298f4ac2f190aefff2d /libcore
parent04340d11c9c0efb908cce138edde535bc07636d7 (diff)
downloadvdr-plugin-skindesigner-0e0f05cfcb72e9d679a6681b9fcabd732856f942.tar.gz
vdr-plugin-skindesigner-0e0f05cfcb72e9d679a6681b9fcabd732856f942.tar.bz2
added support for custom tokens in dislaychannel
Diffstat (limited to 'libcore')
-rw-r--r--libcore/helpers.c18
-rw-r--r--libcore/helpers.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/libcore/helpers.c b/libcore/helpers.c
index b4b507a..f24f6e7 100644
--- a/libcore/helpers.c
+++ b/libcore/helpers.c
@@ -121,6 +121,24 @@ bool FirstFileInFolder(string &path, string &extension, string &fileName) {
return false;
}
+// trim from start
+string &ltrim(string &s) {
+ s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))));
+ return s;
+}
+
+// trim from end
+string &rtrim(string &s) {
+ s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
+ return s;
+}
+
+// trim from both ends
+string &trim(string &s) {
+ return ltrim(rtrim(s));
+}
+
+
// split: receives a char delimiter; returns a vector of strings
// By default ignores repeated delimiters, unless argument rep == 1.
vector<string>& splitstring::split(char delim, int rep) {
diff --git a/libcore/helpers.h b/libcore/helpers.h
index 74ddf94..884738d 100644
--- a/libcore/helpers.h
+++ b/libcore/helpers.h
@@ -16,6 +16,10 @@ bool FileExists(const string &path, const string &name, const string &ext);
bool FolderExists(const string &path);
bool FirstFileInFolder(string &path, string &extension, string &fileName);
+string &ltrim(string &s);
+string &rtrim(string &s);
+string &trim(string &s);
+
class splitstring : public std::string {
std::vector<std::string> flds;
public: