zout.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __MINIMAL_HPP
  2. #define __MINIMAL_HPP
  3. #include <iostream>
  4. #include <cstring>
  5. #define signature cout << GREEN << __PRETTY_FUNCTION__ << "\t" << __FILE__ << RESET << endl;
  6. #define where cout << GREEN << __func__ << " @" << __LINE__ << RESET << endl;
  7. #define abc cout << GREEN << "START (" << __func__ << " @" << __LINE__ << ")" << RESET << endl;
  8. #define xyz cout << GREEN << "END (" << __func__ << " @" << __LINE__ << ")" << RESET << endl;
  9. #define zout(...) {all_out (#__VA_ARGS__, __VA_ARGS__); cout << RED << " (" << __func__ << " @" << __LINE__ << ")" << RESET << endl;}
  10. #define zout2(x) cout << #x" = \n" << x << RED << " (" << __func__ << " @" << __LINE__ << ")" << RESET << endl;
  11. #define jump cout << endl;
  12. #define JUMP cout << endl << endl << endl;
  13. //#define tab cout << "\t" ; //mauvaise idée d'appeler une macro tab. On peut vouloir appeler un tableau tab dans un programme.
  14. #define ecris(x) cout << #x << endl;
  15. #define debug(x) cout << CYAN << #x << " (" << __func__ << " @" << __LINE__ << ")" << RESET << endl;
  16. #define titre(x) cout << BOLDBLUE << #x << RESET << endl;
  17. #define green(x) cout << GREEN << #x << RESET << endl;
  18. #define red(x) cout << RED << #x << RESET << endl;
  19. #define yellow(x) cout << YELLOW << #x << RESET << endl;
  20. #define grostitre(x) cout << BOLDCYAN << #x << " (" << __func__ << " @" << __LINE__ << ")" << RESET << endl;
  21. //the following are UBUNTU/LINUX ONLY terminal color codes.
  22. #define RESET "\033[0m"
  23. #define BLACK "\033[30m" /* Black */
  24. #define RED "\033[31m" /* Red */
  25. #define GREEN "\033[32m" /* Green */
  26. #define YELLOW "\033[33m" /* Yellow */
  27. #define BLUE "\033[34m" /* Blue */
  28. #define MAGENTA "\033[35m" /* Magenta */
  29. #define CYAN "\033[36m" /* Cyan */
  30. #define WHITE "\033[37m" /* White */
  31. #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
  32. #define BOLDRED "\033[1m\033[31m" /* Bold Red */
  33. #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
  34. #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
  35. #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
  36. #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
  37. #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
  38. #define BOLDWHITE "\033[1m\033[37m" /* Bold White */
  39. using namespace std;
  40. /** zout **/
  41. // base case for template recursion when one argument remains
  42. template <typename Arg1>
  43. void all_out(const char* name, Arg1 arg1)
  44. {
  45. cout << BOLDBLUE << name << " = \n" << RESET << arg1 ;
  46. };
  47. // recursive variadic template for multiple arguments
  48. template <typename Arg1, typename... Args>
  49. void all_out(const char* names, Arg1 arg1, Args... args)
  50. {
  51. const char* comma = strchr(names, ',');
  52. cout << BOLDBLUE;
  53. cout.write(names, comma - names) << " = \n" << RESET << arg1 << endl;
  54. all_out(comma + 1, args...);
  55. };
  56. #endif /* __MINIMAL_HPP */