QCAD
Open Source 2D CAD
RDebug.h
Go to the documentation of this file.
1 
20 #ifndef RDEBUG_H
21 #define RDEBUG_H
22 
23 #include "core_global.h"
24 
25 #include <fstream>
26 #include <ostream>
27 #include <stdarg.h>
28 #include <stdio.h>
29 
30 #include <QString>
31 #include <QTime>
32 #include <QMap>
33 #include <QFile>
34 #include <QMetaType>
35 
36 #if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
37 #include <CoreServices/CoreServices.h>
38 #include <mach/mach.h>
39 #include <mach/mach_time.h>
40 #undef check
41 #endif
42 
43 #if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID)
44 #include <execinfo.h>
45 #endif
46 
47 #ifndef RDEFAULT_QSTRING
48 #define RDEFAULT_QSTRING QString()
49 #endif
50 
74 public:
75  static void printBacktrace(const QString& prefix = RDEFAULT_QSTRING);
76 
80  static void startTimer(int id=0);
81 
86  static int stopTimer(int id, const QString& msg, int msThreshold = 0);
87 
92  static int stopTimer(const QString& msg) {
93  return stopTimer(0, msg);
94  }
95 
96  static void timeStamp();
97 
98  static void hexDump(const QString& str);
99 
100  static void incCounter(const QString& id = RDEFAULT_QSTRING);
101  static void decCounter(const QString& id = RDEFAULT_QSTRING);
102  static int getCounter(const QString& id = RDEFAULT_QSTRING);
103  static void printCounter(const QString& id = RDEFAULT_QSTRING);
104  static void printCounters();
105 
106  static void setPrefix(const QString& p) {
107  prefix = p;
108  }
109  static QString getPrefix() {
110  return prefix;
111  }
112 
113 private:
114 #if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
115  static QMap<int, uint64_t> timerMac;
116 #else
117  static QMap<int, QTime> timer;
118 #endif
119  static QMap<QString, int> counter;
120  static QString prefix;
121 };
122 
124 
125 #endif
static QMap< QString, int > counter
Definition: RDebug.h:119
This class provides some static methods for printing debugging information to stderr.
Definition: RDebug.h:73
#define QCADCORE_EXPORT
Definition: core_global.h:10
static QString getPrefix()
Definition: RDebug.h:109
static QString prefix
Definition: RDebug.h:120
Q_DECLARE_METATYPE(RMath *)
static void setPrefix(const QString &p)
Definition: RDebug.h:106
#define RDEFAULT_QSTRING
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RDebug.h:48
static QMap< int, QTime > timer
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RDebug.h:117
static int stopTimer(const QString &msg)
Stops the timer with ID 0 and prints the given message together with the time that has elapsed...
Definition: RDebug.h:92