Changeset 432 for trunk/Include/Classes/System/IO/TextReader.ab
- Timestamp:
- Feb 27, 2008, 1:04:59 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/IO/TextReader.ab
r426 r432 25 25 End Sub 26 26 27 Abstract Function Peek() As Long 28 Abstract Function Read() As Long 29 /* 30 @date 2008/02/26 31 @auther Egtra 32 */ 33 Function Read(buffer As *StrChar, index As Long, count As Long) As Long 34 If buffer = 0 Then 35 ElseIf index < 0 Then 36 ElseIf count < 0 Then 37 End If 38 End Function 39 40 /* 41 @date 2008/02/26 42 @auther Egtra 43 @retval Nothing EOFに達しているとき 44 @retval 有効なStringインスタンス 読み取った1行 45 */ 46 Virtual Function ReadLine() As String 47 If Peek() = -1 Then 48 Exit Function 49 End If 50 Dim sb = New Text.StringBuilder(256) 51 Do 52 Dim ch = Read() 53 If ch = &h0D Then 54 If Peek() = &h0A Then 55 Read() 'CR LFの場合 56 End If 57 Exit Do 58 End If 59 Select Case ch 60 Case -1 'EOF 61 Exit Do 62 Case &h0A 'LF 63 Exit Do 64 Case &h0B 'VT 65 Exit Do 66 Case &h0C 'FF 67 Exit Do 68 Case &h0D 'CR 69 Exit Do 70 ' Case &h85 'NEL 71 ' Exit Do 72 ' Case &h2028 'LS 73 ' Exit Do 74 ' Case &h2029 'PS 75 ' Exit Do 76 End Select 77 sb.Append(ch As StrChar) 'ToDo キャスト不要にすべきというチケットを書くこと 78 Loop 79 ReadLine = sb.ToString 80 End Function 81 /* 82 @date 2008/02/26 83 @auther Egtra 84 */ 85 Virtual Function ReadToEnd() As String 86 Dim sb = New Text.StringBuilder(8192) 87 Do 88 Dim ch = Read() 89 If ch = -1 Then 90 ReadToEnd = sb.ToString 91 Exit Function 92 End If 93 sb.Append(ch As StrChar) 94 Loop 95 End Function 96 97 Protected 27 98 Abstract Sub Dispose(disposing As Boolean) 28 99 29 Abstract Function Peek() As Long 30 Abstract Function Read() As Long 31 Abstract Function Read(buffer As *StrChar, index As Long, count As Long) As Long 32 Virtual Function ReadBlock(buffer As *StrChar, index As Long, count As Long) As Long 33 ReadBlock = Read(buffer, index, count) 100 /* 101 @date 2008/02/26 102 @auther Egtra 103 */ 104 Virtual Function ReadImpl(buffer As *StrChar, index As Long, count As Long) As Long 105 Dim i As Long 106 Dim p = VarPtr(buffer[index]) 107 For i = 0 To ELM(count) 108 Dim c = Read() 109 If c = -1 Then 110 ReadImpl = i - 1 111 Exit Function 112 Else 113 p[i] = c As StrChar 114 End If 115 Next 116 ReadImpl = i - 1 34 117 End Function 35 Abstract Function ReadLine() As String36 Abstract Function ReadToEnd() As String37 118 End Class 38 119
Note:
See TracChangeset
for help on using the changeset viewer.