commonMain.it.unibo.tuprolog.solve.channel.OutputStore.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.solve.channel.impl.OutputStoreImpl
import it.unibo.tuprolog.solve.exception.Warning
import kotlin.js.JsName
import kotlin.jvm.JvmOverloads
import kotlin.jvm.JvmStatic
interface OutputStore : ChannelStore, OutputStore> {
@JsName("stdOut")
val stdOut: OutputChannel
@JsName("setStdOut")
fun setStdOut(channel: OutputChannel): OutputStore
@JsName("stdErr")
val stdErr: OutputChannel
@JsName("setStdErr")
fun setStdErr(channel: OutputChannel): OutputStore
@JsName("warnings")
val warnings: OutputChannel
@JsName("setWarnings")
fun setWarnings(channel: OutputChannel): OutputStore
companion object {
const val STDOUT = "stdout"
const val STDERR = "stderr"
@JsName("fromStandard")
@JvmStatic
@JvmOverloads
fun fromStandard(
output: OutputChannel = OutputChannel.stdOut(),
error: OutputChannel = OutputChannel.stdErr(),
warnings: OutputChannel = OutputChannel.warn(),
): OutputStore = OutputStoreImpl(output, error, warnings, mapOf("user_output" to output))
@JsName("of")
@JvmStatic
@JvmOverloads
fun of(
channels: Map>,
warnings: OutputChannel = OutputChannel.warn(),
): OutputStore {
val stdOut = channels[STDOUT] ?: OutputChannel.stdOut()
val stdErr = channels[STDERR] ?: OutputChannel.stdErr()
return OutputStoreImpl(stdOut, stdErr, warnings, channels)
}
}
}