Package-level declarations

Types

Link copied to clipboard
sealed class Toml : StringFormat

The main entry point to use TOML.

Link copied to clipboard
@Serializable(with = TomlArraySerializer::class)
class TomlArray : TomlElement, List<TomlElement>

Represents array in TOML, which values are TomlElement.

Link copied to clipboard
@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class TomlBlockArray(val itemsPerLine: Int = 1)

Modify the encoding of corresponding array-like property, either to force array of tables to be encoded as block array, or to change how many items will be encoded per line (will override TomlConfig).

Link copied to clipboard
@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class TomlComment(val text: String)

Add comments to corresponding property.

Link copied to clipboard

Builder provided for Toml { ... } factory function.

Link copied to clipboard
interface TomlDecoder : Decoder

A special Decoder which is used internally by decoding process of Toml, providing an extra decodeTomlElement to decode TomlElement from the current position.

Link copied to clipboard
@Serializable(with = TomlElementSerializer::class)
sealed class TomlElement

Represents anything in TOML, including and only including TomlNull, TomlLiteral, TomlArray, TomlTable.

Link copied to clipboard
interface TomlEncoder : Encoder

A special Encoder which is used internally by encoding process of Toml, providing an extra encodeTomlElement to encode TomlElement to the current position.

Link copied to clipboard
value class TomlIndentation(val representation: String)

Indicates indentation representation in string output.

Link copied to clipboard
@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class TomlInline

Force inline the corresponding array-like or table-like property.

Link copied to clipboard
@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class TomlInteger(val base: TomlInteger.Base)

Set the representation of the corresponding Byte, Short, Int, Long property.

Link copied to clipboard
@Serializable(with = TomlLiteralSerializer::class)
class TomlLiteral : TomlElement

Represents literal value, which can be booleans, numbers, chars, strings.

Link copied to clipboard
@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class TomlLiteralString

Mark the corresponding String property as literal when encoded.

Link copied to clipboard
@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class TomlMultilineString

Mark the corresponding String property as multiline when encoded.

Link copied to clipboard
@Serializable(with = TomlNullSerializer::class)
object TomlNull : TomlElement

Represents null.

Link copied to clipboard
annotation class TomlSpecific

Indicates that the corresponding type is only stable to use, but shouldn't be subclassed by any third party, otherwise unpredictable behavior may be observed.

Link copied to clipboard

A TomlWriter that writes TOML to outputStream.

Link copied to clipboard

A TomlWriter that writes TOML as string.

Link copied to clipboard
@Serializable(with = TomlTableSerializer::class)
class TomlTable : TomlElement, Map<String, TomlElement>

Represents table in TOML, which keys are strings and values are TomlElement.

Link copied to clipboard
interface TomlWriter

A custom writer used when encoding Model class or TomlElement to the output.

Functions

Link copied to clipboard
fun Decoder.asTomlDecoder(): TomlDecoder

More convenient approach to cast this Decoder to TomlDecoder.

Link copied to clipboard
fun Encoder.asTomlEncoder(): TomlEncoder

More convenient approach to cast this Decoder to TomlEncoder.

Link copied to clipboard
inline fun <T> Toml.decodeFromTomlElement(element: TomlElement): T

Deserializes element into a value of type T using serializer retrieved from reified type parameter.

Link copied to clipboard
inline fun <T> Toml.encodeToStream(value: T, outputStream: OutputStream)

Serializes value into outputStream using serializer retrieved from reified type parameter.

fun <T> Toml.encodeToStream(serializer: SerializationStrategy<T>, value: T, outputStream: OutputStream)

Serializes value into outputStream using serializer.

Link copied to clipboard
inline fun <T> Toml.encodeToTomlElement(value: T): TomlElement

Serializes value into TomlElement using serializer retrieved from reified type parameter.

Link copied to clipboard
inline fun <T> Toml.encodeToWriter(value: T, writer: TomlWriter)

Serializes value into writer using serializer retrieved from reified type parameter.

Link copied to clipboard
operator fun TomlTable.get(vararg keys: Any?): TomlElement?

Get value along with path constructed by keys.

Link copied to clipboard

Returns content as boolean.

Link copied to clipboard

Returns content as boolean only if content is "true" or "false", otherwise null.

Link copied to clipboard

Returns content as byte.

Link copied to clipboard

Returns content as byte only if content can be byte, otherwise null.

Link copied to clipboard

Returns content as char.

Link copied to clipboard

Returns content as char only if the length of content is exactly 1, otherwise null.

Link copied to clipboard

Returns content as double.

Link copied to clipboard

Returns content as double only if content can be an exact double or inf/-inf/nan, otherwise null.

Link copied to clipboard
inline fun <E : Enum<E>> TomlLiteral.toEnum(serializersModule: SerializersModule = EmptySerializersModule()): E

Returns content as enum with given enum class context.

Link copied to clipboard
inline fun <E : Enum<E>> TomlLiteral.toEnumOrNull(serializersModule: SerializersModule = EmptySerializersModule()): E?

Returns content as enum with given enum class context only if content suits in, otherwise null.

Link copied to clipboard

Returns content as float.

Link copied to clipboard

Returns content as float only if content can be an exact float or inf/-inf/nan, otherwise null.

Link copied to clipboard

Returns content as int.

Link copied to clipboard

Returns content as int only if content can be int, otherwise null.

Link copied to clipboard

Returns content as long.

Link copied to clipboard

Returns content as long only if content can be long, otherwise null.

Link copied to clipboard
inline fun Toml(from: Toml = Toml, config: TomlConfigBuilder.() -> Unit): Toml

Factory function for creating custom instance of Toml.

Link copied to clipboard
fun TomlArray(value: Iterable<*>): TomlArray

Creates TomlArray from the given iterable value.

Link copied to clipboard

Creates TomlLiteral from the given boolean value.

Creates TomlLiteral from the given char value.

Creates TomlLiteral from the given numeric value.

Creates TomlLiteral from the given string value.

inline fun <E : Enum<E>> TomlLiteral(value: E, serializersModule: SerializersModule = EmptySerializersModule()): TomlLiteral

Creates TomlLiteral from the given enum value. Delegates to creator function which consumes string.

Link copied to clipboard
fun TomlTable(value: Map<*, *>): TomlTable

Creates TomlTable from the given map value.

Link copied to clipboard

Returns content as short.

Link copied to clipboard

Returns content as short only if content can be short, otherwise null.

Link copied to clipboard

Convert this to TomlArray.

Link copied to clipboard

Convert this to TomlLiteral.

Link copied to clipboard

Convert this to TomlNull.

Link copied to clipboard

Convert this to TomlTable.