1 #ifndef _theplu_yat_utility_stream_readirect_
2 #define _theplu_yat_utility_stream_readirect_
53 template<
class charT,
class traits = std::
char_traits<
charT> >
67 std::basic_istream<charT, traits>& is2,
79 const std::string& file,
bool active=
true);
91 std::basic_ostream<charT, traits>& os2,
103 const std::string& file,
bool active=
true);
127 void init(std::basic_ios<charT, traits>& ios1,
128 std::basic_ios<charT, traits>& ios2,
131 std::basic_streambuf<charT, traits>* buf_;
132 std::basic_ifstream<charT, traits>* ifs_;
133 std::basic_ios<charT, traits>* ios_;
134 std::basic_ofstream<charT, traits>* ofs_;
150 template<
class charT,
class traits>
153 std::basic_istream<charT, traits>& is2,
bool active)
154 : buf_(NULL), ifs_(NULL), ios_(NULL), ofs_(NULL)
156 init(is1, is2, active);
160 template<
class charT,
class traits>
163 const std::string& file,
bool active)
164 : buf_(NULL), ifs_(NULL), ios_(NULL), ofs_(NULL)
167 ifs_ =
new std::basic_ifstream<charT, traits>(file.c_str());
168 init(is, *ofs_, active);
173 template<
class charT,
class traits>
176 std::basic_ostream<charT, traits>& os2,
bool active)
177 : buf_(NULL), ifs_(NULL), ios_(NULL), ofs_(NULL)
179 init(os1, os2, active);
183 template<
class charT,
class traits>
186 const std::string& file,
bool active)
187 : buf_(NULL), ifs_(NULL), ios_(NULL), ofs_(NULL)
190 ofs_ =
new std::basic_ofstream<charT, traits>(file.c_str());
191 init(os, *ofs_, active);
196 template<
class charT,
class traits>
209 template<
class charT,
class traits>
212 std::basic_ios<charT, traits>& s2,
220 s1.rdbuf(s2.rdbuf());
bool is(const std::string &s)
check if string is convertible to (numerical) type T
Definition: utility.h:483
BasicStreamRedirect(std::basic_istream< charT, traits > &is1, std::basic_istream< charT, traits > &is2, bool active=true)
redirect istream to another istream
Definition: StreamRedirect.h:152
BasicStreamRedirect< char > StreamRedirect
Definition: StreamRedirect.h:140
~BasicStreamRedirect(void)
Destructor - resets the redirect.
Definition: StreamRedirect.h:198
BasicStreamRedirect< wchar_t > wStreamRedirect
Definition: StreamRedirect.h:145
Redirect a stream to another stream.
Definition: StreamRedirect.h:54