-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes #65 (#73) Remove ktor-http Dependency from ksoup-core by Implementing String.resolveOrNull in Pure Kotlin * Implement KMP CodePoint and remove external dependency (#75) Fixes #74 Create a pure Kotlin implementation for CodePoint & remove the external dependency for CodePoint * fix charbuf NPE * add isUtf8Only flag for charset * update extension function for SourceReader * fix clock millis * add ksoup-lite variant (#77)
- Loading branch information
Showing
61 changed files
with
683 additions
and
707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ jobs: | |
matrix: | ||
buildType: | ||
- "common" | ||
- "lite" | ||
- "kotlinx" | ||
- "korlibs" | ||
- "ktor2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
ksoup-engine-common/src/com/fleeksoft/ksoup/io/SourceReaderByteArray.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.fleeksoft.ksoup.io | ||
|
||
internal class SourceReaderByteArray(bytes: ByteArray) : SourceReader { | ||
private var source: ByteArray = bytes | ||
private var currentPosition: Int = 0 | ||
private var markedPosition: Int? = null | ||
private var isClosed: Boolean = false | ||
|
||
override fun mark(readLimit: Long) { | ||
markedPosition = currentPosition | ||
} | ||
|
||
override fun reset() { | ||
isClosed = false | ||
markedPosition?.let { | ||
currentPosition = it | ||
markedPosition = null | ||
} | ||
} | ||
|
||
|
||
override fun readBytes(count: Int): ByteArray { | ||
val byteArray = ByteArray(count) | ||
var i = 0 | ||
while (exhausted().not() && i < count) { | ||
byteArray[i] = source[currentPosition++] | ||
i++ | ||
} | ||
return if (i == 0) { | ||
byteArrayOf() | ||
} else if (i != count) { | ||
byteArray.sliceArray(0 until i) | ||
} else { | ||
byteArray | ||
} | ||
} | ||
|
||
override fun read(bytes: ByteArray, offset: Int, length: Int): Int { | ||
var i = offset | ||
while (exhausted().not() && i < length) { | ||
bytes[i] = source[currentPosition++] | ||
i++ | ||
} | ||
return i | ||
} | ||
|
||
override fun readAllBytes(): ByteArray { | ||
return readBytes(source.size - currentPosition) | ||
} | ||
|
||
override fun exhausted(): Boolean { | ||
return currentPosition >= source.size | ||
} | ||
|
||
override fun close() { | ||
// on reset we need bytes again | ||
// source = ByteArray(0) | ||
// currentPosition = 0 | ||
// markedPosition = null | ||
isClosed = true | ||
} | ||
|
||
override fun readAtMostTo(sink: KByteBuffer, byteCount: Int): Int { | ||
val bytes = readBytes(byteCount) | ||
sink.writeBytes(bytes, bytes.size) | ||
return bytes.size | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
ksoup-engine-common/src/com/fleeksoft/ksoup/io/SourceReaderExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.fleeksoft.ksoup.io | ||
|
||
fun SourceReader.Companion.from(byteArray: ByteArray): SourceReader = SourceReaderByteArray(byteArray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.