How can I derive my own stream from a standard stream?

假如想象 提交于 2019-12-01 04:58:17

I think there are three levels of answer to this question:

Level 1: It is complicated, especially if you are completely new to C++, stop right now. Only if you feel adventurous, continue to level 2.

Level 2: Use some library that makes creating streams easier. I would suggest using Boost.IOStreams library. It makes creating own streams and streambufs much easier. If you are still not satisfied, continue to level 3.

Level 3: You will have to derive from std::streambuf and modify its behaviour to suit your needs. Then you will have to plug your streambuf into own stream.

Could you please describe a little bit more what you own streamclass should do? Just asking how without what is not the best way to get a constructive answer.

Maybe you should have a look at boost::iostream, as there is a much simpler and safer way to write own iostream classes.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!