diff --git a/Utils/convert_adaptor.h b/Utils/convert_adaptor.h index 38b7422c..4015c268 100644 --- a/Utils/convert_adaptor.h +++ b/Utils/convert_adaptor.h @@ -33,8 +33,10 @@ class convert_bufadaptor : public std::basic_streambuf typedef typename traitsT::int_type int_type; typedef std::basic_streambuf fromStreambufT; - convert_bufadaptor(fromStreambufT& frombuf) : externalbuf_(frombuf) { } + explicit convert_bufadaptor(fromStreambufT& frombuf) : externalbuf_(frombuf) { } virtual ~convert_bufadaptor() { } + + void set_buffer(fromStreambufT& frombuf) { externalbuf_ = &frombuf; } protected: virtual int_type overflow(int_type c = traitsT::eof()); @@ -231,17 +233,29 @@ std::streamsize convert_bufadaptor +class convert_adaptor_buffer +{ + protected: + typedef std::basic_streambuf fromStreambufT; + + explicit convert_adaptor_buffer(fromStreambufT& frombuf) : bufadaptor_(frombuf) { } + + convert_bufadaptor bufadaptor_; +}; // convert_adaptor_buffer + template, typename fromCharT = charT, typename fromTraitsT = std::char_traits > -class iconvert_adaptor : public std::basic_istream +class iconvert_adaptor : private convert_adaptor_buffer, + public std::basic_istream { typedef std::basic_istream fromStreamT; public: explicit iconvert_adaptor(fromStreamT& fromstream) : - std::basic_istream(&bufadaptor_), - bufadaptor_(*(fromstream.rdbuf())) + convert_adaptor_buffer(*(fromstream.rdbuf())), + std::basic_istream(&bufadaptor_) { } // iconvert_adaptor @@ -251,9 +265,6 @@ class iconvert_adaptor : public std::basic_istream { return const_cast*>(&bufadaptor_); } // rdbuf - - private: - convert_bufadaptor bufadaptor_; }; // class iconvert_adaptor //////////////////////////////////////////////////////// @@ -262,13 +273,14 @@ template, typename toCharT = charT, typename toTraitsT = std::char_traits > -class oconvert_adaptor : public std::basic_ostream +class oconvert_adaptor : private convert_adaptor_buffer, + public std::basic_ostream { typedef std::basic_ostream toStreamT; public: explicit oconvert_adaptor(toStreamT &toStream) : - std::basic_ostream(&bufadaptor_), - bufadaptor_(*(toStream.rdbuf())) + convert_adaptor_buffer(*(toStream.rdbuf())), + std::basic_ostream(&bufadaptor_) { } // oconvert_adaptor @@ -278,9 +290,6 @@ class oconvert_adaptor : public std::basic_ostream { return const_cast*>(&bufadaptor_); } // rdbuf - - private: - convert_bufadaptor bufadaptor_; }; // class oconvert_adaptor #endif