Package-level declarations

Types

Link copied to clipboard

The :io-lib it.unibo.tuprolog.solve.library.Library, contributing the ISO Prolog stream/I/O predicates: stream management (open/3,4, close/1,2, current_input/1, current_output/1, set_input/1, set_output/1, stream_property/2, at_end_of_stream/0,1, flush_output/1), character/code-level reading and writing (get_char/1,2, get_code/1,2, peek_char/1,2, peek_code/1,2, put_char/1,2, put_code/1,2, nl/1), term I/O (read/1,2, read_term/2,3, write/2, writeq/1,2, write_canonical/1,2, write_term/2,3), plus the tuProlog-specific consult/1 and set_theory/1 for loading a theory from a it.unibo.tuprolog.solve.libs.io.Url.

Link copied to clipboard
enum IOMode : Enum<IOMode>

The three modes a stream can be opened with via it.unibo.tuprolog.solve.libs.io.primitives.Open3 or it.unibo.tuprolog.solve.libs.io.primitives.Open4, mirroring the mode argument of ISO's open/3,4: READ opens an existing source for input, WRITE truncates (or creates) a sink for output, and APPEND opens (or creates) a sink for output, positioned at its end.

Link copied to clipboard
class JsUrl : Url

JS implementation of Url, hand-parsed via the WHATWG JsNativeUrl binding (there being no java.net.URL equivalent to wrap, unlike it.unibo.tuprolog.solve.libs.io.JvmUrl).

Link copied to clipboard
data class JvmUrl(val url: URL) : Url

JVM implementation of Url, thinly wrapping a java.net. url (accessible for interop, e.g. with code that needs a plain java.net.URL/URI).

Link copied to clipboard
interface Url

A parsed source/sink locator, as accepted by the ISO SourceSink argument of open/3,4 and consult/1 (see it.unibo.tuprolog.solve.libs.io.primitives.IOPrimitiveUtils.ensuringArgumentIsUrl), and the type this module's stream-opening functions (openInputChannel, openOutputChannel) operate on.

Functions

Link copied to clipboard

Wraps this channel of raw characters into a channel of Terms, parsed lazily off it using operators. Repeated calls on the same channel return the same wrapped channel, so parsing resumes where the previous call left off.

Link copied to clipboard
expect fun fileUrl(path: String): Url

Platform-specific factory backing Url.Companion.file: builds a file://-scheme Url for path.

actual fun fileUrl(path: String): Url

Platform-specific factory backing Url.Companion.file: builds a file://-scheme Url for path.

actual fun fileUrl(path: String): Url

Platform-specific factory backing Url.Companion.file: builds a file://-scheme Url for path.

Link copied to clipboard

Under Node, streams a local file lazily off disk. Everywhere else (browser-local or any remote resource), eagerly reads the whole resource via Url.readAsText into an in-memory InputChannel instead, since Okio has no synchronous file system for browsers and this module has no HTTP streaming client (see fetch).

Streams a local file lazily off disk via LocalFileSystem; for any non-Url.isFile URL (http(s), ...), lazily streams from java.net.URL.openStream, unlike the JS implementation which eagerly buffers remote resources in full.

Link copied to clipboard
expect fun Url.openOutputChannel(append: Boolean = false): OutputChannel<String>

Opens this Url for writing (or, if append, for appending), e.g. to back open(Url, write, Stream) (see it.unibo.tuprolog.solve.libs.io.primitives.Open3).

Only supported for local files under Node: browsers have no writable local file system, and this module never supports writing to remote resources (on any platform).

Only supported for Url.isFile URLs: writing to a remote resource is never supported (on any platform).

Link copied to clipboard
expect fun parseUrl(string: String): Url

Platform-specific factory backing Url.Companion.of: parses string into a Url.

actual fun parseUrl(string: String): Url

Platform-specific factory backing Url.Companion.of: parses string into a Url.

actual fun parseUrl(string: String): Url

Platform-specific factory backing Url.Companion.of: parses string into a Url.

Link copied to clipboard
expect fun remoteUrl(protocol: String, host: String = "", port: Int? = null, path: String = "", query: String? = null): Url

Platform-specific factory backing Url.Companion.remote.

actual fun remoteUrl(protocol: String, host: String, port: Int?, path: String, query: String?): Url

Platform-specific factory backing Url.Companion.remote.

actual fun remoteUrl(protocol: String, host: String, port: Int?, path: String, query: String?): Url

Platform-specific factory backing Url.Companion.remote.

Link copied to clipboard
fun Url.toURL(): URL

Unwraps this Url into a plain java.net. URL, for interop with JVM APIs that require one.

Link copied to clipboard
fun URL.toUrl(): Url

Wraps a plain java.net. URL into a Url, for interop with code that already has one (e.g. JVM APIs).