Changeset 655 for trunk/ab5.0/ablib/src/Classes/System/IO/TextReader.ab
- Timestamp:
- Nov 9, 2008, 2:21:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/System/IO/TextReader.ab
r497 r655 1 Name Space System2 Name Space IO1 Namespace System 2 Namespace IO 3 3 4 4 Class TextReader 5 5 Implements System.IDisposable 6 7 Public8 'Protected9 Sub TextReader()10 End Sub11 6 Public 12 7 Virtual Sub ~TextReader() … … 31 26 @auther Egtra 32 27 */ 33 Function Read(buffer As * Char, index As Long, count As Long) As Long28 Function Read(buffer As *WCHAR, index As Long, count As Long) As Long 34 29 If buffer = 0 Then 30 Throw New ArgumentNullException("buffer") 35 31 ElseIf index < 0 Then 32 Throw New ArgumentOutOfRangeException("index") 36 33 ElseIf count < 0 Then 34 Throw New ArgumentOutOfRangeException("count") 37 35 End If 38 Read = ReadImpl(buffer, index, count) 36 Read = ReadImpl(VarPtr(buffer[index]), count) 37 End Function 38 39 Static Function Synchronized(reader As TextReader) As TextReader 40 Synchronized = New Detail.SynchronizedTextReader(reader) 39 41 End Function 40 42 … … 45 47 @retval 有効なStringインスタンス 読み取った1行 46 48 */ 47 VirtualFunction ReadLine() As String49 Function ReadLine() As String 48 50 If Peek() = -1 Then 49 51 Exit Function 50 52 End If 51 Dim sb = New Text.StringBuilder(256)53 Dim sb = New Collections.Generic.List<WCHAR> 52 54 Do 53 55 Dim ch = Read() … … 69 71 Case &h0D 'CR 70 72 Exit Do 71 'Case &h85 'NEL72 'Exit Do73 'Case &h2028 'LS74 'Exit Do75 'Case &h2029 'PS76 'Exit Do73 Case &h85 'NEL 74 Exit Do 75 Case &h2028 'LS 76 Exit Do 77 Case &h2029 'PS 78 Exit Do 77 79 End Select 78 sb.A ppend(ch As Char) 'ToDo キャスト不要にすべきというチケットを書くこと80 sb.Add(ch As WCHAR) 79 81 Loop 80 ReadLine = sb.ToString82 ReadLine = New String(sb As *WCHAR, sb.Count) 81 83 End Function 82 84 /* … … 97 99 End Function 98 100 99 Static Function Synchronized(reader As TextReader) As TextReader 100 Synchronized = New Detail.SynchronizedTextReader(reader)101 End Function101 Protected 102 Sub TextReader() 103 End Sub 102 104 103 Protected104 105 Virtual Sub Dispose(disposing As Boolean) 105 106 End Sub … … 109 110 @auther Egtra 110 111 */ 111 Virtual Function ReadImpl(buffer As * Char, index As Long, count As Long) As Long112 Virtual Function ReadImpl(buffer As *WCHAR, count As Long) As Long 112 113 Dim i As Long 113 Dim p = VarPtr(buffer[index])114 114 For i = 0 To ELM(count) 115 115 Dim c = Read() 116 116 If c = -1 Then 117 ReadImpl = i - 1117 ReadImpl = i 118 118 Exit Function 119 119 Else 120 p[i] = c As Char120 buffer[i] = c As Char 121 121 End If 122 122 Next 123 ReadImpl = i - 1123 ReadImpl = i 124 124 End Function 125 125 End Class … … 147 147 End Function 148 148 149 Override Function ReadLine() As String150 ' Using lock = cs.Lock151 ReadLine = base.ReadLine152 ' End Using153 End Function154 155 Override Function ReadToEnd() As String156 ' Using lock = cs.Lock157 ReadToEnd = base.ReadToEnd158 ' End Using159 End Function160 161 149 Protected 162 150 Override Sub Dispose(disposing As Boolean) … … 171 159 End Sub 172 160 173 Override Function ReadImpl(buffer As * Char, index As Long, count As Long) As Long161 Override Function ReadImpl(buffer As *WCHAR, count As Long) As Long 174 162 ' Using lock = cs.Lock 175 ReadImpl = base.ReadImpl(buffer, index,count)163 ReadImpl = base.ReadImpl(buffer, count) 176 164 ' End Using 177 165 End Function … … 183 171 End Namespace 184 172 185 End Name Space186 End Name Space173 End Namespace 174 End Namespace
Note:
See TracChangeset
for help on using the changeset viewer.