Skip to content
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

133 #158

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

133 #158

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
java
kotlin("multiplatform") version "1.7.21"
kotlin("multiplatform") version "2.1.10"
id("org.jetbrains.dokka").version("1.7.20")
`maven-publish`
signing
Expand Down Expand Up @@ -38,12 +40,16 @@ kotlin {
artifact(dokkaJar)
}
}
js(BOTH) {
js(IR) {
browser {
}
nodejs {
}
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
}
sourceSets {
commonMain {}
commonTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.github.doyaaaaaken.kotlincsv.client

import com.github.doyaaaaaken.kotlincsv.dsl.context.CsvReaderContext
import com.github.doyaaaaaken.kotlincsv.dsl.context.ICsvReaderContext

/**
* Base implementation for a [CsvReader] that reads from Strings.
*
* @author doyaaaaaken
* @author gsteckman
*/
open class CsvStringReader(
private val ctx: CsvReaderContext
) : ICsvReaderContext by ctx {

/**
* read csv data as String, and convert into List<List<String>>
*/
fun readAll(data: String): List<List<String>> {
return CsvFileReader(ctx, StringReaderImpl(data), logger).readAllAsSequence().toList()
}

/**
* read csv data with header, and convert into List<Map<String, String>>
*/
fun readAllWithHeader(data: String): List<Map<String, String>> {
return CsvFileReader(ctx, StringReaderImpl(data), logger).readAllWithHeaderAsSequence().toList()
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
package com.github.doyaaaaaken.kotlincsv.client

import com.github.doyaaaaaken.kotlincsv.dsl.context.CsvReaderContext
import com.github.doyaaaaaken.kotlincsv.dsl.context.ICsvReaderContext

/**
* CSV Reader class
*
* @author doyaaaaaken
*/
actual class CsvReader actual constructor(
private val ctx: CsvReaderContext
) : ICsvReaderContext by ctx {

/**
* read csv data as String, and convert into List<List<String>>
*/
actual fun readAll(data: String): List<List<String>> {
return CsvFileReader(ctx, StringReaderImpl(data), logger).readAllAsSequence().toList()
}

/**
* read csv data with header, and convert into List<Map<String, String>>
*/
actual fun readAllWithHeader(data: String): List<Map<String, String>> {
return CsvFileReader(ctx, StringReaderImpl(data), logger).readAllWithHeaderAsSequence().toList()
}
}
ctx: CsvReaderContext
) : CsvStringReader(ctx)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.doyaaaaaken.kotlincsv.client

import com.github.doyaaaaaken.kotlincsv.dsl.context.CsvReaderContext

/**
* CSV Reader class
*
* @author doyaaaaaken
*/
actual class CsvReader actual constructor(
ctx: CsvReaderContext
) : CsvStringReader(ctx)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.doyaaaaaken.kotlincsv.client

import com.github.doyaaaaaken.kotlincsv.dsl.context.CsvWriterContext

/**
* CSV Writer class
*
* @author doyaaaaaken
*/
actual class CsvWriter actual constructor(ctx: CsvWriterContext) {

actual fun open(targetFileName: String, append: Boolean, write: ICsvFileWriter.() -> Unit) {
TODO("Not Implemented")
}

actual fun writeAll(rows: List<List<Any?>>, targetFileName: String, append: Boolean) {
TODO("Not Implemented")
}

actual suspend fun writeAllAsync(rows: List<List<Any?>>, targetFileName: String, append: Boolean) {
TODO("Not Implemented")
}

actual suspend fun openAsync(targetFileName: String, append: Boolean, write: suspend ICsvFileWriter.() -> Unit) {
TODO("Not Implemented")
}
}
Loading