ktoml icon indicating copy to clipboard operation
ktoml copied to clipboard

Source parser and stream utils

Open bishiboosh opened this issue 3 years ago • 3 comments

The main motivation for this PR is to replicate what's done in https://github.com/Kotlin/kotlinx.serialization/blob/master/formats/json/jvmMain/src/kotlinx/serialization/json/JvmStreams.kt, because I'm using ktoml currently in an Android app and using streams directly without copying them to memory first would be a huge advantage to me.

The modifications done to the lib are the following:

  • change parseStringsToTomlTree to use a sequence instead of a list.
  • add a ktoml-source module, that parses directly from an okio Source
  • use this module in ktoml-file, allowing to avoid copying the file to memory while parsing it
  • adding JVM-only methods allowing to parse InputStream

I realize that this introduces JVM-only code, so I could spin the stream-related methods into a new project if needs be.

bishiboosh avatar Feb 24 '22 10:02 bishiboosh

May be you can also add some small example to the readme? You have added new logic to the API, that can be useful for users.

I fixed diktat/detekt code style issues and fixed some small typos

orchestr7 avatar May 04 '22 13:05 orchestr7

@akuleshov7 I'll try to look at your comments today, but I may have to delay until next week, I'm a little bit swamped right now

bishiboosh avatar May 05 '22 06:05 bishiboosh

@bishiboosh, you have been waiting for a review for a half of a year (sorry), so I do not think it is a problem for me to wait several week😅

orchestr7 avatar May 05 '22 07:05 orchestr7

Only today I have noticed that this PR was opened in the same day when this awful war started exactly one year ago. A year has passed already and still it has not ended, oh :(

I have opened #188 to finalise this PR: we need also to think how to reduce the number of affected users of the library.

orchestr7 avatar Feb 23 '23 22:02 orchestr7

And finally, after more than a year, I have merged conflicts 🥳 @bishiboosh thank you for this PR and sorry, that it took so long

orchestr7 avatar Apr 21 '23 03:04 orchestr7