Redirect stdout or stderr to a temporary capture file.
Declared in <bsls_outputredirector.h>
class OutputRedirector;
This class provides a facility for redirecting stdout and stderr to temporary files, retrieving output from the respective temporary file and comparing the output to user-supplied character buffers. An OutputRedirector object can be in an un-redirected state or a redirected state. If the redirector is in a redirected state, it will redirect either stdout or stderr, but not both simultaneously. An OutputRedirector object has the concept of a scratch buffer, where output captured from the process' stdout or stderr stream is stored when the OutputRedirector object is in the redirected state. Throughout this class, the term "captured output" refers to data that has been written to the stdout or stderr stream and is waiting to be loaded into the scratch buffer. Each time the load method is called, the scratch buffer is truncated, and the captured output is moved into the scratch buffer. When this is done, there is no longer any captured output.
| Name | Description |
|---|---|
Stream | Identifies the standard stream redirected by this object. |
| Name | Description |
|---|---|
OutputRedirector [constructor] | Create an OutputRedirector in an un-redirected state. |
~OutputRedirector [destructor] | Restore streams and delete the temporary capture file. |
clear | Reset the scratch buffer to empty. |
compare | compare overloads |
disable | Restore the redirected stream and close the temporary buffer. |
enable | Redirect the configured stream to a temporary file. |
getOutput | Return the address of the scratch buffer. |
isOutputReady | Return true if the captured output has been loaded into the scratch buffer, and false otherwise. |
isRedirecting | Return true if stdout or stderr has been successfully redirected, and false otherwise. |
load | Read captured output into the scratch buffer. |
nonRedirectedStream | Return the value of the global stdout or stderr corresponding to the stream that is not intended to be redirected by this object. |
outputSize | Return the number of bytes currently loaded into the scratch buffer. |
redirectedStream | Return the value of the global stdout or stderr corresponding to the stream that is intended to be redirected by this object. |
redirectedStreamId | Return which stream this object redirects. |
| Name | Description |
|---|---|
k_OUTPUT_REDIRECTOR_BUFFER_SIZE | The size of the buffer used to store the captured values loaded in the stdout and stderr error streams. |
k_PATH_BUFFER_SIZE | The size of the buffer used to hold a file name. |