3 This file is part of libmspio
4 Copyright © 2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_IO_FILTERED_H_
9 #define MSP_IO_FILTERED_H_
14 template<typename B, typename F>
15 class Filtered: public B
22 Activator(Filtered &f_): f(f_) { f.active = true; }
23 ~Activator() { f.active = false; }
30 Filtered(): filter(*this), active(false) { }
31 ~Filtered() { active = true; }
34 Filtered(A0 a0): B(a0), filter(*this), active(false) { }
36 template<typename A0, typename A1>
37 Filtered(A0 a0, A1 a1): B(a0, a1), filter(*this), active(false) { }
39 virtual unsigned put(char c) { return filter.put(c); }
40 virtual bool getline(std::string &l) { return filter.getline(l); }
41 virtual int get() { return filter.get(); }
43 F &get_filter() { return filter; }
45 virtual unsigned do_write(const char *b, unsigned s)
50 return filter.write(b, s);
53 return B::do_write(b, s);
56 virtual unsigned do_read(char *b, unsigned s)
61 return filter.read(b, s);
64 return B::do_read(b, s);