#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QRegExp>
#include <QApplication>
#include <QMetaObject>
#include <QDebug>
#include <QDateTime>
#include "klfdefs.h"
Go to the source code of this file.
Namespaces | |
namespace | KLFSysInfo |
Utilities to get system information. | |
Defines | |
#define | VERSION_RX "^(\\d+)(\\.(\\d+)(\\.(\\d+)([a-zA-Z]+\\d*)?)?)?$" |
Functions | |
KLF_EXPORT const char * | klfVersion () |
KLF_EXPORT int | klfVersionMaj () |
KLF_EXPORT int | klfVersionMin () |
KLF_EXPORT int | klfVersionRelease () |
KLF_EXPORT QByteArray | klfShortFuncSignature (const QByteArray &funcname) |
KLF_EXPORT QByteArray | klfFmt (const char *fmt, va_list pp) |
KLF_EXPORT QByteArray | klfFmt (const char *fmt,...) |
KLF_EXPORT QByteArray | klfFmtDouble (double num, char fmt, int precision) |
KLF_EXPORT QString | klfTimeOfDay (bool shortfmt) |
QString | func_name_w_parens (const char *f) |
KLF_EXPORT QDebug | __klf_dbg_hdr (QDebug dbg, const char *funcname, const char *refinstance, const char *shorttime) |
KLF_EXPORT QDebug | __klf_warning_hdr (QDebug warndbg, const char *funcname, const char *shorttime) |
KLF_EXPORT bool | klfIsValidVersion (const QString &v) |
KLF_EXPORT int | klfVersionCompare (const QString &v1, const QString &v2) |
Compares two version strings. | |
KLF_EXPORT bool | klfVersionCompareLessThan (const QString &v1, const QString &v2) |
Same as klfVersionCompare(v1,v2) < 0 | |
Variables | |
QStringList | klf_version_suffixes = "devel" |
#define VERSION_RX "^(\\d+)(\\.(\\d+)(\\.(\\d+)([a-zA-Z]+\\d*)?)?)?$" |
Definition at line 1173 of file klfdefs.cpp.
Referenced by klfIsValidVersion(), and klfVersionCompare().
KLF_EXPORT QDebug __klf_dbg_hdr | ( | QDebug | dbg, |
const char * | funcname, | ||
const char * | refinstance, | ||
const char * | shorttime | ||
) |
Definition at line 1120 of file klfdefs.cpp.
References func_name_w_parens(), and QDebug::nospace().
KLF_EXPORT QDebug __klf_warning_hdr | ( | QDebug | warndbg, |
const char * | funcname, | ||
const char * | shorttime | ||
) |
Definition at line 1130 of file klfdefs.cpp.
References QDateTime::currentDateTime(), func_name_w_parens(), and QDebug::nospace().
QString func_name_w_parens | ( | const char * | f | ) | [inline] |
Definition at line 1110 of file klfdefs.cpp.
References QString::indexOf().
Referenced by __klf_dbg_hdr(), and __klf_warning_hdr().
KLF_EXPORT QByteArray klfFmt | ( | const char * | fmt, |
va_list | pp | ||
) |
Implements klfFmt(const char *, ...) functionality, but with a va_list
argument pointer for use in vsprintf().
Definition at line 998 of file klfdefs.cpp.
References KLF_FUNC_NAME.
Referenced by klfFmt().
KLF_EXPORT QByteArray klfFmt | ( | const char * | fmt, |
... | |||
) |
Formats a printf-style string and returns the data as a QByteArray.
Definition at line 1027 of file klfdefs.cpp.
References klfFmt().
KLF_EXPORT QByteArray klfFmtDouble | ( | double | num, |
char | fmt, | ||
int | precision | ||
) |
Definition at line 1037 of file klfdefs.cpp.
References QString::number(), and QString::toLatin1().
KLF_EXPORT bool klfIsValidVersion | ( | const QString & | v | ) |
Definition at line 1175 of file klfdefs.cpp.
References QRegExp::exactMatch(), and VERSION_RX.
KLF_EXPORT QByteArray klfShortFuncSignature | ( | const QByteArray & | funcname | ) |
Definition at line 975 of file klfdefs.cpp.
References QByteArray::constData(), QByteArray::indexOf(), QByteArray::lastIndexOf(), QByteArray::mid(), and QByteArray::startsWith().
Referenced by klfShortFuncSignature().
KLF_EXPORT QString klfTimeOfDay | ( | bool | shortfmt | ) |
Returns something like 456.234589
(in a QString
) that represents the actual time in seconds from midnight.
if shortFmt
is TRUE, then the seconds are truncated to 3 digits (ie. seconds are given modulo 1000). In this case, the absolute time reference is undefined, but stays always the same along the program execution (useful for debug messages and timing blocks of code).
Otherwise if shortFmt
is FALSE, the full second and micro-second count output of gettimeofday() is given.
Definition at line 1049 of file klfdefs.cpp.
References QString::fromLatin1().
int klfVersion | ( | ) |
Returns the current version of the KLatexFormula library, given as a string, eg. "3.2.1"
.
For non-release builds, this may have a suffix, eg. "3.2.0beta2"
.
Definition at line 906 of file klfdefs.cpp.
KLF_EXPORT int klfVersionCompare | ( | const QString & | v1, |
const QString & | v2 | ||
) |
Compares two version strings.
v1
and v2
must be of the form "<MAJ>.<MIN>.<REL><suffix>"
or "<MAJ>.<MIN>.<REL>"
or "<MAJ>.<MIN>"
or "<MAJ>"
or an empty string.
Empty strings are considered less than any other version string, except to other empty strings to which they compare equal.
0
if v1 == v2 and a positive value if v2 < v1. This function returns -200
if either of the version strings are invalid.A less specific version number is considered as less than a more specific version number of equal common numbers, eg. "3.1" < "3.1.2".
When a suffix is appended to the version, it is attempted to be recognized:
The full list of recognized suffixes is, in order from "least" to "most" recent version:
"a"
"alpha"
"b"
"beta"
"p"
"pre"
"preview"
"RC"
"rc"
""
( version number specified without prefix)"post"
"dev"
"devel"
Some examples, where "<" represents a logical "less than", characterized by this function returning a strictly negative value when called with both arguments:
"3.1.0" < "3.1.2" "2" < "2.1" < "2.1.1" "3.0.0alpha2" < "3.0.0" "3.0.2" < "3.0.3alpha0" "3.2.0alpha" < "3.2.0beta" "3.2.0alpha" < "3.2.0alpha0" "3.2.0RC3" < "3.2.0RC4"
This function, when exchanging the arguments, returns a value that is of opposite sign, ie.
klfVersionCompare(v1, v2) == - klfVersionCompare(v2, v1)
Definition at line 1181 of file klfdefs.cpp.
References QRegExp::cap(), QRegExp::exactMatch(), QString::isEmpty(), QString::toInt(), and VERSION_RX.
Referenced by klfVersionCompareLessThan().
KLF_EXPORT bool klfVersionCompareLessThan | ( | const QString & | v1, |
const QString & | v2 | ||
) |
Same as klfVersionCompare(v1,v2) < 0
Definition at line 1270 of file klfdefs.cpp.
References klfVersionCompare().
int klfVersionMaj | ( | ) |
Returns the current major version of the KLatexFormula library.
For example, if the version is "3.2.0"
, klfVersionMaj() returns 3
.
Definition at line 911 of file klfdefs.cpp.
int klfVersionMin | ( | ) |
Returns the current minor version of the KLatexFormula library.
For example, if the version is "3.2.0"
, klfVersionMin() returns 2
.
Definition at line 915 of file klfdefs.cpp.
int klfVersionRelease | ( | ) |
Returns the current release version of the KLatexFormula library.
For example, if the version is "3.2.0"
, klfVersionRelease() returns 0
.
Definition at line 919 of file klfdefs.cpp.
QStringList klf_version_suffixes = "devel" |
Definition at line 1148 of file klfdefs.cpp.