#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 | |
KLFSysInfo | |
Utilities to get system information. | |
Macros | |
#define | VERSION_RX "^(\\d+)(\\.(\\d+)(\\.(\\d+)([a-zA-Z]+\\d*)?)?)?$" |
Functions | |
const KLF_EXPORT 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. More... | |
KLF_EXPORT bool | klfVersionCompareLessThan (const QString &v1, const QString &v2) |
Same as klfVersionCompare(v1,v2) < 0 More... | |
Variables | |
QStringList | klf_version_suffixes |
#define VERSION_RX "^(\\d+)(\\.(\\d+)(\\.(\\d+)([a-zA-Z]+\\d*)?)?)?$" |
Definition at line 1172 of file klfdefs.cpp.
KLF_EXPORT QDebug __klf_dbg_hdr | ( | QDebug | dbg, |
const char * | funcname, | ||
const char * | refinstance, | ||
const char * | shorttime | ||
) |
Definition at line 1119 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 1129 of file klfdefs.cpp.
References QDateTime::currentDateTime(), func_name_w_parens(), and QDebug::nospace().
|
inline |
Definition at line 1109 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 997 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 1026 of file klfdefs.cpp.
References klfFmt().
KLF_EXPORT QByteArray klfFmtDouble | ( | double | num, |
char | fmt, | ||
int | precision | ||
) |
Definition at line 1036 of file klfdefs.cpp.
References QString::number(), and QString::toLatin1().
KLF_EXPORT bool klfIsValidVersion | ( | const QString & | v | ) |
Definition at line 1174 of file klfdefs.cpp.
References QRegExp::exactMatch(), and VERSION_RX.
KLF_EXPORT QByteArray klfShortFuncSignature | ( | const QByteArray & | funcname | ) |
Definition at line 974 of file klfdefs.cpp.
References QByteArray::constData(), QByteArray::indexOf(), QByteArray::lastIndexOf(), QByteArray::mid(), and QByteArray::startsWith().
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 1048 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 905 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.
Definition at line 1180 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 1269 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 910 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 914 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 918 of file klfdefs.cpp.
QStringList klf_version_suffixes |
Definition at line 1147 of file klfdefs.cpp.