vul_redirector.h
Go to the documentation of this file.
1 // This is core/vul/vul_redirector.h
2 #ifndef vul_redirector_h_
3 #define vul_redirector_h_
4 //:
5 // \file
6 // \brief Contains class for simplified redirection of iostreams
7 // \author awf@robots.ox.ac.uk
8 //
9 // \verbatim
10 // Modifications
11 // 21-JUL-00 M.Bacic, Oxford RRG -- fixed 'pubsync' on gcc.
12 // PDA (Manchester) 21/03/2001: Tidied up the documentation
13 // Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
14 // \endverbatim
15 
16 #include <iostream>
17 #ifdef _MSC_VER
18 # include <vcl_msvc_warnings.h>
19 #endif
20 
21 struct vul_redirector_data;
22 
23 //: Simplified redirection of iostreams
24 // To implement your own, derive a class from vul_redirector,
25 // and implement `putchunk'.
27 {
28  public:
29  //: Attach redirector to std::ostream s, so that all future output to s goes through this->putchunk
30  vul_redirector(std::ostream& s);
31 
32  //: Destroy redirector, restore stream to original.
33  virtual ~vul_redirector();
34 
35  //: The filter function
36  // Called with `n' characters in `buf', do with as you like.
37  virtual std::streamsize putchunk(char const* buf, std::streamsize n);
38 
39  protected:
40  //: Put characters to original stream.
41  // Useful for derived classes which wish to filter a stream.
42  std::streamsize put_passthru(char const* buf, std::streamsize n);
43 
44  //: Sync original stream.
45  int sync_passthru();
46 
47  private:
49 };
50 
51 #endif // vul_redirector_h_
virtual std::streamsize putchunk(char const *buf, std::streamsize n)
The filter function.
virtual ~vul_redirector()
Destroy redirector, restore stream to original.
vul_redirector_data * p
int sync_passthru()
Sync original stream.
vul_redirector(std::ostream &s)
Attach redirector to std::ostream s, so that all future output to s goes through this->putchunk.
Simplified redirection of iostreams.
std::streamsize put_passthru(char const *buf, std::streamsize n)
Put characters to original stream.