Name and serialization fix
This commit is contained in:
parent
d16d051a1c
commit
62916d0c67
@ -3,7 +3,7 @@ plugins {
|
||||
id("scientifik.publish") version "0.1.4" apply false
|
||||
}
|
||||
|
||||
val dataforgeVersion by extra("0.1.3")
|
||||
val dataforgeVersion by extra("0.1.4-dev-1")
|
||||
|
||||
val bintrayRepo by extra("dataforge")
|
||||
val githubProject by extra("dataforge-core")
|
||||
|
@ -4,6 +4,7 @@ import hep.dataforge.meta.Config
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.toConfig
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.NameToken
|
||||
import hep.dataforge.names.toName
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
@ -11,7 +12,7 @@ import kotlinx.serialization.json.JsonObjectSerializer
|
||||
|
||||
@Serializer(Name::class)
|
||||
object NameSerializer : KSerializer<Name> {
|
||||
override val descriptor: SerialDescriptor = StringDescriptor
|
||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("Name")
|
||||
|
||||
override fun deserialize(decoder: Decoder): Name {
|
||||
return decoder.decodeString().toName()
|
||||
@ -22,6 +23,9 @@ object NameSerializer : KSerializer<Name> {
|
||||
}
|
||||
}
|
||||
|
||||
@Serializer(NameToken::class)
|
||||
object NameTokenSerializer: KSerializer<NameToken>
|
||||
|
||||
/**
|
||||
* Serialized for meta
|
||||
*/
|
||||
|
@ -139,9 +139,7 @@ fun String.toName(): Name {
|
||||
* Convert the [String] to a [Name] by simply wrapping it in a single name token without parsing.
|
||||
* The input string could contain dots and braces, but they are just escaped, not parsed.
|
||||
*/
|
||||
fun String.asName(): Name {
|
||||
return NameToken(this).asName()
|
||||
}
|
||||
fun String.asName(): Name = if(isBlank()) EmptyName else NameToken(this).asName()
|
||||
|
||||
operator fun NameToken.plus(other: Name): Name = Name(listOf(this) + other.tokens)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user