summaryrefslogtreecommitdiff
path: root/libcore/helpers.h
blob: abfae6d1258d35c30fb1445062e87bc5e0e144d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef __HELPERS_H
#define __HELPERS_H

#include <vdr/osd.h>
#include <vdr/plugin.h>
#include "../config.h"

cPlugin *GetScraperPlugin(void);

cSize ScaleToFit(int widthMax, int heightMax, int widthOriginal, int heightOriginal);
int Minimum(int a, int b, int c, int d, int e, int f);
std::string CutText(string &text, int width, string fontName, int fontSize);
std::string StrToLowerCase(string str);
bool isNumber(const string& s);
bool FileExists(const string &fullpath);
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:
    splitstring(const char *s) : std::string(s) { };
    std::vector<std::string>& split(char delim, int rep=0);
};

class cStopWatch {
private:
	uint64_t start;
	uint64_t last;
public:
	cStopWatch(const char* message = NULL);
	~cStopWatch(void) {};
	void Report(const char* message);
	void Stop(const char* message);
};

string GetScreenResolutionString(int width, int height, bool *isHD);
string GetScreenAspectString(double aspect, bool *isWideScreen);

#endif // __HELPERS_H