Open Source Tomb Raider Engine
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*!
  2. * \file include/Log.h
  3. * \brief Log
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _LOG_H_
  8. #define _LOG_H_
  9. #include <string>
  10. #include <sstream>
  11. #include <vector>
  12. class Log {
  13. public:
  14. const static char endl = '\n';
  15. Log();
  16. unsigned long size();
  17. std::string get(unsigned long i);
  18. template<typename T>
  19. Log& operator<< (const T t) {
  20. printBuffer << t;
  21. if (printBuffer.str().back() == endl) {
  22. mHistory.push_back(printBuffer.str().substr(0, printBuffer.str().length() - 1));
  23. #ifdef DEBUG
  24. std::cout << printBuffer.str().substr(0, printBuffer.str().length() - 1) << std::endl;
  25. #endif
  26. printBuffer.str("");
  27. }
  28. return (*this);
  29. }
  30. private:
  31. std::vector<std::string> mHistory;
  32. std::ostringstream printBuffer;
  33. };
  34. Log& getLog();
  35. #endif