Public Member Functions | Static Public Member Functions | Protected Attributes

HBOutputRedirect Class Reference

#import <HBOutputRedirect.h>

List of all members.

Public Member Functions

(void) - addListener:
(void) - removeListener:
(id) - initWithStream:selector:
(void) - startRedirect
(void) - stopRedirect
(void) - forwardOutput:

Static Public Member Functions

(id) + stdoutRedirect
(id) + stderrRedirect

Protected Attributes

NSMutableSet * listeners
 Set that contains all registered listeners for this output.
SEL forwardingSelector
 Selector that is called on listeners to forward the output.
FILE * stream
 Output stream (stdout or stderr) redirected by this object.
int(* oldWriteFunc )(void *, const char *, int)
 Pointer to old write function for the stream.
NSLock * lock

Detailed Description

This class is used to redirect stdout and stderr outputs. It is never created directly; stdoutRedirect and stderrRedirect class methods should be use instead.

Note:
Redirection is done by replacing _write functions for stdout and stderr streams. Because of this messages written by NSLog(), for example are not redirected. I consider this a good thing, but if more universal redirecting is needed, it can be done at file descriptor level.

Member Function Documentation

- (void) addListener: (id)  aListener  

Adds specified object as listener for this output. Method stdoutRedirect: or stderrRedirect: of the listener is called to redirect the output.

- (void) forwardOutput: (NSData *)  data  
- (id) initWithStream: (FILE *)  aStream
selector: (SEL)  aSelector 
- (void) removeListener: (id)  aListener  

Stops forwarding for this output to the specified listener object.

- (void) startRedirect  
+ (id) stderrRedirect  

Returns HBOutputRedirect object used to redirect stderr.

+ (id) stdoutRedirect  

Returns HBOutputRedirect object used to redirect stdout.

- (void) stopRedirect  

Member Data Documentation

- (SEL) forwardingSelector [protected]

Selector that is called on listeners to forward the output.

- (NSMutableSet*) listeners [protected]

Set that contains all registered listeners for this output.

- (NSLock*) lock [protected]
- (int(* oldWriteFunc)(void *, const char *, int)) [protected]

Pointer to old write function for the stream.

- (FILE*) stream [protected]

Output stream (stdout or stderr) redirected by this object.


The documentation for this class was generated from the following files: