Linked Questions
10 questions linked to/from How do I create my own ostream/streambuf?
8 votes
3 answers
7k views
Have a C++ Class act like a custom ostream, sstream
I have a C++ class MyObject and I want to be able to feed this data like I would to a osstream (but unlike a direct sstream, have the incoming data be formatted a special way). I can't seem to figure ...
6 votes
2 answers
3k views
How should I manage ::std::cout after changing file descriptor 1 to refer to a different file?
I would like to do dup2(fd, 1); close(fd); and have ::std::cout write to the new fd 1. How do I can reset the state of ::std::cout so nothing goes funny? For example, is flushing beforehand sufficient?...
0 votes
3 answers
3k views
C++ output with prefix padding
How can I print an string with padding in C++? Specifically what I want is: cout << "something in one line (no prefix padding)" cout << "something in another line (no prefix padding)" ...
2 votes
1 answer
1k views
Check what output is written to standard output
I want to check whether output is written to the standard output (through cout) in a certain part of my program. What I found is a way to block any output by changing the streambuf of cout. (here:C++:...
2 votes
2 answers
500 views
C++ - inheriting ostream crashes on android but not windows
I have implemented a simple ostream and streambuf class. For some reason, it crashes when I try to instantiate my AndroidLogOStream object. Note: I have stlport_static in my Application.mk class ...
1 vote
2 answers
1k views
C++ overload << operator for class object acting as stream
So I've browsed a bunch of other threads, but none pertain to the questions I have on this exact topic. I am writing a C++ library to do socket communication. I have a TCP socket class which handles ...
6 votes
0 answers
2k views
Is it possible to intercept cout and cerr? [duplicate]
I have a library, which sends messages to the console using std::cout and std::cerr. I know, I can redirect that in my GUI Application. But, what I wonder is, if there is a way to detect if cout or ...
0 votes
1 answer
617 views
C++ Interface for logger
I am working a big legacy project and need to redo the common logger. I tried to make same logger interface with before to avoiding changing ton of loggers. The reason I need to redo the logger is the ...
0 votes
1 answer
338 views
Is it possible to change what cout does?
I was wondering if it is possible to simulate a typewriter effect (Meaning pause inbetween each character.) but from the cout global class. For example cout << "Hi, this is a cow." << ...
0 votes
1 answer
68 views
Send the last line of cout to a window
In my application I have a console (which uses std::out) and a window (that has a function to show some text). What I'm looking for is a way to show the last line of cout in my window. I've read some ...