summaryrefslogtreecommitdiff
path: root/include/qntan/Qntan.h
diff options
context:
space:
mode:
authorAndreas Fankhauser hiddenalpha.ch2026-05-14 21:43:01 +0200
committerAndreas Fankhauser hiddenalpha.ch2026-05-14 21:43:01 +0200
commitecef395c137234f4ab71576450ddcdd15f64374f (patch)
tree5541925334c265489e40e2619c8ebbc06be0bf6d /include/qntan/Qntan.h
parent3add52878dfec4b592de09ee5bbb97a504ee0c7f (diff)
downloadQntan-ecef395c137234f4ab71576450ddcdd15f64374f.tar.gz
Qntan-ecef395c137234f4ab71576450ddcdd15f64374f.zip
Introduce CsvEnc
- Introduce `CsvEnc`. - Make `JsonDec.onJsonDocEnd()` async via callback.
Diffstat (limited to 'include/qntan/Qntan.h')
-rw-r--r--include/qntan/Qntan.h49
1 files changed, 48 insertions, 1 deletions
diff --git a/include/qntan/Qntan.h b/include/qntan/Qntan.h
index abe125b..cf66db3 100644
--- a/include/qntan/Qntan.h
+++ b/include/qntan/Qntan.h
@@ -79,6 +79,7 @@ struct Qntan_CsvDec;
struct Qntan_CsvDec_Mentor;
struct Qntan_CsvIStream;
struct Qntan_CsvIStream_Mentor;
+struct Qntan_CsvEnc;
struct Qntan_JsonEnc;
struct Qntan_JsonDec;
struct Qntan_JsonDec_Mentor;
@@ -1203,6 +1204,52 @@ struct Qntan_CsvIStream_Mentor {
+#ifndef Qntan_CsvEnc_appendCellChunk
+# define Qntan_CsvEnc_appendCellChunk(A, B, C, D, E, F) (*A)->appendCellChunk(A, B, C, D, E, F)
+#endif
+#ifndef Qntan_CsvEnc_appendRowsStrz
+# define Qntan_CsvEnc_appendRowsStrz(A, B, C, D) (*A)->appendRowsStrz(A, B, C, D)
+#endif
+#ifndef Qntan_CsvEnc_beginNextRow
+# define Qntan_CsvEnc_beginNextRow(A, B, C) (*A)->beginNextRow(A, B, C)
+#endif
+
+struct Qntan_CsvEnc {
+ /* WARN: pre-alpha! Not usable yet.
+ */
+ void(*appendCellChunk)( struct Qntan_CsvEnc**, char const*buf, int buf_len, int flgs,
+ void(*onDone)(int,Qntan_Cls), Qntan_Cls );
+ /* `buf` the chars to append.
+ * `buf_len` Number of chars to use from `buf`.
+ * `flgs & 4` set means, that this is the last chunk for this cell. So
+ * later calls will append to the next cell.
+ * `flgs & 2` set means, that this row is now complete. So further calls
+ * will then continue constructing the next row.
+ * `flgs & 8` means end of document. This MUST be given at least once at
+ * the very end to ensure output is flushed correctly.
+ * `flgs & 0x10` means that this cell explicitly should be quoted, even when
+ * the contents itself would not require it.
+ * All other bits in `flgs` not mentioned here MUST be zero.
+ */
+ void(*appendRowsStrz)( struct Qntan_CsvEnc**, char***rows,
+ void(*onDone)(int err,Qntan_Cls), Qntan_Cls );
+ /* Appends a 2d array of zero terminated strings. This can be called
+ * multple times to append more rows.
+ * All of `rows`, `rows[x]` and `rows[x][y]` MUST be zero-terminated.
+ * `err` is zero on success. `err` is negative for errors.
+ * `onDone()` will be called as soon operation is done.
+ */
+};
+
+
+
+
+
+
+
+
+
+
struct Qntan_JsonEnc {
/**/
void (*reset)( struct Qntan_JsonEnc** );
@@ -1267,7 +1314,7 @@ struct Qntan_JsonDec_Mentor {
* prepared that the error may not be exactly at the pointed location, but
* somewhere near that location.
*/
- void (*onJsonDocEnd)( Qntan_Cls cls );
+ void (*onJsonDocEnd)( Qntan_Cls cls, void(*onDone)(int,Qntan_Cls), Qntan_Cls );
/**/
void (*onJsonObjBeg)( Qntan_Cls cls );
/**/