Ignore:
Timestamp:
Mar 9, 2008, 12:00:01 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

TextWriter, StreamWriterの追加。
SPrintfの浮動小数点数変換で、NaN, Infiniteの出力に対応。
PathとDirectoryInfoのCreateDirectoryで、対象が既に存在するときには例外を投げないように修正。
SimpleTestCase内で使用する一時フォルダの場所にGetTempPathで取得する版を追加(コメントアウト)。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/IO/StreamWriter.ab

    r271 r468  
    44   
    55Class StreamWriter
    6     ' TODO: 実装
     6    Inherits TextWriter
     7Public
     8    /*
     9    @date 2008/02/25
     10    @auther Egtra
     11    */
     12    Sub StreamWriter(path As String)
     13        init(New FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
     14    End Sub
     15
     16    /*
     17    @date 2008/02/25
     18    @auther Egtra
     19    */
     20    Sub StreamWriter(stream As Stream)
     21        init(stream)
     22    End Sub
     23
     24    Override Sub Write(str As String)
     25        buf.Append(str)
     26        Dim len = buf.Length
     27        If len >= 2048 Then
     28            s.Write(StrPtr(buf) As *Byte, 0, len)
     29            buf.Length = 0
     30        End If
     31    End Sub
     32
     33    Override Sub Write(x As Boolean)
     34        buf.Append(x)
     35    End Sub
     36   
     37    Override Sub Write(x As Char)
     38        buf.Append(x)
     39    End Sub
     40
     41    Override Sub Write(x As Byte)
     42        buf.Append(x)
     43    End Sub
     44#ifdef UNICODE
     45    Override Sub Write(x As SByte)
     46        buf.Append(x)
     47    End Sub
     48#else
     49    Override Sub Write(x As Word)
     50        buf.Append(x)
     51    End Sub
     52#endif
     53    Override Sub Write(x As Integer)
     54        buf.Append(x)
     55    End Sub
     56
     57    Override Sub Write(x As DWord)
     58        buf.Append(x)
     59    End Sub
     60
     61    Override Sub Write(x As Long)
     62        buf.Append(x)
     63    End Sub
     64
     65    Override Sub Write(x As QWord)
     66        buf.Append(x)
     67    End Sub
     68
     69    Override Sub Write(x As Int64)
     70        buf.Append(x)
     71    End Sub
     72
     73    Override Sub Write(x As Single)
     74        buf.Append(x)
     75    End Sub
     76
     77    Override Sub Write(x As Double)
     78        buf.Append(x)
     79    End Sub
     80
     81    Override Sub Write(x As Object)
     82        Write(x.ToString)
     83    End Sub
     84
     85Protected
     86    Override Sub Dispose(disposing As Boolean)
     87        If disposing Then
     88            s.Dispose()
     89        End If
     90    End Sub
     91
     92Private
     93    Sub init(stream As Stream)
     94        s = stream
     95        buf = New System.Text.StringBuilder(4096)
     96    End Sub
     97
     98    buf As Text.StringBuilder
     99    s As System.IO.Stream
    7100End Class
    8101
Note: See TracChangeset for help on using the changeset viewer.