[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
Namespaces | Defines | Functions | Variables
src/klftools/klfdefs.cpp File Reference
#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"
Include dependency graph for klfdefs.cpp:

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 Documentation

#define VERSION_RX   "^(\\d+)(\\.(\\d+)(\\.(\\d+)([a-zA-Z]+\\d*)?)?)?$"

Definition at line 1173 of file klfdefs.cpp.

Referenced by klfIsValidVersion(), and klfVersionCompare().


Function Documentation

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 
)
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.

Warning:
the final string length must not exceed 8192 bytes, the size of the internal buffer.

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)
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.

Returns:
a negative value if v1 < v2, 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:

  • "alpha" or "alphaN" is alpha version, eg. "3.1.1alpha2" < "3.1.1.alpha5" < "3.1.1"
  • "dev" is INTERNAL versioning, should not be published, it means further development after the given version number; for the next release, a higher version number has to be decided upon.
  • unrecognized suffixes are compared lexicographically, case sensitive.
  • after any non-empty suffix, you can add an optional integer number, which will be taken into account when comparing same version numbers with same suffix words, see examples below.

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.

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.


Variable Documentation

Definition at line 1148 of file klfdefs.cpp.


Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net