Advertisement
Guest User

output.h

a guest
Feb 7th, 2011
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #ifndef OUTPUT_H
  2. #define OUTPUT_H
  3.  
  4. #include <iostream>
  5. #include <sstream>
  6. #include <QString>
  7.  
  8. class Output: public std::ostream
  9. {
  10.     friend std::ostream& operator<<(std::ostream &out, const QString var);
  11. private:
  12.  
  13.     class StreamBuffer: public std::stringbuf
  14.     {
  15.     private:
  16.         std::ostream &out;
  17.         QString prefix;
  18.  
  19.     public:
  20.         StreamBuffer(std::ostream& str, const QString &p);
  21.  
  22.         //Kada se pozove sync funkcija:
  23.         //1) Ispisemo prefix, onda sadrzaj buffera
  24.         //2) Resetiramo buffer
  25.         //3) pozovemo flush stvarnog objekta koji koristimo za ispis
  26.         virtual int sync();
  27.     };
  28.  
  29.     //Ova klasa samo koristi specijalnu verziju buffera
  30.     StreamBuffer buffer;
  31.  
  32. public:
  33.     Output(const QString &prefix);
  34.  
  35.  
  36. };
  37.  
  38.  
  39. #endif // OUTPUT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement