I have an object that I want to be able to stream. But I want to be able to stream it in different ways by using different formats, or should I say ways to describe this object. And I wonder how this is supposed to be solved with streams.
What I want is to be able to use a generic format and use some kind of format adapter to transform the generic format into the preferred format.
I also want to be able to separate the format from the implementation of Item, so I do not have to change Item each time a new format is added or changed.
this code illustrate approximately what I want.
Item item;
std::cout << "generic formatted:" << item;
std::cout << "custom formatted:" << CustomItemFormat() << item;
but this might not be possible or practical.
how is the streaming library intended to be used facing such problems?