[#BloombergLP-bsls-OutputRedirector] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::OutputRedirector :relfileprefix: ../../ :mrdocs: Redirect `stdout` or `stderr` to a temporary capture file. == Synopsis Declared in `<bsls_outputredirector.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class OutputRedirector; ---- == Description 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. == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/OutputRedirector/Stream.adoc[`Stream`] | Identifies the standard stream redirected by this object. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/OutputRedirector/2constructor.adoc[`OutputRedirector`] [.small]#[constructor]# | Create an `OutputRedirector` in an un‐redirected state. | xref:BloombergLP/bsls/OutputRedirector/2destructor.adoc[`~OutputRedirector`] [.small]#[destructor]# | Restore streams and delete the temporary capture file. | xref:BloombergLP/bsls/OutputRedirector/clear.adoc[`clear`] | Reset the scratch buffer to empty. | xref:BloombergLP/bsls/OutputRedirector/compare-0c.adoc[`compare`] | `compare` overloads | xref:BloombergLP/bsls/OutputRedirector/disable.adoc[`disable`] | Restore the redirected stream and close the temporary buffer. | xref:BloombergLP/bsls/OutputRedirector/enable.adoc[`enable`] | Redirect the configured stream to a temporary file. | xref:BloombergLP/bsls/OutputRedirector/getOutput.adoc[`getOutput`] | Return the address of the scratch buffer. | xref:BloombergLP/bsls/OutputRedirector/isOutputReady.adoc[`isOutputReady`] | Return `true` if the captured output has been loaded into the scratch buffer, and `false` otherwise. | xref:BloombergLP/bsls/OutputRedirector/isRedirecting.adoc[`isRedirecting`] | Return `true` if `stdout` or `stderr` has been successfully redirected, and `false` otherwise. | xref:BloombergLP/bsls/OutputRedirector/load.adoc[`load`] | Read captured output into the scratch buffer. | xref:BloombergLP/bsls/OutputRedirector/nonRedirectedStream.adoc[`nonRedirectedStream`] | Return the value of the global `stdout` or `stderr` corresponding to the stream that is not intended to be redirected by this object. | xref:BloombergLP/bsls/OutputRedirector/outputSize.adoc[`outputSize`] | Return the number of bytes currently loaded into the scratch buffer. | xref:BloombergLP/bsls/OutputRedirector/redirectedStream.adoc[`redirectedStream`] | Return the value of the global `stdout` or `stderr` corresponding to the stream that is intended to be redirected by this object. | xref:BloombergLP/bsls/OutputRedirector/redirectedStreamId.adoc[`redirectedStreamId`] | Return which stream this object redirects. |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/OutputRedirector/k_OUTPUT_REDIRECTOR_BUFFER_SIZE.adoc[`k_OUTPUT_REDIRECTOR_BUFFER_SIZE`] | The size of the buffer used to store the captured values loaded in the `stdout` and `stderr` error streams. | xref:BloombergLP/bsls/OutputRedirector/k_PATH_BUFFER_SIZE.adoc[`k_PATH_BUFFER_SIZE`] | The size of the buffer used to hold a file name. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#