basic_streambuf versuche
-
Hallo zusammen,
Ich hab mir folgenden Beitrag als Ausgangsgrundlage genommen mir reicht's! Kryptostream muß her!
Jetzt wollte ich das ganze als Steambuffer implementieren, so das ich den Crypt-Stream so aufrufen kann:
crypt<RC4> rc4(); crypt.setKey(128, "passphrase"); crypt << "zu verschlüsseln"; crypt.clear();Die eingabe zum Stream können/sollen sein ein string, filestream oder was auch immer. Folgendes hab ich bisher schon gebastelt:
(Nur zum Testen für den basic_streambuf)template<class _char, class _traits = std::char_traits<_char>> class myClassBuf: public std::basic_streambuf<_char, _traits> { public: myClassBuf(): _buffer(new std::basic_iostream<_char, _traits>) { }; virtual ~myClassBuf() {}; typedef _char char_type; typedef _traits traits_type; typedef typename _traits::int_type int_type; typedef typename _traits::pos_type pos_type; //typedef std::basic_streambuf<_char, _traits>::pos_type pos_type; virtual myClassBuf *setbuf(char_type* buf, std::streamsize) { }; virtual int_type overflow(int_type c = _traits::eof()) { }; virtual int_type underflow() { }; protected: char_type *_buffer; std::streamsize _size; }; template<class _char, class _traits = std::char_traits<_char>> class myClassStream: std::basic_iostream<_char, _traits> { public: myClassStream(); ~myClassStream() {}; }; template<class charT, class traits> myClassStream<charT, traits>::myClassStream(): myClassBuffer<charT, traits>(), std::basic_iostream<_char. _traits>() { }Ich hab aber leider keine Ahnung wie ich weitermachen soll/muss. Google ist in solcher beziehung nicht grad sehr ergiebig.