This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

output.cpp

By: a guest on Feb 7th, 2011  |  syntax: C++  |  size: 0.48 KB  |  views: 65  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data