K,
It's fairly easy to use a ostringstream object or a derived class to output text like a normal stream class like cout.
Eg.
class console: public ostringstream
{
public:
void Render()
{
std::string buff = ostringstream::str();
//Some code to put it to screen
//Write it to a file
}
}
//Example of useage
console con;
con<<"Asasds"<<213;
This works as long as I keep calling Render().
Now if I want the text to be put into a file, I could ofcourse write buff but the output will have to wait till a render is performed.
I would like to have the text written as soon as the << operator is used. And I dont want to have to write a definition each and every data type :P.
What can be done to overload << so that an internal function can be called to write it to a file without having to wait till Render() is called.