]> err.no Git - sope/blob - sope-core/NGStreams/NGStreams/NGDataStream.h
Id fixes
[sope] / sope-core / NGStreams / NGStreams / NGDataStream.h
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OGo
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 // $Id$
22
23 #ifndef __NGStreams_NGDataStream_H__
24 #define __NGStreams_NGDataStream_H__
25
26 #include <NGStreams/NGStream.h>
27 #include <NGStreams/NGStreamProtocols.h>
28
29 @class NSData;
30
31 @interface NGDataStream : NGStream < NGPositionableStream >
32 {
33 @private
34   NSException  *lastException;
35   NGStreamMode streamMode;
36   NSData       *data;
37   unsigned     position;
38   
39   unsigned int (*dataLength)(id, SEL);
40   const void   *(*dataBytes)(id, SEL);  
41   
42   /* for read-only streams */
43   unsigned int length;
44   const void   *bytes;
45 }
46
47 + (id)dataStream;
48 + (id)dataStreamWithCapacity:(int)_capacity;
49 + (id)streamWithData:(NSData *)_data;
50 - (id)initWithData:(NSData *)_data mode:(NGStreamMode)_mode;
51 - (id)initWithData:(NSData *)_data;
52
53 - (NSException *)lastException;
54 - (void)setLastException:(NSException *)_exception;
55 - (void)resetLastException;
56
57 // accessors
58
59 - (NSData *)data;
60
61 - (unsigned)availableBytes; // returns number of available bytes
62
63 // primitives
64
65 // throws
66 //   NGStreamNotOpenException   when the stream is not open
67 //   NGEndOfStreamException     when the end of the stream is reached
68 - (unsigned)readBytes:(void *)_buf count:(unsigned)_len;
69
70 // throws
71 //   NGReadOnlyStreamException when the stream is not writeable
72 //   NGStreamNotOpenException  when the stream is not open
73 - (unsigned)writeBytes:(const void *)_buf count:(unsigned)_len;
74
75 - (BOOL)close;
76
77 - (NGStreamMode)mode;
78 - (BOOL)isRootStream;
79
80 // NGPositionableStream
81
82 - (BOOL)moveToLocation:(unsigned)_location;
83 - (BOOL)moveByOffset:(int)_delta;
84
85 // blocking ..
86
87 - (BOOL)wouldBlockInMode:(NGStreamMode)_mode; // always NO ..
88
89 @end
90
91 #endif /* __NGStreams_NGDataStream_H__ */