aboutsummaryrefslogtreecommitdiff
path: root/okio/src/jvmMain/kotlin/okio/BufferedSource.kt
blob: b312d5695830d6e757ed8203540cc24a307ae161 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * Copyright (C) 2014 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package okio

import java.io.IOException
import java.io.InputStream
import java.nio.channels.ReadableByteChannel
import java.nio.charset.Charset

actual interface BufferedSource : Source, ReadableByteChannel {
  /** Returns this source's internal buffer. */
  @Deprecated(
    message = "moved to val: use getBuffer() instead",
    replaceWith = ReplaceWith(expression = "buffer"),
    level = DeprecationLevel.WARNING
  )
  fun buffer(): Buffer

  actual val buffer: Buffer

  @Throws(IOException::class)
  actual fun exhausted(): Boolean

  @Throws(IOException::class)
  actual fun require(byteCount: Long)

  @Throws(IOException::class)
  actual fun request(byteCount: Long): Boolean

  @Throws(IOException::class)
  actual fun readByte(): Byte

  @Throws(IOException::class)
  actual fun readShort(): Short

  @Throws(IOException::class)
  actual fun readShortLe(): Short

  @Throws(IOException::class)
  actual fun readInt(): Int

  @Throws(IOException::class)
  actual fun readIntLe(): Int

  @Throws(IOException::class)
  actual fun readLong(): Long

  @Throws(IOException::class)
  actual fun readLongLe(): Long

  @Throws(IOException::class)
  actual fun readDecimalLong(): Long

  @Throws(IOException::class)
  actual fun readHexadecimalUnsignedLong(): Long

  @Throws(IOException::class)
  actual fun skip(byteCount: Long)

  @Throws(IOException::class)
  actual fun readByteString(): ByteString

  @Throws(IOException::class)
  actual fun readByteString(byteCount: Long): ByteString

  @Throws(IOException::class)
  actual fun select(options: Options): Int

  @Throws(IOException::class)
  actual fun readByteArray(): ByteArray

  @Throws(IOException::class)
  actual fun readByteArray(byteCount: Long): ByteArray

  @Throws(IOException::class)
  actual fun read(sink: ByteArray): Int

  @Throws(IOException::class)
  actual fun readFully(sink: ByteArray)

  @Throws(IOException::class)
  actual fun read(sink: ByteArray, offset: Int, byteCount: Int): Int

  @Throws(IOException::class)
  actual fun readFully(sink: Buffer, byteCount: Long)

  @Throws(IOException::class)
  actual fun readAll(sink: Sink): Long

  @Throws(IOException::class)
  actual fun readUtf8(): String

  @Throws(IOException::class)
  actual fun readUtf8(byteCount: Long): String

  @Throws(IOException::class)
  actual fun readUtf8Line(): String?

  @Throws(IOException::class)
  actual fun readUtf8LineStrict(): String

  @Throws(IOException::class)
  actual fun readUtf8LineStrict(limit: Long): String

  @Throws(IOException::class)
  actual fun readUtf8CodePoint(): Int

  /** Removes all bytes from this, decodes them as `charset`, and returns the string. */
  @Throws(IOException::class)
  fun readString(charset: Charset): String

  /**
   * Removes `byteCount` bytes from this, decodes them as `charset`, and returns the
   * string.
   */
  @Throws(IOException::class)
  fun readString(byteCount: Long, charset: Charset): String

  @Throws(IOException::class)
  actual fun indexOf(b: Byte): Long

  @Throws(IOException::class)
  actual fun indexOf(b: Byte, fromIndex: Long): Long

  @Throws(IOException::class)
  actual fun indexOf(b: Byte, fromIndex: Long, toIndex: Long): Long

  @Throws(IOException::class)
  actual fun indexOf(bytes: ByteString): Long

  @Throws(IOException::class)
  actual fun indexOf(bytes: ByteString, fromIndex: Long): Long

  @Throws(IOException::class)
  actual fun indexOfElement(targetBytes: ByteString): Long

  @Throws(IOException::class)
  actual fun indexOfElement(targetBytes: ByteString, fromIndex: Long): Long

  @Throws(IOException::class)
  actual fun rangeEquals(offset: Long, bytes: ByteString): Boolean

  @Throws(IOException::class)
  actual fun rangeEquals(offset: Long, bytes: ByteString, bytesOffset: Int, byteCount: Int): Boolean

  actual fun peek(): BufferedSource

  /** Returns an input stream that reads from this source. */
  fun inputStream(): InputStream
}