source: trunk/ab5.0/ablib/src/Classes/System/IO/Stream.ab@ 605

Last change on this file since 605 was 605, checked in by イグトランス (egtra), 16 years ago

非同期入出力(Begin/End-Read/Writeメソッド)を実装。

File size: 2.4 KB
Line 
1Namespace System
2Namespace IO
3
4
5Class Stream
6 Implements IDisposable
7
8Protected
9 Sub Stream()
10 End Sub
11Public
12 Sub ~Stream()
13 This.Dispose(False)
14 End Sub
15Public
16 Abstract Function CanRead() As Boolean
17 Abstract Function CanSeek() As Boolean
18
19 Virtual Function CanTimeout() As Boolean
20 Return False
21 End Function
22
23 Abstract Function CanWrite() As Boolean
24 Abstract Function Length() As QWord
25 Abstract Sub Position(value As QWord)
26 Abstract Function Position() As QWord
27
28 Virtual Sub ReadTimeout(value As Long)
29 Throw New InvalidOperationException("Stream does not support Timeout.")
30 End Sub
31
32 Virtual Function ReadTimeout() As Long
33 Throw New InvalidOperationException("Stream does not support Timeout.")
34 End Function
35
36 Virtual Sub WriteTimeout(value As Long)
37 Throw New InvalidOperationException("Stream does not support Timeout.")
38 End Sub
39
40 Virtual Function WriteTimeout() As Long
41 Throw New InvalidOperationException("Stream does not support Timeout.")
42 End Function
43
44Public
45 Virtual Function BeginRead(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
46 Dim r = Read(buffer,offset,count)
47 Return New Detail.SyncStreamResultImpl(r, state)
48 End Function
49 Virtual Function BeginWrite(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
50 Write(buffer,offset,count)
51 Return New Detail.SyncStreamResultImpl(0, state)
52 End Function
53 Sub Close()
54 Dispose(True)
55 End Sub
56 Sub Dispose()
57 Dispose(True)
58 End Sub
59 Virtual Function EndRead(asyncResult As System.IAsyncResult) As Long
60 Dim ar = asyncResult As Detail.IAsyncStreamResult
61 EndRead = ar.WaitAndGetResult
62 End Function
63 Virtual Sub EndWrite(asyncResult As System.IAsyncResult)
64 End Sub
65 Abstract Sub Flush()
66 Abstract Function Read(buffer As *Byte, offset As Long, count As Long) As Long
67
68 Virtual Function ReadByte() As Long
69 Dim b As Byte
70 Dim ret = Read(VarPtr(b), 0, 1)
71 If ret <> 0 Then
72 Return b
73 Else
74 Return -1
75 End If
76 End Function
77
78 Abstract Function Seek(offset As Int64, origin As SeekOrigin) As Int64
79 Abstract Sub SetLength(value As QWord)
80 Abstract Sub Write(buffer As *Byte, offset As Long, count As Long)
81 Virtual Sub WriteByte(b As Byte)
82 Write(VarPtr(b), 0, 1)
83 End Sub
84Protected
85 Virtual Sub Dispose(disposing As Boolean)
86 End Sub
87End Class
88
89
90End Namespace
91End Namespace
Note: See TracBrowser for help on using the repository browser.