-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tree refactoring and basic text writing #90
Changes from all commits
99c90dd
5c1c558
a3d3d1e
8962396
a4b78e9
c85313d
d795753
63300a5
be49283
8202750
b685378
0664aa0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
package com.akuleshov7.ktoml | ||
|
||
import com.akuleshov7.ktoml.KtomlConf.Indentation.FOUR_SPACES | ||
|
||
/** | ||
* @property ignoreUnknownNames - a control to allow/prohibit unknown names during the deserialization | ||
* @property emptyValuesAllowed - a control to allow/prohibit empty values: a = # comment | ||
* @property escapedQuotesInLiteralStringsAllowed - a control to allow/prohibit escaping of single quotes in literal strings | ||
* @property indentation | ||
*/ | ||
public data class KtomlConf( | ||
val ignoreUnknownNames: Boolean = false, | ||
val emptyValuesAllowed: Boolean = true, | ||
val escapedQuotesInLiteralStringsAllowed: Boolean = true | ||
) | ||
val escapedQuotesInLiteralStringsAllowed: Boolean = true, | ||
val indentation: Indentation = FOUR_SPACES, | ||
) { | ||
/** | ||
* @property value | ||
*/ | ||
public enum class Indentation(public val value: String) { | ||
FOUR_SPACES(" "), | ||
NONE(""), | ||
TAB("\t"), | ||
TWO_SPACES(" "), | ||
; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,16 @@ package com.akuleshov7.ktoml | |
import com.akuleshov7.ktoml.decoders.TomlMainDecoder | ||
import com.akuleshov7.ktoml.exceptions.MissingRequiredFieldException | ||
import com.akuleshov7.ktoml.parsers.TomlParser | ||
import com.akuleshov7.ktoml.parsers.node.TomlFile | ||
import com.akuleshov7.ktoml.tree.TomlFile | ||
import com.akuleshov7.ktoml.writers.TomlWriter | ||
|
||
import kotlin.native.concurrent.ThreadLocal | ||
import kotlinx.serialization.* | ||
|
||
import kotlinx.serialization.DeserializationStrategy | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.SerializationStrategy | ||
import kotlinx.serialization.StringFormat | ||
|
||
import kotlinx.serialization.modules.EmptySerializersModule | ||
import kotlinx.serialization.modules.SerializersModule | ||
|
||
|
@@ -22,8 +28,10 @@ public open class Toml( | |
private val config: KtomlConf = KtomlConf(), | ||
override val serializersModule: SerializersModule = EmptySerializersModule | ||
) : StringFormat { | ||
// parser is created once after the creation of the class, to reduce the number of created parsers for each toml | ||
// parser and writer are created once after the creation of the class, to reduce | ||
// the number of created parsers and writers for each toml | ||
public val tomlParser: TomlParser = TomlParser(config) | ||
public val tomlWriter: TomlWriter = TomlWriter(config) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add some comment to this writer for newbies? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Perhaps editing the comment above |
||
|
||
// ================== basic overrides =============== | ||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you plan to implement
encodeToString
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when an Encoder implementation is completed