Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/base16/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Base16 (a.k.a. "hex") encoding/decoding in accordance with [RFC 4648 section 8][
val base16 = Base16.Builder {
isLenient(enable = true)
lineBreak(interval = 64)
lineBreakReset(onFlush = true)
encodeLowercase(enable = true)
backFillBuffers(enable = true)
}

val text = "Hello World!"
Expand Down
3 changes: 2 additions & 1 deletion library/base16/api/base16.api
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public final class io/matthewnelson/encoding/base16/Base16$Builder {
public final fun encodeLowercase (Z)Lio/matthewnelson/encoding/base16/Base16$Builder;
public final fun isLenient (Z)Lio/matthewnelson/encoding/base16/Base16$Builder;
public final fun lineBreak (B)Lio/matthewnelson/encoding/base16/Base16$Builder;
public final fun lineBreakReset (Z)Lio/matthewnelson/encoding/base16/Base16$Builder;
public final fun strictSpec ()Lio/matthewnelson/encoding/base16/Base16$Builder;
}

Expand All @@ -36,7 +37,7 @@ public final class io/matthewnelson/encoding/base16/Base16$Config : io/matthewne
public final field encodeLowercase Z
public final field encodeToLowercase Z
public final field isConstantTime Z
public synthetic fun <init> (ZBZZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (ZBZZZLkotlin/jvm/internal/DefaultConstructorMarker;)V
}

public final class io/matthewnelson/encoding/base16/Base16ConfigBuilder {
Expand Down
1 change: 1 addition & 0 deletions library/base16/api/base16.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class io.matthewnelson.encoding.base16/Base16 : io.matthewnelson.encoding.
final fun encodeLowercase(kotlin/Boolean): io.matthewnelson.encoding.base16/Base16.Builder // io.matthewnelson.encoding.base16/Base16.Builder.encodeLowercase|encodeLowercase(kotlin.Boolean){}[0]
final fun isLenient(kotlin/Boolean): io.matthewnelson.encoding.base16/Base16.Builder // io.matthewnelson.encoding.base16/Base16.Builder.isLenient|isLenient(kotlin.Boolean){}[0]
final fun lineBreak(kotlin/Byte): io.matthewnelson.encoding.base16/Base16.Builder // io.matthewnelson.encoding.base16/Base16.Builder.lineBreak|lineBreak(kotlin.Byte){}[0]
final fun lineBreakReset(kotlin/Boolean): io.matthewnelson.encoding.base16/Base16.Builder // io.matthewnelson.encoding.base16/Base16.Builder.lineBreakReset|lineBreakReset(kotlin.Boolean){}[0]
final fun strictSpec(): io.matthewnelson.encoding.base16/Base16.Builder // io.matthewnelson.encoding.base16/Base16.Builder.strictSpec|strictSpec(){}[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import kotlin.jvm.JvmSynthetic
* val base16 = Base16.Builder {
* isLenient(enable = true)
* lineBreak(interval = 64)
* lineBreakReset(onFlush = true)
* encodeLowercase(enable = true)
* backFillBuffers(enable = true)
* }
*
* val text = "Hello World!"
Expand Down Expand Up @@ -72,22 +74,26 @@ public class Base16: EncoderDecoder<Base16.Config> {
if (other == null) return
this._isLenient = other.isLenient ?: true
this._lineBreakInterval = other.lineBreakInterval
this._lineBreakResetOnFlush = other.lineBreakResetOnFlush
this._encodeLowercase = other.encodeLowercase
this._backFillBuffers = other.backFillBuffers
}

@get:JvmSynthetic
@set:JvmSynthetic
internal var _isLenient: Boolean = true
private set
@get:JvmSynthetic
@set:JvmSynthetic
internal var _lineBreakInterval: Byte = 0
private set
@get:JvmSynthetic
internal var _lineBreakResetOnFlush: Boolean = true
private set
@get:JvmSynthetic
@set:JvmSynthetic
internal var _encodeLowercase: Boolean = false
private set
@get:JvmSynthetic
@set:JvmSynthetic
internal var _backFillBuffers: Boolean = true
private set

/**
* DEFAULT: `true`
Expand Down Expand Up @@ -130,6 +136,13 @@ public class Base16: EncoderDecoder<Base16.Config> {
* */
public fun lineBreak(interval: Byte): Builder = apply { _lineBreakInterval = interval }

/**
* DEFAULT: `true`
*
* @see [EncoderDecoder.Config.lineBreakResetOnFlush]
* */
public fun lineBreakReset(onFlush: Boolean): Builder = apply { _lineBreakResetOnFlush = onFlush }

/**
* DEFAULT: `false`
*
Expand Down Expand Up @@ -180,12 +193,14 @@ public class Base16: EncoderDecoder<Base16.Config> {
public class Config private constructor(
isLenient: Boolean,
lineBreakInterval: Byte,
lineBreakResetOnFlush: Boolean,
@JvmField
public val encodeLowercase: Boolean,
backFillBuffers: Boolean,
): EncoderDecoder.Config(
isLenient,
lineBreakInterval,
lineBreakResetOnFlush,
paddingChar = null,
maxDecodeEmit = 1,
backFillBuffers,
Expand Down Expand Up @@ -222,6 +237,7 @@ public class Base16: EncoderDecoder<Base16.Config> {
internal val DEFAULT: Config = Config(
isLenient = true,
lineBreakInterval = 64,
lineBreakResetOnFlush = true,
encodeLowercase = false,
backFillBuffers = true,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public class Base16ConfigBuilder {
isLenient = compat._isLenient
lineBreakInterval = compat._lineBreakInterval
encodeToLowercase = compat._encodeLowercase

// Prior to 2.6.0, behavior was broken whereby the
// LineBreakOutFeed was not being reset whenever
// Encoder.Feed.flush was called. This maintains
// that behavior for consumers who have not updated
// to the Builder API.
compat.lineBreakReset(onFlush = false)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ package io.matthewnelson.encoding.base16.internal

import io.matthewnelson.encoding.base16.Base16

internal inline fun ((Boolean, Byte, Boolean, Boolean) -> Base16.Config).build(
internal inline fun ((Boolean, Byte, Boolean, Boolean, Boolean) -> Base16.Config).build(
b: Base16.Builder,
noinline base16: (Base16.Config, Any?) -> Base16,
): Base16 {
if (
b._isLenient == Base16.DELEGATE.config.isLenient
&& b._lineBreakInterval == Base16.DELEGATE.config.lineBreakInterval
&& b._lineBreakResetOnFlush == Base16.DELEGATE.config.lineBreakResetOnFlush
&& b._encodeLowercase == Base16.DELEGATE.config.encodeLowercase
&& b._backFillBuffers == Base16.DELEGATE.config.backFillBuffers
) {
Expand All @@ -34,6 +35,7 @@ internal inline fun ((Boolean, Byte, Boolean, Boolean) -> Base16.Config).build(
val config = this(
b._isLenient,
b._lineBreakInterval,
b._lineBreakResetOnFlush,
b._encodeLowercase,
b._backFillBuffers,
)
Expand Down
5 changes: 5 additions & 0 deletions library/base32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ val crockford = Base32.Crockford.Builder {
encodeLowercase(enable = false)
hyphen(interval = 5)
check(symbol = '~')
backFillBuffers(enable = true)
}

val text = "Hello World!"
Expand All @@ -25,8 +26,10 @@ assertEquals(text, decoded)
val default = Base32.Default.Builder {
isLenient(enable = true)
lineBreak(interval = 64)
lineBreakReset(onFlush = true)
encodeLowercase(enable = false)
padEncoded(enable = true)
backFillBuffers(enable = true)
}

val text = "Hello World!"
Expand All @@ -44,8 +47,10 @@ assertEquals(text, decoded)
val hex = Base32.Hex.Builder {
isLenient(enable = true)
lineBreak(interval = 64)
lineBreakReset(onFlush = true)
encodeLowercase(enable = false)
padEncoded(enable = true)
backFillBuffers(enable = true)
}

val text = "Hello World!"
Expand Down
6 changes: 4 additions & 2 deletions library/base32/api/base32.api
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public final class io/matthewnelson/encoding/base32/Base32$Default$Builder {
public final fun encodeLowercase (Z)Lio/matthewnelson/encoding/base32/Base32$Default$Builder;
public final fun isLenient (Z)Lio/matthewnelson/encoding/base32/Base32$Default$Builder;
public final fun lineBreak (B)Lio/matthewnelson/encoding/base32/Base32$Default$Builder;
public final fun lineBreakReset (Z)Lio/matthewnelson/encoding/base32/Base32$Default$Builder;
public final fun padEncoded (Z)Lio/matthewnelson/encoding/base32/Base32$Default$Builder;
public final fun strictSpec ()Lio/matthewnelson/encoding/base32/Base32$Default$Builder;
}
Expand All @@ -132,7 +133,7 @@ public final class io/matthewnelson/encoding/base32/Base32$Default$Config : io/m
public final field encodeToLowercase Z
public final field isConstantTime Z
public final field padEncoded Z
public synthetic fun <init> (ZBZZZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (ZBZZZZLkotlin/jvm/internal/DefaultConstructorMarker;)V
}

public final class io/matthewnelson/encoding/base32/Base32$Hex : io/matthewnelson/encoding/base32/Base32 {
Expand All @@ -153,6 +154,7 @@ public final class io/matthewnelson/encoding/base32/Base32$Hex$Builder {
public final fun encodeLowercase (Z)Lio/matthewnelson/encoding/base32/Base32$Hex$Builder;
public final fun isLenient (Z)Lio/matthewnelson/encoding/base32/Base32$Hex$Builder;
public final fun lineBreak (B)Lio/matthewnelson/encoding/base32/Base32$Hex$Builder;
public final fun lineBreakReset (Z)Lio/matthewnelson/encoding/base32/Base32$Hex$Builder;
public final fun padEncoded (Z)Lio/matthewnelson/encoding/base32/Base32$Hex$Builder;
public final fun strictSpec ()Lio/matthewnelson/encoding/base32/Base32$Hex$Builder;
}
Expand All @@ -167,7 +169,7 @@ public final class io/matthewnelson/encoding/base32/Base32$Hex$Config : io/matth
public final field encodeToLowercase Z
public final field isConstantTime Z
public final field padEncoded Z
public synthetic fun <init> (ZBZZZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (ZBZZZZLkotlin/jvm/internal/DefaultConstructorMarker;)V
}

public final class io/matthewnelson/encoding/base32/Base32CrockfordConfigBuilder {
Expand Down
2 changes: 2 additions & 0 deletions library/base32/api/base32.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ sealed class <#A: io.matthewnelson.encoding.core/EncoderDecoder.Config> io.matth
final fun encodeLowercase(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Default.Builder // io.matthewnelson.encoding.base32/Base32.Default.Builder.encodeLowercase|encodeLowercase(kotlin.Boolean){}[0]
final fun isLenient(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Default.Builder // io.matthewnelson.encoding.base32/Base32.Default.Builder.isLenient|isLenient(kotlin.Boolean){}[0]
final fun lineBreak(kotlin/Byte): io.matthewnelson.encoding.base32/Base32.Default.Builder // io.matthewnelson.encoding.base32/Base32.Default.Builder.lineBreak|lineBreak(kotlin.Byte){}[0]
final fun lineBreakReset(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Default.Builder // io.matthewnelson.encoding.base32/Base32.Default.Builder.lineBreakReset|lineBreakReset(kotlin.Boolean){}[0]
final fun padEncoded(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Default.Builder // io.matthewnelson.encoding.base32/Base32.Default.Builder.padEncoded|padEncoded(kotlin.Boolean){}[0]
final fun strictSpec(): io.matthewnelson.encoding.base32/Base32.Default.Builder // io.matthewnelson.encoding.base32/Base32.Default.Builder.strictSpec|strictSpec(){}[0]
}
Expand Down Expand Up @@ -174,6 +175,7 @@ sealed class <#A: io.matthewnelson.encoding.core/EncoderDecoder.Config> io.matth
final fun encodeLowercase(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Hex.Builder // io.matthewnelson.encoding.base32/Base32.Hex.Builder.encodeLowercase|encodeLowercase(kotlin.Boolean){}[0]
final fun isLenient(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Hex.Builder // io.matthewnelson.encoding.base32/Base32.Hex.Builder.isLenient|isLenient(kotlin.Boolean){}[0]
final fun lineBreak(kotlin/Byte): io.matthewnelson.encoding.base32/Base32.Hex.Builder // io.matthewnelson.encoding.base32/Base32.Hex.Builder.lineBreak|lineBreak(kotlin.Byte){}[0]
final fun lineBreakReset(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Hex.Builder // io.matthewnelson.encoding.base32/Base32.Hex.Builder.lineBreakReset|lineBreakReset(kotlin.Boolean){}[0]
final fun padEncoded(kotlin/Boolean): io.matthewnelson.encoding.base32/Base32.Hex.Builder // io.matthewnelson.encoding.base32/Base32.Hex.Builder.padEncoded|padEncoded(kotlin.Boolean){}[0]
final fun strictSpec(): io.matthewnelson.encoding.base32/Base32.Hex.Builder // io.matthewnelson.encoding.base32/Base32.Hex.Builder.strictSpec|strictSpec(){}[0]
}
Expand Down
Loading