开发者

How to switch iostream from binary to text mode and vice versa?

开发者 https://www.devze.com 2022-12-22 22:49 出处:网络
I want to read both formatted text and binary data from the same iostream. How can I do that? Why? Imagine this situation: You have different resources, and resource loaders for them, that take a std

I want to read both formatted text and binary data from the same iostream. How can I do that?

Why? Imagine this situation: You have different resources, and resource loaders for them, that take a std::istream as a parameter. And there are a "resource source" that provides these streams. Resources can be both text and binary and I need to handle both cases with resource loaders.

Or other situat开发者_如何学编程ion: Image that you have an archive with resources of mixed types. How can I get a text stream from inside the binary archive stream?


All that binary mode does is prevent special handling of newline characters. C++ has no concept of "resources" or "resource types". Simply read everything in binary mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号