/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../libs.h" #include "asset.h" #define CSV_BUFFER_SIZE 128 #define CSV_BUFFER_ROW_SIZE 16 /** Result of a CSV buffer operation. */ typedef struct { /** How many rows within the CSV */ int32_t rowCount; /** Count of columns in the CSV, this is the longest row in the CSV. */ int32_t columnCount; /** How many cells within the CSV */ int32_t cellCount; } csvbufferresult_t; /** Callback to receive data for each cell in a CSV being buffered */ typedef void csvbuffercallback_t( assetbuffer_t *asset, void *user, int32_t row, int32_t column, char *data ); /** Callback to receive buffer data for a CSV row */ typedef void csvbufferrowcallback_t( assetbuffer_t *asset, void *user, int32_t row, char **columns, int32_t columnCount ); /** Data used by the cell callback for when the row buffering is progressing */ typedef struct { /** Which row the current buffer is on */ int32_t row; /** Count of columns (in the current row) */ int32_t columnCount; /** Array of characters for the row */ char rowData[CSV_BUFFER_ROW_SIZE * CSV_BUFFER_SIZE]; /** Pointers to the start of each string within the row */ char *columns[CSV_BUFFER_ROW_SIZE]; /** Pointer to custom user data */ void *user; /** Pointer to custom user callback */ csvbufferrowcallback_t *callback; } csvbufferrowdata_t;