Advertisement
QuantumWarpCode

Simple Cross-Platform C++ Console Output Class

Jul 3rd, 2015
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Made by Elopus001
  2. //output.cpp
  3.  
  4. #include "stdafx.hpp"
  5. #include "output.hpp"
  6.  
  7. #ifdef _MSC_VER
  8. void Output::show()
  9. {
  10.     HWND hWnd = GetConsoleWindow();
  11.     ShowWindow(hWnd, SW_SHOW);
  12. }
  13.  
  14. void Output::hide()
  15. {
  16.     HWND hWnd = GetConsoleWindow();
  17.     ShowWindow(hWnd, SW_HIDE);
  18. }
  19. #endif
  20.  
  21. void Output::end()
  22. {
  23. #ifdef _MSC_VER
  24.     std::cout << "Press any key to continue..." << std::endl;
  25.     _getch();
  26.     return;
  27. #else
  28.     std::cout << "Press enter to continue..." << std::endl;
  29.     std::cin.get();
  30.     return;
  31. #endif
  32. }
  33.  
  34. void Output::header(char* text)
  35. {
  36.     std::cout << "=====" << text << "=====" << std::endl;
  37.     return;
  38. }
  39.  
  40. void Output::log(char* text, char* log)
  41. {
  42.     std::ofstream logfile;
  43.     logfile.open(std::string("log") + log + std::string(".log"), std::ios::app);
  44.     logfile << text << std::endl;
  45.     logfile.close();
  46.     return;
  47. }
  48.  
  49. void Output::clear(char* log)
  50. {
  51.     std::ofstream logfile;
  52.     logfile.open(std::string("log") + log + std::string(".log"), std::ios::trunc);
  53.     logfile.close();
  54.     return;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement