summaryrefslogtreecommitdiffstats
path: root/macosx/HBOutputRedirect.h
blob: f689b8795fedbfee9cc1e058fae9960c807e34bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * @file
 * @date 17.5.2007
 *
 * Interface of class HBOutputRedirect.
 */

#import <Foundation/Foundation.h>


@protocol HBOutputRedirectListening <NSObject>

- (void)stdoutRedirect:(NSString *)text;
- (void)stderrRedirect:(NSString *)text;

@end

/**
 * This class is used to redirect @c stdout and @c stderr outputs. It is never
 * created directly; @c stdoutRedirect and @c stderrRedirect class methods
 * should be use instead.
 *
 * @note Redirection is done by replacing @c _write functions for @c stdout and
 *		 @c 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.
 */
@interface HBOutputRedirect : NSObject

+ (id)stdoutRedirect;
+ (id)stderrRedirect;

- (void)addListener:(id <HBOutputRedirectListening>)aListener;
- (void)removeListener:(id <HBOutputRedirectListening>)aListener;

@end