-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Create ParseCommon for commonMain Parsing - Rename functions, so they're overloaded based on the arg type
- Loading branch information
Showing
12 changed files
with
93 additions
and
68 deletions.
There are no files selected for viewing
27 changes: 23 additions & 4 deletions
27
src/commonMain/kotlin/it/krzeminski/snakeyaml/engine/kmp/api/lowlevel/Parse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
package it.krzeminski.snakeyaml.engine.kmp.api.lowlevel | ||
|
||
import it.krzeminski.snakeyaml.engine.kmp.api.LoadSettings | ||
import it.krzeminski.snakeyaml.engine.kmp.events.Event | ||
import okio.Source | ||
|
||
expect class Parse( | ||
settings: LoadSettings | ||
) { | ||
expect class Parse { | ||
/** | ||
* Parse a YAML string and produce parsing events. | ||
* | ||
* See [Processing Overview](http://www.yaml.org/spec/1.2/spec.html.id2762107). | ||
* | ||
* @param string YAML document(s). The BOM must not be present (it will be parsed as content) | ||
* @return parsed events | ||
*/ | ||
fun parse(string: String): Iterable<Event> | ||
|
||
/** | ||
* Parse a YAML stream and produce parsing events. | ||
* | ||
* See [Processing Overview](http://www.yaml.org/spec/1.2/spec.html.id2762107). | ||
* | ||
* @param source YAML document(s). The BOM must not be present (it will be parsed as content) | ||
* @return parsed events | ||
*/ | ||
fun parse(source: Source): Iterable<Event> | ||
|
||
@Deprecated("renamed", ReplaceWith("parse(yaml)")) | ||
fun parseString(yaml: String): Iterable<Event> | ||
} |
21 changes: 21 additions & 0 deletions
21
src/commonMain/kotlin/it/krzeminski/snakeyaml/engine/kmp/api/lowlevel/ParseCommon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package it.krzeminski.snakeyaml.engine.kmp.api.lowlevel | ||
|
||
import it.krzeminski.snakeyaml.engine.kmp.api.LoadSettings | ||
import it.krzeminski.snakeyaml.engine.kmp.events.Event | ||
import it.krzeminski.snakeyaml.engine.kmp.parser.ParserImpl | ||
import it.krzeminski.snakeyaml.engine.kmp.scanner.StreamReader | ||
import okio.Buffer | ||
import okio.Source | ||
|
||
internal class ParseCommon ( | ||
private val settings: LoadSettings, | ||
) { | ||
fun parse(string: String): Iterable<Event> = | ||
parse(Buffer().writeUtf8(string)) | ||
|
||
fun parse(source: Source): Iterable<Event> = | ||
Iterable { | ||
val reader = StreamReader(stream = source, loadSettings = settings) | ||
ParserImpl(settings, reader) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters