You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
991 B

  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4. struct print {
  5. print() { if(false) std::cout.setstate(std::ios_base::failbit); }
  6. ~print() { if(false) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } }
  7. };
  8. struct noprint {
  9. noprint() { if(true) std::cout.setstate(std::ios_base::failbit); }
  10. ~noprint() { if(true) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } }
  11. };
  12. #ifdef LOG_DEBUG
  13. #define DEBUG (print(), std::cout << "DEBUG[" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
  14. #define WARN (print(), std::cout << "WARN [" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
  15. #else
  16. #define DEBUG (noprint(), std::cout << "")
  17. #define WARN (noprint(), std::cout << "")
  18. #endif
  19. #ifdef LOG_DEBUG
  20. #define STEP \
  21. do { DEBUG << "Stepping through, Hit Enter..."; \
  22. std::cin.get(); \
  23. } while (0)
  24. #else
  25. #define STEP (void)(0)
  26. #endif
  27. namespace io {
  28. void debug(std::string msg);
  29. }