Package-level declarations

Types

Link copied to clipboard

A bidirectional TOML transcoder, capable of converting TomlValues into Kotlin values, and vice versa.

Link copied to clipboard

Functions

Link copied to clipboard

Serializes given value into a valid TOML document and writes it to a temporary file in the same directory as the file indicated by path. The file will then be synced to disk, and finally moved to its final destination, atomically replacing any pre-existing file in that location.

Link copied to clipboard
inline fun <T> TomlMapper.decode(stream: InputStream): T

Parses the given TOML-formatted input stream into a TOML document and decodes it into the given type T.

inline fun <T> TomlMapper.decode(path: Path): T

Parses the given TOML-formatted file into a TOML document and decodes it into the given type T.

inline fun <T> TomlMapper.decode(string: String): T

Parses the given TOML-formatted string into a TOML document and decodes it into the given type T.

Link copied to clipboard
inline fun <T> TomlMapper.decodeWithDefaults(defaultValue: T, stream: InputStream): T

Like decode, but fills in any values missing from the input stream with values from the given defaultValue.

inline fun <T> TomlMapper.decodeWithDefaults(defaultValue: T, path: Path): T

Like decode, but fills in any values missing from the input file with values from the given defaultValue.

inline fun <T> TomlMapper.decodeWithDefaults(defaultValue: T, string: String): T

Like decode, but fills in any values missing from the input string with values from the given defaultValue.

Link copied to clipboard

Delegate the handling of the given type to the given mapper. Overrides any previous configuration for that type, and will be overridden in turn by any subsequent configuration.

Link copied to clipboard
fun TomlMapper.encodeTo(outputStream: OutputStream, value: Any)

Serializes given value into a valid TOML document and writes it to the given OutputStream. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.

fun TomlMapper.encodeTo(output: Appendable, value: Any)

Serializes given value into a valid TOML document and writes it to the given Appendable. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.

fun TomlMapper.encodeTo(path: Path, value: Any)

Serializes given value into a valid TOML document and writes it to the file indicated by the given Path. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.

Link copied to clipboard

Encodes the given value into a valid TOML document. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.

Link copied to clipboard

Encodes the given value into a valid TOML document and serializes it into a string. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.

Link copied to clipboard
operator fun TomlValue.get(vararg path: String): TomlValue?

Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by the type parameter T. If decoding is not possible, a TomlException.DecodingError is thrown. If there is no value at the given path, null is returned.

inline fun <T : Any> TomlValue.get(mapper: TomlMapper, vararg path: String): T?

Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by T using the given custom TOML decoder.

fun <T> TomlValue.get(mapper: TomlMapper, targetKType: KType, path: List<String>): T?

Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by targetKType using the given custom TOML decoder. targetKType and T should correspond to the same type, or the behavior of get is undefined.

Link copied to clipboard

Creates a new TOML mapper with the given configuration. In the interest of efficiency, consider creating a mapper once and then keeping it around for the duration of your program, rather than re-creating it every time you need to process a TOML value.

fun tomlMapper(baseMapper: TomlMapper, configuration: TomlMapperConfigurator.() -> Unit): TomlMapper

Creates a mapper which inherits all its configuration from the given baseMapper.

Link copied to clipboard