[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
Classes | Defines | Functions
src/klftools/klfdebug.h File Reference

Debugging utilities. More...

#include <QMap>
#include <klfdefs.h>
#include <QDebug>
Include dependency graph for klfdebug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  KLFDebugBlock
 Utility to time the execution of a block. More...
class  KLFDebugBlockTimer
 An extension of KLFDebugBlock with millisecond-time display. More...
class  KLFDebugObjectWatcher

Defines

#define KLF_SHORT_TIME   qPrintable(klfTimeOfDay())
#define KLF_DEBUG_DECLARE_REF_INSTANCE(expr)
 Declares a 'ref-instance' identifier for identifying insances in debug output.
#define KLF_DEBUG_DECLARE_ASSIGNABLE_REF_INSTANCE()
 Declare that this class has an assignable debugging ref-instance.
#define KLF_DEBUG_ASSIGN_REF_INSTANCE(object, ref_instance)
 Assign a debugging ref-instance to a class instance.
#define KLF_DEBUG_ASSIGN_SAME_REF_INSTANCE(object)
 Assigns to the given object the same ref-instance as the current object instance.
#define KLF_DEBUG_TIME_BLOCK(msg)
 Utility to time the execution of a block.
#define KLF_DEBUG_BLOCK(msg)
 Utility to debug the execution of a block.
#define KLF_DEBUG_TEE(expr)
 Print the value of expression and return it.
#define klfDebugf(arglist)
 print debug stream items
#define klfDbg(streamableItems)
 print debug stream items
#define klfDbgT(streamableItems)
 print debug stream items, with current time
#define klfDbgSt(streamableItems)
 print debug stream items (special case)
#define klfDbgStT(streamableItems)
 print debug stream items, with current time (special case)
#define KLF_DEBUG_WATCH_OBJECT(qobj)
#define klfWarning(streamableItems)
#define KLF_FUNC_NAME
#define KLF_ASSERT_CONDITION(expr, msg, failaction)
 Asserting Conditions (NON-FATAL)
#define KLF_ASSERT_CONDITION_ELSE(expr, msg, failaction)
 Asserting Conditions previous to block (NON-FATAL)
#define KLF_ASSERT_NOT_NULL(ptr, msg, failaction)
 Asserting Non-NULL pointers (NON-FATAL)

Functions

KLF_EXPORT QByteArray klfShortFuncSignature (const QByteArray &fullFuncName)
QByteArray klfShortFuncSignature (const char *fullFuncName)
KLF_EXPORT QString klfTimeOfDay (bool shortFmt=true)
KLF_EXPORT QDebug __klf_warning_hdr (QDebug warnstr, const char *funcname, const char *shorttime)

Detailed Description

Debugging utilities.

Definition in file klfdebug.h.


Define Documentation

#define KLF_ASSERT_CONDITION (   expr,
  msg,
  failaction 
)

Asserting Conditions (NON-FATAL)

If the given expression expr is FALSE, then prints function name and the given message msg to standard warning output (using Qt's qWarning()) and executes instructions given by failaction.

failaction is any C/C++ instructions that you can place inside a normal code block (in this case the code will be contained in an 'if' block). The allowed instructions include for example 'return', 'continue' or 'break' instructions.

On Qt 4, msg may contain << operators to chain output to a QDebug.

On Qt 3, msg may be anything that can be added with '+' to a QString.

A helper macro for asserting non-NULL pointers is also defined as KLF_ASSERT_NOT_NULL. It directly calls KLF_ASSERT_CONDITION with the expression (ptr) != NULL.

Example:

  bool static_has_failed = false;
  void * find_whatever_pointer(SomeContainer c, const char * querystring) {
    int i = ... // find 'querystring' in the container 'c'
    KLF_ASSERT_CONDITION( i >= 0 && i < c.size() ,
                          "Can't find string "<<querystring<<"!" ,  // Assuming Qt 4 for << streaming
                          static_has_failed = true;  return NULL;  )
    ...
  }
  QString get_myobject_name(MyObject *object) {
    KLF_ASSERT_NOT_NULL( object , "object is NULL!" , return QString() ) ;
    return object->name;
  }

Note Qt4 is needed to use the streaming operators as in the first asserting condition above. With Qt 3, one has to use QString's '+' operator:

  KLF_ASSERT_CONDITION( ... , "Can't find string "+querystring+"!" , ... );

Which works since on Qt 3, the msg argument text is expanded after a QString("")+.

This macro is not affected by the KLF_DEBUG symbol. This macro is always defined and functional.

Referenced by KLFShowHideSideWidgetManager::eventFilter(), KLFFlowListWidget::insertItem(), KLFFlowListWidget::itemAt(), KLFFlowListWidget::itemDataAt(), klfLoad(), KLFShowHideSideWidgetManager::newSideWidgetSet(), KLFSyncGuardPtr< T >::operator=(), KLFLatexSyntaxHighlighter::ParsedBlock::parenIsLatexBrace(), KLFFlowListWidget::removeItem(), KLFLatexSyntaxHighlighter::setFmtComment(), KLFLatexSyntaxHighlighter::setFmtKeyword(), KLFLatexSyntaxHighlighter::setFmtLonelyParen(), KLFLatexSyntaxHighlighter::setFmtParenMatch(), KLFLatexSyntaxHighlighter::setFmtParenMismatch(), KLFFlowListWidget::setItems(), KLFPropertizedObject::setProperty(), KLFSideWidget::setSideWidgetManager(), KLFSearchableProxy::setTarget(), KLFSearchBar::setTarget(), and KLFShowHideSideWidgetManager::showSideWidget().

#define KLF_ASSERT_CONDITION_ELSE (   expr,
  msg,
  failaction 
)

Asserting Conditions previous to block (NON-FATAL)

Similar to KLF_ASSERT_CONDITION, but expects a block of actions to perform if indeed the condition is met. An example:

 class MyObject {
   MyTarget *pTarget;
   int otherfield;
   ...

   void reinitialize();
 };

 void MyObject::reinitialize()
 {
   ...
   // if the condition is not met, print the message, and don't attempt to dereference
   // the pointer, but proceed in this function, eg. assign `otherfield' etc.
   KLF_ASSERT_CONDITION_ELSE( pTarget != NULL , "Warning n != 0 !!" , )
   {
     // for example...
     pTarget->reinitializeTarget();
   }

   otherfield = ...;
   ...
 }

Referenced by KLFSearchBar::eventFilter().

#define KLF_ASSERT_NOT_NULL (   ptr,
  msg,
  failaction 
)

Asserting Non-NULL pointers (NON-FATAL)

This macro is equivalent to

  KLF_ASSERT_CONDITION(ptr != NULL, message, failaction) ;

If the given pointer ptr is NULL, then prints function name and the given message msg to standard warning output (using Qt's qWarning()) and executes instructions given by failaction.

On Qt 4, msg may contain << operators to chain output to a QDebug.

On Qt 3, msg may be anything that can be added with '+' to a QString.

See KLF_ASSERT_CONDITION for more information.

Referenced by KLFConfigBase::connectQObject(), KLFConfigProp< T >::connectQObjectProperty(), KLFConfigProp< T >::connectQObjectSlot(), KLFPosSearchable::Pos::data(), KLFConfigProp< T >::disconnectQObjectProperty(), KLFConfigProp< T >::disconnectQObjectSlot(), KLFSearchBar::find(), KLFSideWidgetManagerFactory::findCreateSideWidgetManager(), KLFSearchBar::findNext(), KLFContainerSideWidgetManager::init(), KLFConfigProp< T >::initialize(), KLFFactoryBase::KLFFactoryBase(), klfLoad(), klfSave(), KLFContainerSideWidgetManager::newSideWidgetSet(), KLFConfigBase::propertyChanged(), KLFSearchableProxy::searchAbort(), KLFPosSearchableProxy::searchAborted(), KLFPosSearchableProxy::searchFind(), KLFSearchableProxy::searchFind(), KLFSearchableProxy::searchFindNext(), KLFPosSearchableProxy::searchHasInterruptRequested(), KLFItemViewSearchTarget::searchMoveToIterPos(), KLFPosSearchableProxy::searchMoveToPos(), KLFItemViewSearchTarget::searchPerformed(), KLFPosSearchableProxy::searchPerformed(), KLFPosSearchableProxy::searchQueryString(), KLFPosSearchableProxy::searchReinitialized(), KLFPosSearchableProxy::searchStartFrom(), KLFItemViewSearchTarget::setSearchColumns(), KLFPosSearchableProxy::setSearchInterruptRequested(), KLFPosSearchableProxy::setSearchQueryString(), KLFSideWidget::setSideWidgetManager(), KLFConfigProp< T >::setValue(), KLFFloatSideWidgetManager::setWFlags(), KLFShowHideSideWidgetManager::showSideWidget(), KLFContainerSideWidgetManager::showSideWidget(), KLFSideWidget::showSideWidget(), KLFShowHideSideWidgetManager::sideWidgetVisible(), KLFContainerSideWidgetManager::sideWidgetVisible(), KLFSideWidget::sideWidgetVisible(), KLFConfigProp< T >::value(), and KLFFactoryBase::~KLFFactoryBase().

#define KLF_DEBUG_ASSIGN_REF_INSTANCE (   object,
  ref_instance 
)

Assign a debugging ref-instance to a class instance.

The class declaration must contain a call to the KLF_DEBUG_DECLARE_ASSIGNABLE_REF_INSTANCE() macro.

Example usage:

 // vehicle.h
 class Vehicle {
 public:
   Vehicle(QString xmlspecsfile) { loadFromXML(xmlspecsfile);  }
   ...
   double calculate_drag_force(double speed);
 private:
   void loadFromXML(const QString& fname);
   ...
   KLF_DEBUG_DECLARE_ASSIGNABLE_REF_INSTANCE()
 }
 // vehicle.cpp
 void Vehicle::loadFromXML()
 {
   // ... load vehicle data and parameters from XML file
 }
 void Vehicle::calculate_drag_force(double speed)
 {
   klfDbg("shape-factor="<<...<<", speed="<<speed ) ;
   ...
   return drag_force;
 }
 // main.cpp
 int main()
 {
   ...
   Vehicle alpha("vehiclespecs/alpha-romeo.xml");
   KLF_DEBUG_ASSIGN_REF_INSTANCE(&alpha, "car/Alpha-Romeo");
   Vehicle f16("vehiclespecs/f16.xml");
   KLF_DEBUG_ASSIGN_REF_INSTANCE(&f16, "fighter/F-16");
   ...
   double drag_at_210kmh = alpha.calculate_drag_force(210);  // will produce debugging output
 }

This program will produce debugging output at the last line marked above:

Vehicle::calculate_drag_force():[car/Alpha-Romeo]
        node=[kind=1, children/sz=0,allfetched=false]

Note that the ref-instance is the one assigned with KLF_DEBUG_ASSIGN_REF_INSTANCE().

#define KLF_DEBUG_ASSIGN_SAME_REF_INSTANCE (   object)

Assigns to the given object the same ref-instance as the current object instance.

This macro works very much like KLF_DEBUG_ASSIGN_REF_INSTANCE(), but instead of assigning a given string as ref-instance, it assigns the ref-instance from the current object instance it is being called from.

Note that the ref-instance string is copied at the time of calling this macro. In other words:

  • if the current object has itself an assignable ref-instance, and the ref-instance of the current object is not yet set, then object will be set an empty ref-instance
  • if the ref-instance of the current class instance changes, then the second class will not update its ref-instance.

Example usage: in src/klflibview.cpp, in KLFLibDefaultView, when the corresponding view model is created, it is assigned the same ref-instance to the view object:

 KLFLibDefaultView::setResource(...)  : ...
 {
   ...
   pModel = new KLFLibModel(...);
   KLF_DEBUG_ASSIGN_SAME_REF_INSTANCE(pModel) ;
   ...
 }

Debugging messages sent from the KLFLibModel object will be tagged with the same ref-instance string as the messages sent from the KLFLibDefaultView object.

#define KLF_DEBUG_BLOCK (   msg)

Utility to debug the execution of a block.

Prints msg with ": block begin" when this macro is called, and prints msg with ": block end" at the end of the block. The end of the block is detected by creating an object on the stack and printing the message in that object's destructor.

Note:
KLF_DEBUG needs to be defined at compile-time to enable this feature. Otherwise, this macro is a no-op.

This macro accepts a QString.

Usage example:

 void do_something() {
   KLF_DEBUG_BLOCK("block do_something() execution") ;
   ... // do something
   if (failed) { // for example
     KLF_DEBUG_BLOCK(QString("%1: failed if-block").arg(KLF_FUNC_NAME)) ;
     ... // more fail treatment...
     return;   // both end block messages will be printed here automatically
   }
   if (go_no_further)
     return;   // do_something() end block msg will be printed here automatically
   ...
   // no special instruction needed at end of block
 }
Note:
msg is (macro-expanded) added to a QString(""), so you can write something like
   KLF_DEBUG_BLOCK(KLF_FUNC_NAME+"(int,void*)") ;
(the '+' is understood well) instead of having to write
   KLF_DEBUG_BLOCK(QString("")+KLF_FUNC_NAME+"(int,void*)") ;
even though KLF_FUNC_NAME expands into a const char*.

Advanced: If that last note wasn't clear, consider that this macro expands to:

   KLFDebugBlock __klf_debug_block(QString("")+msg)

where KLFDebugBlock is a helper class and __klf_debug_block the name of an instance of that class created on the stack. msg is passed as argument to the constructor, added to a QString(""), which allows for the feature explained above, using the fact that the preprocessor replaces the macro argument in full text, and the fact that the '+' operator operates from left to right.

Warning:
This is a macro that expands its text without explicitely protecting it (this allows you to do what the above note said).

Referenced by KLFSearchBar::abortSearch(), KLFRelativeFont::calculateRelativeFont(), KLFConfigBase::connectQObject(), KLFDisplayLabel::display(), KLFRelativeFontBase::eventFilter(), KLFSearchBar::find(), KLFSearchBar::focus(), KLFLatexSyntaxHighlighter::highlightBlock(), KLFLatexParenSpecs::identifyModifier(), KLFLatexParenSpecs::identifyParen(), KLFFlowListWidget::insertItem(), klfDataToEscaped(), klfDrawGlowedImage(), klfEscapedToData(), klfHideWindows(), klfLoad(), klfLoadVariantListFromXML(), klfLoadVariantMapFromXML(), klfMergeEnvironment(), KLFPleaseWaitPopup::KLFPleaseWaitPopup(), klfPrefixedPath(), KLFRefPtr< KLFPointerGuard >::KLFRefPtr(), klfRestoreWindows(), klfSave(), klfSaveVariantMapToXML(), klfSearchPath(), KLFSideWidgetManagerBase::KLFSideWidgetManagerBase(), klfUrlCompare(), KLFShowHideSideWidgetManager::newParentWidgetSet(), KLFShowHideSideWidgetManager::newSideWidgetSet(), KLFContainerSideWidgetManager::newSideWidgetSet(), KLFFloatSideWidgetManager::newSideWidgetSet(), KLFPosSearchable::Pos::operator=(), KLFRefPtr< KLFPointerGuard >::operator=(), KLFColorClickSquare::paintEvent(), KLFProgressDialog::paintEvent(), KLFItemViewSearchTarget::searchAborted(), KLFIteratorSearchable< QModelIndex >::searchFind(), KLFIteratorSearchable< QModelIndex >::searchIterFind(), KLFItemViewSearchTarget::searchIterMatches(), KLFItemViewSearchTarget::searchMoveToIterPos(), KLFItemViewSearchTarget::searchPerformed(), KLFItemViewSearchTarget::searchReinitialized(), KLFIteratorSearchable< QModelIndex >::searchStartFrom(), KLFAbstractPropertizedObject::setAllProperties(), KLFPropertizedObject::setAllProperties(), KLFEnumComboBox::setEnumValues(), KLFLatexSyntaxHighlighter::setFmtKeyword(), KLFFlowLayout::setGeometry(), KLFSideWidgetManagerBase::setOurParentWidget(), KLFItemViewSearchTarget::setSearchColumns(), KLFItemViewSearchTarget::setSearchView(), KLFSideWidgetManagerBase::setSideWidget(), KLFSideWidget::setSideWidgetManager(), KLFTargeter::setTarget(), KLFPleaseWaitPopup::showPleaseWait(), KLFShowHideSideWidgetManager::showSideWidget(), KLFPosSearchable::Pos::valid(), KLFContainerSideWidgetManager::~KLFContainerSideWidgetManager(), KLFRefPtr< KLFPointerGuard >::~KLFRefPtr(), KLFSideWidget::~KLFSideWidget(), KLFSideWidgetManagerBase::~KLFSideWidgetManagerBase(), KLFTarget::~KLFTarget(), and KLFTargeter::~KLFTargeter().

Declare that this class has an assignable debugging ref-instance.

This macro should be used within class declarations. If the KLF_DEBUG symbol is defined, this macro will declare a ref-instance for that class, which other objects may assign with KLF_DEBUG_ASSIGN_REF_INSTANCE().

See also KLF_DEBUG_DECLARE_REF_INSTANCE and KLF_DEBUG_ASSIGN_REF_INSTANCE(). See the latter for an example usage.

#define KLF_DEBUG_DECLARE_REF_INSTANCE (   expr)

Declares a 'ref-instance' identifier for identifying insances in debug output.

Useful for debugging classes that are instanciated multiple times, and that may superpose debugging output.

Use this macro in the class declaration and specify an expression that will identify the instance. Then this information will be displayed in the debug message when using klfDbg().

The expression given as argument to this macro is any valid expression that can be used within a const member function---you may reference eg. private properties, private functions, inherited protected members, public functions, etc. The expression should evaluate to a QString, or any expression that can be added (with operator+(QString,...)) to a QString.

Example:

 class MyDocument {
 public:
   MyDocument(QString fname) : fileName(fname) { }
   // ....
   QString currentFileName() const { return fileName; }
   // ...
 private:
   QString fileName;
   KLF_DEBUG_DECLARE_REF_INSTANCE( currentFileName() ) ;
   //  we could also have used (equivalent):
   //KLF_DEBUG_DECLARE_REF_INSTANCE( fileName ) ;
 };

This macro expands to a protected inline member returning the given expression surrounded with square brackets.

Note:
this feature is optional. Classes that do not declare a 'ref-instance' will still be able to use klfDbg() normally, except there is no way (apart from what you output yourself) to make the difference between messages originating from two different class instances.
Warning:
when you declare a 'ref-instance' in a class, static members of that class cannot use klfDbg any more because that macro will try to invoke the ref-instance of the class. Use instead klfDbgSt which does the same thing, but explicitely skips the ref-instance. This is not needed for classes that do not declare a ref-instance.
#define KLF_DEBUG_TEE (   expr)

Print the value of expression and return it.

If KLF_DEBUG preprocessor symbol is not defined, this macro just expands to (expr).

Note:
This macro works only in Qt4.

Very useful for debugging return values, eg.

   return KLF_DEBUG_TEE(result);

effectively does

   return result;

however printing the result while returning it.

Referenced by KLFWaitAnimationOverlay::calcAnimationLabelGeometry(), KLFSysInfo::isCompatibleSysArch(), and KLFColorChooser::sizeHint().

#define KLF_DEBUG_TIME_BLOCK (   msg)

Utility to time the execution of a block.

This macro behaves exactly like KLF_DEBUG_BLOCK, but also prints the current time (short format) for timing the execution of the given block.

The effective internal difference between KLF_DEBUG_TIME_BLOCK and KLF_DEBUG_BLOCK is the use of the helper class KLFDebugBlockTimer instead of KLFDebugBlock.

Note:
KLF_DEBUG needs to be defined at compile-time to enable this feature. Otherwise, this maco is a no-op.

Usage example:

 void do_something() {
   KLF_DEBUG_TIME_BLOCK(KLF_FUNC_NAME) ;
   ... // some lengthy operation
   ... if (failed) return; // for example
   ... // no special instruction needed at end of block
 }

Referenced by KLFSearchBar::eventFilter(), klfLoadVariantFromText(), KLFPObjEditWidget::KLFPObjEditWidget(), KLFSearchBar::KLFSearchBar(), KLFIteratorSearchable< QModelIndex >::searchIterFindNext(), and KLFPObjEditWidget::~KLFPObjEditWidget().

#define KLF_DEBUG_WATCH_OBJECT (   qobj)

Definition at line 163 of file klfdebug.h.

#define KLF_FUNC_NAME

This macro expands to the function name this macro is called in.

The header klfdefs.h will try to determine which of the symbols __PRETTY_FUNCTION__, __FUNCTION__ and/or __func__ are defined and use the most "pretty" one, formatting it as necessary with klfShortFuncSignature().

Referenced by KLFSearchBar::abortSearch(), KLFWaitAnimationOverlay::calcAnimationLabelGeometry(), KLFRelativeFont::calculateRelativeFont(), KLFConfigBase::connectQObject(), KLFSideWidgetManagerFactory::createSideWidgetManager(), KLFConfigBase::disconnectQObject(), KLFDisplayLabel::display(), KLFProgressReporter::doReportProgress(), KLFPropertizedObject::doSetProperty(), KLFEnumComboBox::enumText(), KLFRelativeFontBase::eventFilter(), KLFSearchBar::eventFilter(), KLFSearchBar::find(), KLFSearchBar::focus(), KLFLatexSyntaxHighlighter::highlightBlock(), KLFLatexParenSpecs::identifyModifier(), KLFLatexParenSpecs::identifyParen(), KLFFlowListWidget::insertItem(), KLFSysInfo::isCompatibleSysArch(), klfDataToEscaped(), klfDrawGlowedImage(), klfEscapedToData(), klfFmt(), klfHideWindows(), klfLoad(), klfLoadVariantFromText(), klfLoadVariantListFromXML(), klfLoadVariantMapFromXML(), klfMergeEnvironment(), KLFPleaseWaitPopup::KLFPleaseWaitPopup(), KLFPObjEditWidget::KLFPObjEditWidget(), klfPrefixedPath(), KLFRefPtr< KLFPointerGuard >::KLFRefPtr(), klfRestoreWindows(), klfSave(), klfSaveVariantMapToXML(), klfSaveVariantToText(), KLFSearchBar::KLFSearchBar(), klfSearchPath(), KLFSideWidgetManagerBase::KLFSideWidgetManagerBase(), klfUrlCompare(), KLFShowHideSideWidgetManager::newParentWidgetSet(), KLFShowHideSideWidgetManager::newSideWidgetSet(), KLFContainerSideWidgetManager::newSideWidgetSet(), KLFFloatSideWidgetManager::newSideWidgetSet(), KLFPosSearchable::Pos::operator=(), KLFRefPtr< KLFPointerGuard >::operator=(), KLFColorClickSquare::paintEvent(), KLFProgressDialog::paintEvent(), KLFConfigBase::property(), KLFPropertizedObject::property(), KLFConfigBase::propertyChanged(), KLFPropertizedObject::propertyIdForName(), KLFPropertizedObject::propertyMaxId(), KLFPropertizedObject::propertyNameForId(), KLFPropertizedObject::registeredProperties(), KLFPropertizedObject::registeredPropertyIdList(), KLFPropertizedObject::registeredPropertyNameList(), KLFItemViewSearchTarget::searchAborted(), KLFIteratorSearchable< QModelIndex >::searchFind(), KLFIteratorSearchable< QModelIndex >::searchIterFind(), KLFIteratorSearchable< QModelIndex >::searchIterFindNext(), KLFItemViewSearchTarget::searchIterMatches(), KLFItemViewSearchTarget::searchMoveToIterPos(), KLFItemViewSearchTarget::searchPerformed(), KLFItemViewSearchTarget::searchReinitialized(), KLFIteratorSearchable< QModelIndex >::searchStartFrom(), KLFAbstractPropertizedObject::setAllProperties(), KLFPropertizedObject::setAllProperties(), KLFUnitChooser::setCurrentUnit(), KLFUnitChooser::setCurrentUnitAbbrev(), KLFEnumComboBox::setEnumValues(), KLFLatexSyntaxHighlighter::setFmtKeyword(), KLFFlowLayout::setGeometry(), KLFEnumListWidget::setItems(), KLFSideWidgetManagerBase::setOurParentWidget(), KLFColorChooseWidgetPane::setPaneType(), KLFItemViewSearchTarget::setSearchColumns(), KLFItemViewSearchTarget::setSearchView(), KLFEnumComboBox::setSelectedValue(), KLFSideWidgetManagerBase::setSideWidget(), KLFSideWidget::setSideWidgetManager(), KLFTargeter::setTarget(), KLFUnitChooser::setUnits(), KLFPleaseWaitPopup::showPleaseWait(), KLFShowHideSideWidgetManager::showSideWidget(), KLFPosSearchable::Pos::valid(), KLFContainerSideWidgetManager::~KLFContainerSideWidgetManager(), KLFPObjEditWidget::~KLFPObjEditWidget(), KLFRefPtr< KLFPointerGuard >::~KLFRefPtr(), KLFSideWidget::~KLFSideWidget(), KLFSideWidgetManagerBase::~KLFSideWidgetManagerBase(), KLFTarget::~KLFTarget(), and KLFTargeter::~KLFTargeter().

#define KLF_SHORT_TIME   qPrintable(klfTimeOfDay())
#define klfDbg (   streamableItems)

print debug stream items

Warning:
This macro may be counter-intuitive, as the argument is not evaluated before expansion. This macro expands more or less to:
 qDebug()<<KLF_FUNC_NAME [possibly more info, eg ref-instance] <<": "<< streamableItems 
which means that you can list any QDebug-streamable items as macro arguments, separated by a << operator, keeping in mind that these stream operators will be "seen" only AFTER the macro has expanded. Example usage:
 int index = ...; QString mode = ...;
 klfDbg( "index is "<<index<<" and mode is "<<mode ) ; 

The advantage of this syntax is that when disabling debug, the parts in your code where you call this macro are truly "erased" (the macro itself, with all its arguments, expands to nothing), and result into no overhead of having to go eg. through null-streams. Additionally, all macro arguments are NOT evaluated in non-debug mode.

Referenced by _klf_mac_battery_info(), KLFSearchBar::abortSearch(), KLFWaitAnimationOverlay::calcAnimationLabelGeometry(), KLFLatexEdit::canInsertFromMimeData(), KLFConfigBase::connectQObject(), KLFDebugObjectWatcher::debugObjectDestroyed(), KLFConfigBase::disconnectQObject(), KLFSearchBar::displayState(), KLFPropertizedObject::doLoadProperty(), KLFRelativeFontBase::eventFilter(), KLFShowHideSideWidgetManager::eventFilter(), KLFContainerSideWidgetManager::eventFilter(), KLFSearchBar::eventFilter(), KLFSearchBar::find(), KLFSearchBar::findNext(), KLFLatexSyntaxHighlighter::highlightBlock(), KLFLatexParenSpecs::identifyModifier(), KLFLatexParenSpecs::identifyParen(), KLFLatexEdit::insertFromMimeData(), KLFFlowListWidget::insertItem(), KLFColorChooseWidget::internalColorNameSet(), KLFSysInfo::isCompatibleSysArch(), KLFContainerSideWidgetManager::KLFContainerSideWidgetManager(), klfDataToEscaped(), klfEscapedToData(), klfHideWindows(), klfLoadVariantFromText(), klfLoadVariantMapFromXML(), klfPrefixedPath(), KLFRelativeFontBase::KLFRelativeFontBase(), klfRestoreWindows(), klfSaveVariantToText(), KLFSearchBar::KLFSearchBar(), klfSearchFind(), klfSearchPath(), klfUrlCompare(), KLFFlowLayout::maximumSize(), KLFFlowLayout::minimumSize(), KLFShowHideSideWidgetManager::newSideWidgetSet(), KLFContainerSideWidgetManager::newSideWidgetSet(), KLFColorClickSquare::paintEvent(), KLFLatexSyntaxHighlighter::parsedBlocksForPos(), KLFSearchBar::promptEmptySearch(), KLFIteratorSearchable< QModelIndex >::searchFind(), KLFIteratorSearchable< QModelIndex >::searchIterFind(), KLFIteratorSearchable< QModelIndex >::searchIterFindNext(), KLFPosSearchable::searchQueryString(), KLFPosSearchable::searchStartFrom(), KLFAbstractPropertizedObject::setAllProperties(), KLFPropertizedObject::setAllProperties(), KLFSearchBar::setAutoHide(), KLFSearchBar::setCurrentState(), KLFEnumComboBox::setEnumValues(), KLFFlowLayout::setGeometry(), KLFSideWidgetManagerBase::setOurParentWidget(), KLFRefPtr< KLFPointerGuard >::setPointer(), KLFPosSearchable::setSearchInterruptRequested(), KLFPosSearchable::setSearchQueryString(), KLFSearchBar::setShowOverlayMode(), KLFSideWidgetManagerBase::setSideWidget(), KLFSideWidget::setSideWidgetManager(), KLFTargeter::setTarget(), KLFUnitSpinBox::setUnit(), KLFProgressDialog::setValue(), KLFShowHideSideWidgetManager::showSideWidget(), KLFFlowLayout::sizeHint(), KLFPosSearchable::Pos::valid(), KLFSideWidgetManagerBase::waitForShowHideActionFinished(), and KLFContainerSideWidgetManager::~KLFContainerSideWidgetManager().

#define klfDbgSt (   streamableItems)

print debug stream items (special case)

Like klfDbg(), but for use in static functions in classes for which you have declared a 'ref-instance' with KLF_DEBUG_DECLARE_REF_INSTANCE().

If you get compilation errors like 'cannot call memeber function ...::__klf_debug_ref_instance() const without object' then it is likely that you should use this macro instead.

Explanation: ref instance works by declaring a protected inline const member in classes. A function with the same name exists globally, returning an empty string, such that classes that do not declare a ref-instance may use klfDbg() which sees the global no-op ref-instance function. However, static members of classes that declare a ref-instance see the class' ref-instance function, which evidently cannot be called from a static member. Use this macro in that last case, that simply bypasses the ref-instance call (anyway you won't need it in a static function !).

#define klfDbgStT (   streamableItems)

print debug stream items, with current time (special case)

Same as klfDbgSt(), but prints also the time like klfDbgT() does.

#define klfDbgT (   streamableItems)

print debug stream items, with current time

Same as klfDbg(), but also prints current time given by KLF_SHORT_TIME.

Referenced by KLFSearchBar::clear(), KLFSearchBar::find(), KLFSearchBar::findNext(), KLFSearchBar::focusOrNext(), KLFSearchBar::slotSearchFocusIn(), KLFSearchBar::slotSearchFocusOut(), and KLFSearchBar::slotSearchReset().

#define klfDebugf (   arglist)

print debug stream items

This macro expands to qDebug(msg, args...) if KLF_DEBUG is defined, or otherwise expands to nothing.

The usage is a bit special, to honor many-argument processing:

 klfDebugf(("%s: this is a debug message. value=%d", KLF_FUNC_NAME, somevalue)) ;

Note the double-parenthesis.

#define klfWarning (   streamableItems)

Emit a warning to the standard error. Will do so regardless of whether KLF_DEBUG is defined or not. Its usage is identical to klfDbg:

   int some_function(int x)
   {
     if (x < 0) {
       klfWarning("Expected positive x; I was given x="<<x) ;
     }
   }

Referenced by _klf_linux_battery_info(), _klf_otheros_battery_info(), _klf_win_battery_info(), KLFEnumType::enumValue(), KLFLatexParenSpecs::identifyModifier(), KLFLatexParenSpecs::identifyParen(), klfEnvironmentListToMap(), klfLoadVariantMapFromXML(), klfSaveVariantToText(), klfSetEnvironmentPath(), KLFSyncGuardPtr< T >::operator=(), and KLFConfigBase::property().


Function Documentation

KLF_EXPORT QDebug __klf_warning_hdr ( QDebug  warnstr,
const char *  funcname,
const char *  shorttime 
)
KLF_EXPORT QByteArray klfShortFuncSignature ( const QByteArray fullFuncName)
KLF_EXPORT QByteArray klfShortFuncSignature ( const char *  fullFuncName) [inline]

Takes as input a funcion signature like

void MyClass::functionName(const QString& arg1, int arg2) const

and outputs a short form of it, like

MyClass::functionName

Definition at line 37 of file klfdebug.h.

References klfShortFuncSignature().

KLF_EXPORT QString klfTimeOfDay ( bool  shortFmt = true)

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


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