All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.it.unibo.tuprolog.solve.channel.OutputChannel.kt Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy