adebug.h 819 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef ADEBUG_H
  2. #define ADEBUG_H
  3. #include <QDebug>
  4. #if defined(__GNUC__) || defined(__clang__)
  5. #define FUNC_IDENT __PRETTY_FUNCTION__
  6. #elif defined(_MSC_VER)
  7. #define FUNC_IDENT __FUNCSIG__
  8. #else
  9. #define FUNC_IDENT __func__
  10. #endif
  11. #define DEB qDebug() << FUNC_IDENT << "\n\t"
  12. #define DEB_SRC DEB
  13. #define DEB_RAW qDebug() << '\t'
  14. /*!
  15. * Representation macro for custom classes.
  16. *
  17. * Usage
  18. * -----
  19. * class Myclass {
  20. * ...
  21. * REPR(MyClass,
  22. * "member1=" + object.member1 + ", "
  23. * "something2" + object.calculate()
  24. * )
  25. * };
  26. *
  27. * MyClass mc;
  28. * DEB << mc;
  29. *
  30. * output:
  31. * MyClass(member1=3000, something2="A320")
  32. */
  33. #define REPR(cls, str) \
  34. friend \
  35. QDebug operator<<(QDebug qdb, const cls& object) \
  36. { \
  37. qdb << QString(#cls) + '(' + str + ')'; \
  38. return qdb; \
  39. }
  40. #endif