Advertisement
Guest User

output.cpp

a guest
Feb 7th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include "output.h"
  2.  
  3. Output::Output(const QString &prefix) :
  4.     std::ostream(&buffer), buffer(std::cout, prefix)
  5. {
  6.  
  7. }
  8.  
  9. Output::StreamBuffer::StreamBuffer(std::ostream& str, const QString &p)
  10.     :out(str)
  11. {
  12.     prefix = p + "-> ";
  13. }
  14.  
  15. std::ostream& operator<<(std::ostream &out, const QString var)
  16. {
  17.     out<<qPrintable(var);
  18.  
  19.     return out;
  20. }
  21.  
  22. int Output::StreamBuffer::sync()
  23. {
  24.     out <<qPrintable(prefix)<< str();
  25.     str("");
  26.     out.flush();
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement