Base declarations for klatexformula and some utilities. More...
Go to the source code of this file.
Namespaces | |
namespace | KLFSysInfo |
Utilities to get system information. | |
Defines | |
#define | klfFmtCC |
#define | KLF_FUNC_SINGLE_RUN |
Simple test for one-time-run functions. | |
#define | KLF_PATH_SEP |
The character used in the $PATH environment variable to separate different locations. | |
Enumerations | |
enum | KLFSysInfo::Os { KLFSysInfo::Linux, KLFSysInfo::Win32, KLFSysInfo::MacOsX, KLFSysInfo::OtherOs } |
List of known operating systems. More... | |
Functions | |
KLF_EXPORT const char * | klfVersion () |
KLF_EXPORT int | klfVersionMaj () |
KLF_EXPORT int | klfVersionMin () |
KLF_EXPORT int | klfVersionRelease () |
KLF_EXPORT QByteArray | klfFmt (const char *fmt,...) |
KLF_EXPORT QByteArray | klfFmt (const char *fmt, va_list pp) |
int | KLFSysInfo::sizeofVoidStar () |
the processor register size. | |
KLF_EXPORT QString | KLFSysInfo::arch () |
The architecture of this sytem. | |
KLF_EXPORT KLFSysInfo::Os | KLFSysInfo::os () |
Which operating system this system is running. | |
KLF_EXPORT QString | KLFSysInfo::osString (KLFSysInfo::Os sysos=os()) |
The operating system we are running, returned as a string. | |
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 | |
KLF_EXPORT QStringList | klfSearchFind (const QString &wildcard_expression, int limit=-1) |
Find files matching a path with wildcards. | |
KLF_EXPORT QString | klfSearchPath (const QString &prog, const QString &extra_path="") |
Smart executable searching in a given path list with wildcards. |
Base declarations for klatexformula and some utilities.
Definition in file klfdefs.h.
#define KLF_FUNC_SINGLE_RUN |
Simple test for one-time-run functions.
Usage example:
void init_load_stuff() { KLF_FUNC_SINGLE_RUN ; // ... eg. load some initializing data in a static structure ... // this operation will only be performed the first time that init_load_stuff() is called. // ... }
#define KLF_PATH_SEP |
The character used in the $PATH environment variable to separate different locations.
Expands to '
:' (colon) on unices/Mac and to '
;' (semicolon) on Windows.
Note that the character is given as a char
(observe the single-quotes), not in a string.
Definition at line 107 of file klfdefs.h.
Referenced by KLFBackend::detectSettings(), and klfSearchPath().
#define klfFmtCC |
Same as klfFmt(), but returns the formatted string as a const char*
C-style string.
Example:
unsigned int flags = ... ; qDebug()<<"Flags are: "<<klfFmtCC("%#010x", flags) ;
Used in a QDebug stream, this function has the advantage (over klfFmt()) of not having its value enclosed in quotes.
Note for advanced usage
This macro, when called as klfFmtCC (format, args...)
expands to
(const char*)klfFmt (format, args...)
Which means that if you are trying to do something (quite unorthodox) like:
cout<<"3rd digit of 280 in base 8 is: "<< klfFmtCC("%o", 280)[2]; // does not compile
then it will fail at compile-time, since the const char*
cast is evaluated after the operator[]
. The working example is:
cout<<"3rd digit of 280 in base 8 is: "<< (klfFmtCC("%o", 280))[2]; // correct
This macro had to be declared without any arguments, since C preprocessor macros don't support variable number of arguments (as required by printf-style formatting). This is the reason why I couldn't automatically fit in the extra required parenthesis in the macro definition.
Definition at line 70 of file klfdefs.h.
Referenced by KLFBackend::detectSettings().
KLF_EXPORT QByteArray klfFmt | ( | const char * | fmt, |
... | |||
) |
Formats a printf-style string and returns the data as a QByteArray.
Definition at line 866 of file klfdefs.cpp.
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 833 of file klfdefs.cpp.
References QByteArray::duplicate(), and KLF_FUNC_NAME.
KLF_EXPORT QStringList klfSearchFind | ( | const QString & | wildcard_expression, |
int | limit | ||
) |
Find files matching a path with wildcards.
This function returns at most limit
file names that match the given wildcard_expression
. The latter may be any absolute path in which (any number of) *
and ? wildcards may be placed.
This function splits the wildcard_expression
at '/'
characters, and by starting at the root directory, recursively exploring all directories matching the given section of the pattern. (native '\' separators on windows are appropriately converted to universal '/'
, so you don't have to worry about passing '\'-style paths).
For example, searching for "/usr/lib*
/kde4/kate*.so"
will start looking in the root directory for a directory named "usr"
, in which a directory matching "lib*"
is searched for. In each of those matches, a directory named "kde4"
is searched for, in which files named "lib*.so.*"
are listed. All found matches are returned (up to a given limit
number of entries if limit
is positive).
The drive letter in wildcard_expression
on windows may not contain a wildcard.
Definition at line 1174 of file klfdefs.cpp.
References QRegExp::exactMatch(), QDir::fromNativeSeparators(), klfDbg, QString::replace(), and QDir::separator().
Smart executable searching in a given path list with wildcards.
This function looks for an executable named programName
. It looks in the directories given in argument extra_path
, and in the system environment variable PATH
. extra_path
and PATH
are assumed to be a colon-separated list of directories (semicolon-separated on windows, see KLF_PATH_SEP). Each given directory may contain wildcards (in particular, wildcards in PATH
are also parsed). programName
itself may also contain wildcards.
This function splits extra_path
and PATH
into a directory list, and then, for each directory in that list, calls klfSearchFind() with as argument the string "<directory>/<programName>"
. This function then returns the first result that is an executable file (this check is explicitely performed).
Definition at line 1195 of file klfdefs.cpp.
References QString::isEmpty(), QFileInfo::isExecutable(), QStringList::join(), KLF_PATH_SEP, and klfDbg.
KLF_EXPORT const char* 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 739 of file klfdefs.cpp.
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)"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)
Mathematically such a function would be called antisymmetric or skewsymmetric.
Definition at line 1037 of file klfdefs.cpp.
References QRegExp::cap(), QRegExp::exactMatch(), QString::isEmpty(), and QString::toInt().
KLF_EXPORT 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 744 of file klfdefs.cpp.
KLF_EXPORT 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 748 of file klfdefs.cpp.
KLF_EXPORT 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 752 of file klfdefs.cpp.