diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deserializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deserializer.kt new file mode 100644 index 000000000..aa39bccdb --- /dev/null +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deserializer.kt @@ -0,0 +1,12 @@ +package it.unibo.tuprolog.serialize + +import kotlin.js.JsName + +interface Deserializer { + @JsName("mimeType") + val mimeType: MimeType + @JsName("deserialize") + fun deserialize(string: String): T + @JsName("reconstruct") + fun reconstruct(`object`: Any): T +} \ No newline at end of file diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/MimeType.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/MimeType.kt new file mode 100644 index 000000000..376197ca5 --- /dev/null +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/MimeType.kt @@ -0,0 +1,11 @@ +package it.unibo.tuprolog.serialize + +sealed class MimeType(val type: String, val subType: String) { + + object Json : MimeType("application", "json") + + object Yaml : MimeType("application", "yaml") + + object Xml : MimeType("application", "xml") + +} \ No newline at end of file diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationException.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationException.kt new file mode 100644 index 000000000..91a084c17 --- /dev/null +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationException.kt @@ -0,0 +1,6 @@ +package it.unibo.tuprolog.serialize + +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.exception.TuPrologException + +class SerializationException(term: Term) : TuPrologException("Error while serialising $term") \ No newline at end of file diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt new file mode 100644 index 000000000..6bf85d9d7 --- /dev/null +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt @@ -0,0 +1,8 @@ +@file:JvmName("SerializationUtils") +package it.unibo.tuprolog.serialize + +import kotlin.jvm.JvmName + +expect fun termSerializer(mimeType: MimeType): TermSerializer + +expect fun termDeserializer(mimeType: MimeType): TermDeserializer \ No newline at end of file diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Serializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Serializer.kt new file mode 100644 index 000000000..c04b66240 --- /dev/null +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Serializer.kt @@ -0,0 +1,12 @@ +package it.unibo.tuprolog.serialize + +import kotlin.js.JsName + +interface Serializer { + @JsName("mimeType") + val mimeType: MimeType + @JsName("serialize") + fun serialize(value: T): String + @JsName("objectify") + fun objectify(value: T): Any +} \ No newline at end of file diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeserializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeserializer.kt new file mode 100644 index 000000000..c1e407ced --- /dev/null +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeserializer.kt @@ -0,0 +1,15 @@ +package it.unibo.tuprolog.serialize + +import it.unibo.tuprolog.core.Term +import kotlin.js.JsName +import kotlin.jvm.JvmStatic + +interface TermDeserializer : Deserializer { + companion object { + @JvmStatic + @JsName("of") + fun of(mimeType: MimeType): TermDeserializer { + return termDeserializer(mimeType) + } + } +} \ No newline at end of file diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerializer.kt new file mode 100644 index 000000000..bfd6f4c88 --- /dev/null +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerializer.kt @@ -0,0 +1,15 @@ +package it.unibo.tuprolog.serialize + +import it.unibo.tuprolog.core.Term +import kotlin.jvm.JvmStatic + +interface TermSerializer : Serializer { + + companion object { + @JvmStatic + fun of(mimeType: MimeType): TermSerializer { + return termSerializer(mimeType) + } + } + +} \ No newline at end of file diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt new file mode 100644 index 000000000..e9bc43a3f --- /dev/null +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt @@ -0,0 +1,9 @@ +package it.unibo.tuprolog.serialize + +actual fun termSerializer(mimeType: MimeType): TermSerializer { + TODO("Not yet implemented") +} + +actual fun termDeserializer(mimeType: MimeType): TermDeserializer { + TODO("Not yet implemented") +} \ No newline at end of file diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt new file mode 100644 index 000000000..d9d095247 --- /dev/null +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/SerializationUtils.kt @@ -0,0 +1,9 @@ +package it.unibo.tuprolog.serialize + +actual fun termDeserializer(mimeType: MimeType): TermDeserializer { + TODO("Not yet implemented") +} + +actual fun termSerializer(mimeType: MimeType): TermSerializer { + TODO("Not yet implemented") +} \ No newline at end of file