1 #ifndef MYTHMISCUTIL_H_ 2 #define MYTHMISCUTIL_H_ 19 int &totalMB,
int &freeMB,
int &totalVM,
int &freeVM);
22 #define M_QSTRING_UNICODE(str) hasUtf8(str) ? QString::fromUtf8(str) : str 29 QString name_template =
"/tmp/mythtv_XXXXXX",
bool dir =
false);
36 QStringList *intermediaries =
nullptr,
37 unsigned maxLinks = 255);
41 inline float clamp(
float val,
float minimum,
float maximum)
43 return std::min(std::max(val, minimum), maximum);
45 inline int clamp(
int val,
int minimum,
int maximum)
47 return std::min(std::max(val, minimum), maximum);
49 inline float lerp(
float r,
float a,
float b)
51 return ((1.0f -
r) * a) + (
r *
b);
53 inline int lerp(
float r,
int a,
int b)
55 return (
int)
lerp(
r, (
float) a, (
float)
b);
57 inline float sq(
float a) {
return a*a; }
58 inline int sq(
int a) {
return a*a; }
62 return (val) ?
"true" :
"false";
87 Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive);
95 QueryPerformanceCounter((LARGE_INTEGER*)(&x));
102 inline void rdtsc(uint64_t &x)
104 timing_ab_t &y = (timing_ab_t&) x;
115 inline void rdtsc(uint64_t &x) { x = 0ULL; }
118 #endif // MYTHMISCUTIL_H_ MBASE_PUBLIC bool IsPulseAudioRunning(void)
Is A/V Sync destruction daemon is running on this host?
MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size=0)
Copies src file to dst file.
MBASE_PUBLIC bool ping(const QString &host, int timeout)
Can we ping host within timeout seconds?
MBASE_PUBLIC bool hasUtf8(const char *str)
Guess whether a string is UTF-8.
MBASE_PUBLIC void myth_yield(void)
MBASE_PUBLIC bool myth_nice(int val)
MBASE_PUBLIC bool WakeOnLAN(QString MAC)
MBASE_PUBLIC void setHttpProxy(void)
Get network proxy settings from OS, and use for [Q]Http[Comms].
MBASE_PUBLIC bool MythWakeup(const QString &wakeUpCommand, uint flags=kMSNone, uint timeout=0)
MBASE_PUBLIC int intResponse(const QString &query, int def)
In an interactive shell, prompt the user to input a number.
MBASE_PUBLIC QString createTempFile(QString name_template="/tmp/mythtv_XXXXXX", bool dir=false)
MBASE_PUBLIC bool IsMACAddress(QString MAC)
MBASE_PUBLIC QString FileHash(QString filename)
float clamp(float val, float minimum, float maximum)
MBASE_PUBLIC bool telnet(const QString &host, int port)
Can we talk to port on host?
MBASE_PUBLIC void wrapList(QStringList &list, int width)
float lerp(float r, float a, float b)
MBASE_PUBLIC QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries=nullptr, unsigned maxLinks=255)
MBASE_PUBLIC bool getMemStats(int &totalMB, int &freeMB, int &totalVM, int &freeVM)
Returns memory statistics in megabytes.
MBASE_PUBLIC bool myth_ioprio(int val)
range -1..8, smaller is higher priority
static QString xml_bool_to_string(bool val)
MBASE_PUBLIC bool getUptime(time_t &uptime)
Returns uptime statistics.
MBASE_PUBLIC QString xml_indent(uint level)
MBASE_PUBLIC QString getResponse(const QString &query, const QString &def)
In an interactive shell, prompt the user to input a string.
MBASE_PUBLIC bool makeFileAccessible(QString filename)
Makes a file accessible to all frontends/backends.
MBASE_PUBLIC bool MythRemoveDirectory(QDir &aDir)
MBASE_PUBLIC int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)