commonMain.it.unibo.tuprolog.solve.channel.OutputChannel.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solve-jvm Show documentation
Show all versions of solve-jvm Show documentation
Resolution-agnostic API for logic solvers
package it.unibo.tuprolog.solve.channel
import it.unibo.tuprolog.core.Struct
import it.unibo.tuprolog.solve.channel.impl.OutputChannelFromFunction
import it.unibo.tuprolog.solve.exception.Warning
import kotlin.js.JsName
import kotlin.jvm.JvmOverloads
import kotlin.jvm.JvmStatic
interface OutputChannel : Channel {
companion object {
@JvmStatic
@JsName("stdOut")
fun stdOut(): OutputChannel = stdout()
@JvmStatic
@JsName("stdErr")
fun stdErr(): OutputChannel = stderr()
@JvmStatic
@JsName("warning")
fun warn(): OutputChannel = warning()
@JvmStatic
@JsName("of")
fun of(consumer: (T) -> Unit): OutputChannel = OutputChannelFromFunction(consumer)
@JvmStatic
@JvmOverloads
@JsName("streamTerm")
fun streamTerm(id: String? = null): Struct = Channel.streamTerm(input = false, id)
}
@JsName("use")
fun use(function: OutputChannel.() -> R): R = this.function().also { close() }
@JsName("write")
fun write(value: T)
@JsName("flush")
fun flush()
}