]> Cypherpunks repositories - gostls13.git/commitdiff
io: add ByteScanner, RuneScanner interfaces
authorRobert Griesemer <gri@golang.org>
Thu, 26 May 2011 18:03:52 +0000 (11:03 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 26 May 2011 18:03:52 +0000 (11:03 -0700)
R=r, rsc
CC=golang-dev
https://golang.org/cl/4530069

src/pkg/io/io.go

index 1ad1129923c5a9e2e3754fb9d7bf69d8dfe9c626..846dcacb5aa439522eebad8db6210a193bcfa565 100644 (file)
@@ -162,6 +162,18 @@ type ByteReader interface {
        ReadByte() (c byte, err os.Error)
 }
 
+// ByteScanner is the interface that adds the UnreadByte method to the
+// basic ReadByte method.
+//
+// UnreadByte causes the next call to ReadByte to return the same byte
+// as the previous call to ReadByte.
+// It may be an error to call UnreadByte twice without an intervening
+// call to ReadByte.
+type ByteScanner interface {
+       ByteReader
+       UnreadByte() os.Error
+}
+
 // RuneReader is the interface that wraps the ReadRune method.
 //
 // ReadRune reads a single UTF-8 encoded Unicode character
@@ -171,6 +183,18 @@ type RuneReader interface {
        ReadRune() (rune int, size int, err os.Error)
 }
 
+// RuneScanner is the interface that adds the UnreadRune method to the
+// basic ReadRune method.
+//
+// UnreadRune causes the next call to ReadRune to return the same rune
+// as the previous call to ReadRune.
+// It may be an error to call UnreadRune twice without an intervening
+// call to ReadRune.
+type RuneScanner interface {
+       RuneReader
+       UnreadRune() os.Error
+}
+
 // WriteString writes the contents of the string s to w, which accepts an array of bytes.
 func WriteString(w Writer, s string) (n int, err os.Error) {
        return w.Write([]byte(s))