]> err.no Git - sope/blob - sope-core/NGStreams/NGStreams/NGCTextStream.h
b4ce71d0be6e271ecf73910b579cb64babb0f36b
[sope] / sope-core / NGStreams / NGStreams / NGCTextStream.h
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGStreams_NGCTextStream_H__
23 #define __NGStreams_NGCTextStream_H__
24
25 #include <NGStreams/NGStreamsDecls.h>
26 #include <NGStreams/NGStream.h>
27 #include <NGStreams/NGTextStream.h>
28 #include <NGStreams/NGTextStreamProtocols.h>
29 #include <NGStreams/NGFilterStream.h>
30
31 @class NSEnumerator;
32
33 NGStreams_EXPORT id<NGExtendedTextInputStream>  NGTextIn;
34 NGStreams_EXPORT id<NGExtendedTextOutputStream> NGTextOut;
35 NGStreams_EXPORT id<NGExtendedTextOutputStream> NGTextErr;
36 NGStreams_EXPORT void NGInitTextStdio(void);
37
38 /*
39   NGCTextStream
40
41   NGCTextStream is a text stream which operates in the operation systems
42   default encoding (it returns the bytes read from the source as characters).
43   Note that the results of the unicode-methods do not necessarily represent a
44   valid unicode character. This is only the case for character codes in the
45   7bit ASCII set.
46   NGCTextStream never returns a character value above 255.
47   
48   To retrieve correctly converted unicode characters use the NGTextStream
49   class.
50 */
51
52 @interface NGCTextStream : NGTextStream
53 {
54 @private
55   id<NGStream>        source; // retained
56   NGIOReadMethodType  readBytes;
57   NGIOWriteMethodType writeBytes;
58   BOOL                (*flushBuffer)(id, SEL);
59 }
60
61 + (id)textStreamWithInputSource:(id<NGInputStream>)_source;
62 + (id)textStreamWithOutputSource:(id<NGOutputStream>)_source;
63 + (id)textStreamWithSource:(id<NGStream>)_stream;
64 - (id)initWithSource:(id<NGStream>)_stream;
65 - (id)initWithInputSource:(id<NGInputStream>)_source;
66 - (id)initWithOutputSource:(id<NGOutputStream>)_source;
67
68 // accessors
69
70 - (id<NGStream>)source;
71
72 // operations
73
74 - (BOOL)close; // forwarded to source
75
76 // NGTextInputStream, NGExtendedTextInputStream
77
78 - (unichar)readCharacter;
79 - (unsigned char)readChar;
80
81 - (NSString *)readLineAsString;
82
83 // Enumeration
84
85 - (NSEnumerator *)lineEnumerator;
86
87 // NGTextOutputStream, NGExtendedTextOutputStream
88
89 - (BOOL)writeCharacter:(unichar)_character;
90 - (BOOL)writeString:(NSString *)_string;
91 - (BOOL)flush;
92
93 - (BOOL)writeNewline;
94
95 @end
96
97 #endif /* __NGStreams_NGCTextStream_H__ */