mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Updated stream API.
This commit is contained in:
committed by
Christoffer Lerno
parent
a6cff5c2a5
commit
9a6d83f526
@@ -3,17 +3,11 @@ import std::io;
|
||||
|
||||
struct CsvReader
|
||||
{
|
||||
Stream stream;
|
||||
Stream* stream;
|
||||
String separator;
|
||||
}
|
||||
|
||||
fn void CsvReader.init_file(&self, File* file, String separator = ",")
|
||||
{
|
||||
self.stream = file.as_stream();
|
||||
self.separator = separator;
|
||||
}
|
||||
|
||||
fn void CsvReader.init(&self, Stream stream, String separator = ",")
|
||||
fn void CsvReader.init(&self, Stream* stream, String separator = ",")
|
||||
{
|
||||
self.stream = stream;
|
||||
self.separator = separator;
|
||||
@@ -42,7 +36,7 @@ fn void! CsvReader.skip_row(self) @maydiscard
|
||||
|
||||
macro CsvReader.@each_row(self, int rows = int.max; @body(String[] row))
|
||||
{
|
||||
Stream stream = self.stream;
|
||||
Stream* stream = self.stream;
|
||||
String sep = self.separator;
|
||||
while (rows--)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ fault JsonParsingError
|
||||
INVALID_NUMBER,
|
||||
}
|
||||
|
||||
fn Object*! parse(Stream s, Allocator* using = mem::heap())
|
||||
fn Object*! parse(Stream* s, Allocator* using = mem::heap())
|
||||
{
|
||||
JsonContext context = { .last_string = dstring::new_with_capacity(64, using), .stream = s, .allocator = using };
|
||||
defer context.last_string.free();
|
||||
@@ -44,7 +44,7 @@ enum JsonTokenType @local
|
||||
struct JsonContext @local
|
||||
{
|
||||
uint line;
|
||||
Stream stream;
|
||||
Stream* stream;
|
||||
Allocator* allocator;
|
||||
JsonTokenType token;
|
||||
DString last_string;
|
||||
|
||||
Reference in New Issue
Block a user