OutputRedirector [constructor] | Create an OutputRedirector in an un-redirected state, and with an empty scratch buffer. Upon a call to enable, this redirector will be responsible for redirecting the stream associated with the specified which to a temporary file. The behavior is undefined unless which is equal to OutputRedirector::e_STDOUT_STREAM or OutputRedirector::e_STDERR_STREAM. |
~OutputRedirector [destructor] | Destroy this OutputRedirector object. If the object is in a redirected state, the original stream will be restored to its initial target and the temporary file to which the stream was redirected will be deleted. |
clear | Reset the scratch buffer to empty. The behavior is undefined unless enable has been previously called successfully (after the latest call to disable if disable has been called successfully). |
compare | compare overloads |
disable | If the redirector is in a redirected state, restore the original target of the redirected stream and close the temporary buffer. If the redirector is not in a redirected state, this method is a no-op. Calling this method invalidates all output in the temporary file, so a call to load after the next successful enable call will not load any output that was previously written to the file. This method does not clear the scratch buffer, so one may call load before calling disable, and the contents will be available after disable is called. If disable fails to disable the redirection, it will end the program by calling std::abort. |
enable | If the Stream specified at construction was e_STDOUT_STREAM, redirect stdout to a temporary file. If the Stream specified at construction was e_STDERR_STREAM, redirect stderr to a temporary file. The temporary file to which the stream is redirected will be created the first time enable is called, and will be deleted when this object is destroyed. If enable fails to redirect either stdout or stderr it will end the program by calling std::abort. |
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. Return true if all captured output was successfully loaded, and false otherwise. Note that captured output is allowed to have zero length. The behavior is undefined unless enable has been previously called successfully (after the latest call to disable, if disable has been called successfully). |
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 OutputRedirector::e_STDOUT_STREAM if this object is responsible for redirecting stdout, and OutputRedirector::e_STDERR_STREAM if this object is responsible for redirecting stderr. |