Go to the documentation of this file. 1 #ifndef MYTHMISCUTIL_H_
2 #define MYTHMISCUTIL_H_
18 #if QT_VERSION < QT_VERSION_CHECK(5,10,0)
21 #include <QRandomGenerator>
26 #if QT_VERSION < QT_VERSION_CHECK(5,10,0)
27 return static_cast<uint32_t
>(qrand());
29 return QRandomGenerator::global()->generate();
35 int &totalMB,
int &freeMB,
int &totalVM,
int &freeVM);
40 #define M_QSTRING_UNICODE(str) hasUtf8(str) ? QString::fromUtf8(str) : str
47 QString name_template =
"/tmp/mythtv_XXXXXX",
bool dir =
false);
54 QStringList *intermediaries =
nullptr,
55 unsigned maxLinks = 255);
59 inline float clamp(
float val,
float minimum,
float maximum)
61 return std::min(std::max(val, minimum), maximum);
63 inline int clamp(
int val,
int minimum,
int maximum)
65 return std::min(std::max(val, minimum), maximum);
67 inline float lerp(
float r,
float a,
float b)
69 return ((1.0F - r) * a) + (r * b);
71 inline int lerp(
float r,
int a,
int b)
73 return (
int)
lerp(r, (
float) a, (
float) b);
75 inline float sq(
float a) {
return a*a; }
76 inline int sq(
int a) {
return a*a; }
80 return (val) ?
"true" :
"false";
105 Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive);
129 QueryPerformanceCounter((LARGE_INTEGER*)(&x));
136 inline void rdtsc(uint64_t &x)
138 auto &y = (timing_ab_t&) x;
149 inline void rdtsc(uint64_t &x) { x = 0ULL; }
154 #endif // MYTHMISCUTIL_H_
MBASE_PUBLIC bool IsMACAddress(const QString &MAC)
MBASE_PUBLIC bool hasUtf8(const char *str)
Guess whether a string is UTF-8.
MBASE_PUBLIC loadArray getLoadAvgs(void)
Returns the system load averages.
MBASE_PUBLIC QString xml_indent(uint level)
MBASE_PUBLIC void myth_yield(void)
MBASE_PUBLIC bool IsPulseAudioRunning(void)
Is A/V Sync destruction daemon is running on this host?
MBASE_PUBLIC QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries=nullptr, unsigned maxLinks=255)
MBASE_PUBLIC bool telnet(const QString &host, int port)
Can we talk to port on host?
MBASE_PUBLIC QString getResponse(const QString &query, const QString &def)
In an interactive shell, prompt the user to input a string.
MBASE_PUBLIC bool WakeOnLAN(const QString &MAC)
MBASE_PUBLIC bool getMemStats(int &totalMB, int &freeMB, int &totalVM, int &freeVM)
Returns memory statistics in megabytes.
MBASE_PUBLIC QString createTempFile(QString name_template="/tmp/mythtv_XXXXXX", bool dir=false)
float clamp(float val, float minimum, float maximum)
MBASE_PUBLIC bool MythRemoveDirectory(QDir &aDir)
MBASE_PUBLIC int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)
float lerp(float r, float a, float b)
std::array< double, 3 > loadArray
MBASE_PUBLIC bool MythWakeup(const QString &wakeUpCommand, uint flags=kMSNone, std::chrono::seconds timeout=0s)
MBASE_PUBLIC bool myth_ioprio(int val)
range -1..8, smaller is higher priority
MBASE_PUBLIC bool ping(const QString &host, std::chrono::milliseconds timeout)
Can we ping host within timeout seconds?
static QString xml_bool_to_string(bool val)
MBASE_PUBLIC QString FileHash(const QString &filename)
MBASE_PUBLIC uint32_t MythRandom()
MBASE_PUBLIC int intResponse(const QString &query, int def)
In an interactive shell, prompt the user to input a number.
MBASE_PUBLIC QStringList MythSplitCommandString(const QString &line)
MBASE_PUBLIC bool myth_nice(int val)
MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size=0)
Copies src file to dst file.
MBASE_PUBLIC bool getUptime(std::chrono::seconds &uptime)
MBASE_PUBLIC void setHttpProxy(void)
Get network proxy settings from OS, and use for [Q]Http[Comms].
MBASE_PUBLIC void wrapList(QStringList &list, int width)
MBASE_PUBLIC QString MythFormatTime(std::chrono::milliseconds msecs, const QString &fmt)
Format a milliseconds time value.
MSqlQuery query(MSqlQuery::InitCon())
MBASE_PUBLIC bool makeFileAccessible(const QString &filename)