Index: trunk/Include/Classes/System/IO/StreamReader.ab
===================================================================
--- trunk/Include/Classes/System/IO/StreamReader.ab	(revision 426)
+++ trunk/Include/Classes/System/IO/StreamReader.ab	(revision 432)
@@ -1,23 +1,35 @@
+'Classes/System/IO/StreamReader.ab
+
 Namespace System
 Namespace IO
 
+/*
+@brief ストリームから読み取りを行うTextReaderの実装。
+@date 2008/02/25
+@auther Egtra
+*/
 Class StreamReader
 	Inherits TextReader
 Public
+	/*
+	@date 2008/02/25
+	@auther Egtra
+	*/
 	Sub StreamReader(path As String)
 		init(New FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
 	End Sub
 
+	/*
+	@date 2008/02/25
+	@auther Egtra
+	*/
 	Sub StreamReader(stream As Stream)
 		init(stream)
 	End Sub
 
-	Override Sub Dispose(disposing As Boolean)
-		s.Dispose(disposing)
-		size = 0
-		cur = 0
-		last = 0
-	End Sub
-
+	/*
+	@date 2008/02/25
+	@auther Egtra
+	*/
 	Override Function Peek() As Long
 		If cur = last Then
@@ -32,4 +44,8 @@
 	End Function
 
+	/*
+	@date 2008/02/25
+	@auther Egtra
+	*/
 	Override Function Read() As Long
 		Read = Peek()
@@ -37,18 +53,51 @@
 	End Function
 
-	Override Function Read(buffer As *StrChar, index As Long, count As Long) As Long
-		If buffer = 0 Then
-		ElseIf index < 0 Then
-		ElseIf count < 0 Then
+	/*
+	@date 2008/02/26
+	@auther Egtra
+	*/
+	Override Function ReadToEnd() As String
+		Dim sb = New Text.StringBuilder(65536)
+		sb.Append(buf, cur, last - cur)
+		Do
+			Dim read = Read(buf, 0, size)
+			sb.Append(buf, 0, read)
+			If read < size Then
+				ReadToEnd = sb.ToString
+				Exit Function
+			End If
+		Loop
+	End Function
+
+Protected
+	/*
+	@date 2008/02/25
+	@auther Egtra
+	*/
+	Override Sub Dispose(disposing As Boolean)
+		If disposing Then
+			If Not ActiveBasic.IsNothing(s) Then
+				s.Dispose(True)
+			End If
 		End If
+		s = Nothing
+		size = 0
+		cur = 0
+		last = 0
+	End Sub
 
+	/*
+	@date 2008/02/25
+	@auther Egtra
+	*/
+	Override Function ReadImpl(buffer As *StrChar, index As Long, count As Long) As Long
 		Dim n = last - cur
 		If count <= n Then
-			Read = ReadFromBuffer(buffer, index, count)
+			ReadImpl = ReadFromBuffer(buffer, index, count)
 			Exit Function
 		End If
 		Dim p = VarPtr(buffer[index])
-		Read = ReadFromBuffer(p, 0, n)
-		If Read = count Then 'バッファの中身で足りた場合
+		ReadImpl = ReadFromBuffer(p, 0, n)
+		If ReadImpl = count Then 'バッファの中身で足りた場合
 			Exit Function
 		End If
@@ -62,5 +111,5 @@
 			End If
 			p = VarPtr(p[n])
-			Read += n
+			ReadImpl += n
 			count -= n
 		End If
@@ -70,44 +119,12 @@
 			Exit Function
 		End If
-		Read += ReadFromBuffer(p, 0, Math.Min(last, count))
-	End Function
-
-	Override Function ReadLine() As String
-		Dim sb = New Text.StringBuilder(256)
-		Do
-			Dim ch = Read()
-			If ch = &h0D Then
-				If Peek() = &h0A Then
-					Read() 'CR LFの場合
-				End If
-				Exit Do
-			End If
-			Select Case ch
-				Case -1 'EOF
-					Exit Do
-				Case &h0A 'LF
-					Exit Do
-				Case &h0B 'VT
-					Exit Do
-				Case &h0C 'FF
-					Exit Do
-				Case &h0D 'CR
-					Exit Do
-'				Case &h85 'NEL
-'					Exit Do
-'				Case &h2028 'LS
-'					Exit Do
-'				Case &h2029 'PS
-'					Exit Do
-			End Select
-			sb.Append(ch As StrChar) 'ToDo キャスト不要にすべきというチケットを書くこと
-		Loop
-		ReadLine = sb.ToString
-	End Function
-
-	Override Function ReadToEnd() As String
+		ReadImpl += ReadFromBuffer(p, 0, Math.Min(last, count))
 	End Function
 
 Private
+	/*
+	@date 2008/02/25
+	@auther Egtra
+	*/
 	Sub init(str As Stream)
 		s = str
@@ -120,4 +137,6 @@
 	/**
 	@brief バッファの中身から読み取る。
+	@date 2008/02/25
+	@auther Egtra
 	文字数が足りなくても、元のストリームまで読みには行かない。
 	*/
@@ -132,5 +151,5 @@
 	cur As Long
 	last As Long '中身の終わり
-	buf As *Byte '暫定
+	buf As *SByte '暫定
 End Class
 
