Changeset 609 for trunk


Ignore:
Timestamp:
Aug 22, 2008, 11:57:39 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

Stream.Nullを追加

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/IO/Stream.ab

    r605 r609  
    11Namespace System
    22Namespace IO
    3 
    43
    54Class Stream
     
    8281        Write(VarPtr(b), 0, 1)
    8382    End Sub
     83
     84    Static Function Null() As Stream
     85        '(Constではなく)読み取り専用にはこうするしかないはず。
     86        If ActiveBasic.IsNothing(null) Then
     87            null = New Detail.NullStream
     88        End If
     89        Null = null
     90    End Function
    8491Protected
    8592    Virtual Sub Dispose(disposing As Boolean)
    8693    End Sub
     94
     95Private
     96    Static null = Nothing As Stream
    8797End Class
    8898
     99Namespace Detail
     100
     101/*!
     102@brief ヌルストリーム
     103@date 2008/08/21
     104@auther Egtra
     105*/
     106Class NullStream
     107    Inherits Stream
     108Public
     109    Override Function CanRead() As Boolean
     110        CanRead = True
     111    End Function
     112
     113    Override Function Read(buffer As *Byte, offset As Long, count As Long) As Long
     114        Read = 0
     115    End Function
     116
     117    Override Function ReadByte() As Long
     118        ReadByte = -1
     119    End Function
     120
     121    Override Function CanWrite() As Boolean
     122        CanWrite = True
     123    End Function
     124
     125    Override Sub Write(buffer As *Byte, offset As Long, count As Long)
     126    End Sub
     127
     128    Override Sub WriteByte(b As Byte)
     129    End Sub
     130
     131    Override Sub Flush()
     132    End Sub
     133
     134    Override Function CanSeek() As Boolean
     135        CanSeek = True
     136    End Function
     137
     138    Override Function Length() As QWord
     139        Length = 0
     140    End Function
     141
     142    Override Sub Position(value As QWord)
     143    End Sub
     144
     145    Override Function Position() As QWord
     146        Position = 0
     147    End Function
     148
     149    Override Function Seek(offset As Int64, origin As SeekOrigin) As Int64
     150        Seek = 0
     151    End Function
     152
     153    Override Sub SetLength(value As QWord)
     154    End Sub
     155End Class
     156
     157End Namespace
    89158
    90159End Namespace
Note: See TracChangeset for help on using the changeset viewer.