Loading...
Searching...
No Matches
csv.c File Reference
`#include "arc/std/parser/csv.h"`
`#include "arc/std/parser/helpers.h"`
`#include "arc/std/bool.h"`
`#include "arc/std/parser.h"`
`#include <stddef.h>`
`#include <stdint.h>`
`#include <stdlib.h>`

Go to the source code of this file.

## Data Structures

struct | ARC_ParserCSVUserData

## Typedefs

typedef struct ARC_ParserCSVUserData | ARC_ParserCSVUserData

## Functions

void | ARC_ParserCSV_InitLexerRulesFn (ARC_Lexer *lexer)
uint32_t | ARC_ParserCSV_GetStringIdFn (ARC_String *string)
void | ARC_ParserCSVData_VectorDestroyVectorFn (void *data)
void | ARC_ParserCSVData_GetDataTag (ARC_Vector *dataVector, ARC_ParserTagToken *tagToken, ARC_ParserCSVUserData *userData)
void | ARC_ParserCSVData_RunLineTag (ARC_Vector *dataVector, ARC_ParserTagToken *tagToken, ARC_ParserCSVUserData *userData)
void | ARC_ParserCSVData_CreateFn (void **data, ARC_ParserTagToken *parsedData, void *userData)
void | ARC_ParserCSVData_DestroyFn (void *data, ARC_Bool clear, void *userData)
void | ARC_ParserCSV_CreateAsParser (ARC_Parser **parser, ARC_Bool header, ARC_ParserCSV_CastTypeFn castTypeFn, ARC_ParserCSV_DestroyTypeFn destroyTypeFn)
| creates a parser for the Parser Lang

## Typedef Documentation

## ARC_ParserCSVUserData

typedef struct ARC_ParserCSVUserData ARC_ParserCSVUserData

## Function Documentation

## ARC_ParserCSV_CreateAsParser()

void ARC_ParserCSV_CreateAsParser | ( | ARC_Parser ** | parser,
|  | ARC_Bool | header,
|  | ARC_ParserCSV_CastTypeFn | castTypeFn,
|  | ARC_ParserCSV_DestroyTypeFn | destroyTypeFn )

creates a parser for the Parser Lang

Note
  the rules will be inited for the parser lang
  the parsed data will be saved as a vector of ARC_ParserLanguageTag

Parameters

  [out] | parser | the parser to create

Definition at line 302 of file csv.c.

{
/* ~ define the language as a string ~ */
char *languageCString =
"<line> -> <data> NEWLINE <line> | <data> | NEWLINE <line> | LAMBDA\n"
"<data> -> <string> COMMA <data> | <string>\n"
"<string> -> <nonCommaChar> <string> | <nonCommaChar>\n"
"<nonCommaChar> -> CHAR_BEFORE_COMMA | CHAR_AFTER_COMMA\n";
ARC_String *languageString;
ARC_String_CreateWithStrlen(&languageString, languageCString);
/* ~ init the userdata ~ */
ARC_ParserCSVUserData *userdata = (ARC_ParserCSVUserData *)malloc(sizeof(ARC_ParserCSVUserData));
userdata->header = header;
userdata->castTypeFn = castTypeFn;
userdata->destroyTypeFn = destroyTypeFn;
/* ~ create the language ~ */
ARC_ParserData_CreateFn createCharFn = ARC_ParserCSVData_CreateFn;
ARC_ParserData_DestroyFn destroyCharFn = ARC_ParserCSVData_DestroyFn;
ARC_Parser_CreateFromString(parser, languageString, ARC_ParserCSV_InitLexerRulesFn, ARC_ParserCSV_GetStringIdFn, &createCharFn, &destroyCharFn, userdata);
//cleanup
ARC_String_Destroy(languageString);
}
ARC_ParserCSV_InitLexerRulesFn
void ARC_ParserCSV_InitLexerRulesFn(ARC_Lexer *lexer)
Definition csv.c:15
ARC_ParserCSV_GetStringIdFn
uint32_t ARC_ParserCSV_GetStringIdFn(ARC_String *string)
Definition csv.c:24
ARC_ParserCSVData_CreateFn
void ARC_ParserCSVData_CreateFn(void **data, ARC_ParserTagToken *parsedData, void *userData)
Definition csv.c:157
ARC_ParserCSVData_DestroyFn
void ARC_ParserCSVData_DestroyFn(void *data, ARC_Bool clear, void *userData)
Definition csv.c:263
ARC_Parser_CreateFromString
void ARC_Parser_CreateFromString(ARC_Parser **parser, ARC_String *languageString, ARC_Parser_InitLexerRulesFn initLexerRulesFn, ARC_Parser_GetStringIdFn getStringIdFn, ARC_ParserData_CreateFn *createDataFn, ARC_ParserData_DestroyFn *destroyDataFn, void *userData)
creates an ARC_Parser type from a string
Definition parser.c:105
ARC_ParserData_CreateFn
void(* ARC_ParserData_CreateFn)(void **data, ARC_ParserTagToken *parsedData, void *userData)
TODO: write this.
Definition parser.h:57
ARC_ParserData_DestroyFn
void(* ARC_ParserData_DestroyFn)(void *data, ARC_Bool clear, void *userData)
TODO: write this.
Definition parser.h:62
ARC_String_CreateWithStrlen
void ARC_String_CreateWithStrlen(ARC_String **string, char *data)
creates ARC_String type with strinlen
Definition string.c:32
ARC_String_Destroy
void ARC_String_Destroy(ARC_String *string)
destroys ARC_String type
Definition string.c:52
ARC_ParserCSVUserData
Definition csv.c:9
ARC_ParserCSVUserData::castTypeFn
ARC_ParserCSV_CastTypeFn castTypeFn
Definition csv.c:11
ARC_ParserCSVUserData::header
ARC_Bool header
Definition csv.c:10
ARC_ParserCSVUserData::destroyTypeFn
ARC_ParserCSV_DestroyTypeFn destroyTypeFn
Definition csv.c:12
ARC_String
substring position within a string
Definition string.h:14

References ARC_Parser_CreateFromString(), ARC_ParserCSV_GetStringIdFn(), ARC_ParserCSV_InitLexerRulesFn(), ARC_ParserCSVData_CreateFn(), ARC_ParserCSVData_DestroyFn(), ARC_String_CreateWithStrlen(), ARC_String_Destroy(), ARC_ParserCSVUserData::castTypeFn, ARC_ParserCSVUserData::destroyTypeFn, and ARC_ParserCSVUserData::header.

## ARC_ParserCSV_GetStringIdFn()

uint32_t ARC_ParserCSV_GetStringIdFn | ( | ARC_String * | string | ) |

Definition at line 24 of file csv.c.

{
if(ARC_String_EqualsCStringWithStrlen(string, "LAMBDA")){
return ARC_PARSER_TAG_LAMBDA;
}
if(ARC_String_EqualsCStringWithStrlen(string, "COMMA")){
return ARC_PARSER_CSV_CHAR_COMMA;
}
if(ARC_String_EqualsCStringWithStrlen(string, "NEWLINE")){
return ARC_PARSER_CSV_CHAR_NEWLINE;
}
if(ARC_String_EqualsCStringWithStrlen(string, "CHAR_BEFORE_COMMA")){
return ARC_PARSER_CSV_CHAR_BEFORE_COMMA;
}
if(ARC_String_EqualsCStringWithStrlen(string, "CHAR_AFTER_COMMA")){
return ARC_PARSER_CSV_CHAR_AFTER_COMMA;
}
if(ARC_String_EqualsCStringWithStrlen(string, "<line>")){
return ARC_PARSER_CSV_LINE;
}
if(ARC_String_EqualsCStringWithStrlen(string, "<data>")){
return ARC_PARSER_CSV_DATA;
}
if(ARC_String_EqualsCStringWithStrlen(string, "<string>")){
return ARC_PARSER_CSV_STRING;
}
if(ARC_String_EqualsCStringWithStrlen(string, "<nonCommaChar>")){
return ARC_PARSER_CSV_NON_COMMA_CHAR;
}
return ~(uint32_t)0;
}
ARC_PARSER_CSV_CHAR_AFTER_COMMA
#define ARC_PARSER_CSV_CHAR_AFTER_COMMA
Definition csv.h:66
ARC_PARSER_CSV_CHAR_BEFORE_COMMA
#define ARC_PARSER_CSV_CHAR_BEFORE_COMMA
Definition csv.h:65
ARC_PARSER_CSV_CHAR_COMMA
#define ARC_PARSER_CSV_CHAR_COMMA
Definition csv.h:63
ARC_PARSER_CSV_DATA
#define ARC_PARSER_CSV_DATA
Definition csv.h:68
ARC_PARSER_CSV_STRING
#define ARC_PARSER_CSV_STRING
Definition csv.h:69
ARC_PARSER_CSV_LINE
#define ARC_PARSER_CSV_LINE
Definition csv.h:67
ARC_PARSER_CSV_CHAR_NEWLINE
#define ARC_PARSER_CSV_CHAR_NEWLINE
Definition csv.h:64
ARC_PARSER_CSV_NON_COMMA_CHAR
#define ARC_PARSER_CSV_NON_COMMA_CHAR
Definition csv.h:70
ARC_PARSER_TAG_LAMBDA
#define ARC_PARSER_TAG_LAMBDA
basic tag for letting the parser know it is ok to end
Definition parser.h:150
ARC_String_EqualsCStringWithStrlen
ARC_Bool ARC_String_EqualsCStringWithStrlen(ARC_String *string, const char *cstring)
check if ARC_String and cstring match
Definition string.c:171

References ARC_PARSER_CSV_CHAR_AFTER_COMMA, ARC_PARSER_CSV_CHAR_BEFORE_COMMA, ARC_PARSER_CSV_CHAR_COMMA, ARC_PARSER_CSV_CHAR_NEWLINE, ARC_PARSER_CSV_DATA, ARC_PARSER_CSV_LINE, ARC_PARSER_CSV_NON_COMMA_CHAR, ARC_PARSER_CSV_STRING, ARC_PARSER_TAG_LAMBDA, and ARC_String_EqualsCStringWithStrlen().

Referenced by ARC_ParserCSV_CreateAsParser().

## ARC_ParserCSV_InitLexerRulesFn()

void ARC_ParserCSV_InitLexerRulesFn | ( | ARC_Lexer * | lexer | ) |

Definition at line 15 of file csv.c.

{
ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharRule(ARC_PARSER_CSV_CHAR_COMMA , ',' ));
ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharRule(ARC_PARSER_CSV_CHAR_NEWLINE, '\n'));
//NOTE: used an ascii table to get these values
ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(ARC_PARSER_CSV_CHAR_BEFORE_COMMA, 0x21, 0x2b));
ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(ARC_PARSER_CSV_CHAR_AFTER_COMMA , 0x2d, 0x7e));
}
ARC_Lexer_RegisterTokenRule
void ARC_Lexer_RegisterTokenRule(ARC_Lexer *lexer, ARC_LexerTokenRule tokenRule)
adds a token rule to a lexer
Definition lexer.c:79
ARC_LexerTokenRule_CreateAndReturnMatchCharRule
ARC_LexerTokenRule ARC_LexerTokenRule_CreateAndReturnMatchCharRule(uint32_t id, char character)
creates a ARC_LexerTokenRule with a given id and character
Definition lexer.c:378
ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween
ARC_LexerTokenRule ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(uint32_t id, char start, char end)
creates a ARC_LexerTokenRule with a given id and character range
Definition lexer.c:400

References ARC_Lexer_RegisterTokenRule(), ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(), ARC_LexerTokenRule_CreateAndReturnMatchCharRule(), ARC_PARSER_CSV_CHAR_AFTER_COMMA, ARC_PARSER_CSV_CHAR_BEFORE_COMMA, ARC_PARSER_CSV_CHAR_COMMA, and ARC_PARSER_CSV_CHAR_NEWLINE.

Referenced by ARC_ParserCSV_CreateAsParser().

## ARC_ParserCSVData_CreateFn()

void ARC_ParserCSVData_CreateFn | ( | void ** | data,
|  | ARC_ParserTagToken * | parsedData,
|  | void * | userData )

Definition at line 157 of file csv.c.

{
*data = NULL;
if(data == NULL || userData == NULL){
//TODO: error here?
*data = NULL;
return;
}
//cast the csv data back to its original type
ARC_ParserCSVUserData *csvUserData = (ARC_ParserCSVUserData *)userData;
//crate a vector for the data to be stored in before being copied to a 2d array
ARC_Vector *dataVector;
ARC_Vector_DestroyDataFn destroyVectorFn = ARC_ParserCSVData_VectorDestroyVectorFn;
ARC_Vector_Create(&dataVector, NULL, &destroyVectorFn);
//create the first row vector, does not need a destroy function as its contents will be moved
ARC_Vector *dataRowVector;
ARC_Vector_Create(&dataRowVector, NULL, NULL);
//add the row to the dataVector
ARC_Vector_Add(dataVector, (void *)dataRowVector);
//recursively add data from the parsedData to the data vector
ARC_ParserCSVData_RunLineTag(dataVector, parsedData, csvUserData);
//get the first line to check if it has any values
dataRowVector = ARC_Vector_Get(dataVector, 0);
if(ARC_Vector_GetSize(dataRowVector) == 0){
//TODO: iterate and clear the vector
ARC_Vector_Destroy(dataVector);
return;
}
//create the data that will be saved
ARC_ParserCSVData *csvData = (ARC_ParserCSVData *)malloc(sizeof(ARC_ParserCSVData));
csvData->hasHeader = csvUserData->header;
csvData->headers = NULL;
csvData->height = 0;
csvData->width = ARC_Vector_GetSize(dataRowVector);
csvData->data = NULL;
//create the starting index (to offset the header if it exists)
uint32_t heightStartIndex = 0;
//store the headers if they exist
if(csvData->hasHeader == ARC_True){
heightStartIndex++;
//copy the headers
csvData->headers = (ARC_String **)malloc(sizeof(ARC_String *) * csvData->width);
for(uint32_t headerIndex = 0; headerIndex < csvData->width; headerIndex++){
csvData->headers[headerIndex] = (ARC_String *)ARC_Vector_Get(dataRowVector, headerIndex);
}
}
//check that all the rows are the same size
for(uint32_t rowIndex = heightStartIndex; rowIndex < ARC_Vector_GetSize(dataVector); rowIndex++){
ARC_Vector *currentRowVector = (ARC_Vector *)ARC_Vector_Get(dataVector, rowIndex);
//skip an empty line (this should only be the case for the last line)
uint32_t currentRowVectorSize = ARC_Vector_GetSize(currentRowVector);
if(currentRowVectorSize == 0){
continue;
}
//a row was found so update the height
csvData->height++;
//TODO: probs want to error
//cleanup and exit if they don't match
if(csvData->width != currentRowVectorSize){
//TODO: iterate and clear the vector
ARC_Vector_Destroy(dataVector);
return;
}
}
//init location to copy data to
csvData->data = (void ***)malloc(sizeof(void **) * csvData->height);
//copy the data
uint32_t rowIndex = 0;
for(uint32_t y = 0; y < csvData->height; y++, rowIndex++){
ARC_Vector *currentRowVector = (ARC_Vector *)ARC_Vector_Get(dataVector, rowIndex + heightStartIndex);
//skip an empty line (should only be the case for the last line)
uint32_t currentRowVectorSize = ARC_Vector_GetSize(currentRowVector);
if(currentRowVectorSize == 0){
y--;
continue;
}
//create the current row
csvData->data[y] = (void **)malloc(sizeof(void *) * csvData->width);
for(uint32_t x = 0; x < csvData->width; x++){
csvData->data[y][x] = ARC_Vector_Get(currentRowVector, x);
}
}
ARC_Vector_Destroy(dataVector);
*data = (void *)csvData;
}
ARC_True
#define ARC_True
Definition bool.h:11
ARC_ParserCSVData_VectorDestroyVectorFn
void ARC_ParserCSVData_VectorDestroyVectorFn(void *data)
Definition csv.c:64
ARC_ParserCSVData_RunLineTag
void ARC_ParserCSVData_RunLineTag(ARC_Vector *dataVector, ARC_ParserTagToken *tagToken, ARC_ParserCSVUserData *userData)
Definition csv.c:118
ARC_ParserCSVData
defines a csv data type, data is set by the callback passed in when createing a parserCSV as parser
Definition csv.h:44
ARC_ParserCSVData::height
uint32_t height
Definition csv.h:49
ARC_ParserCSVData::width
uint32_t width
Definition csv.h:48
ARC_ParserCSVData::data
void *** data
Definition csv.h:50
ARC_ParserCSVData::headers
ARC_String ** headers
Definition csv.h:46
ARC_ParserCSVData::hasHeader
ARC_Bool hasHeader
Definition csv.h:45
ARC_Vector
Definition vector.c:9
ARC_Vector_DestroyDataFn
void(* ARC_Vector_DestroyDataFn)(void *data)
a callback that cleans up memory when it is removed from the vector
Definition vector.h:31
ARC_Vector_GetSize
uint32_t ARC_Vector_GetSize(ARC_Vector *vector)
gets the current size of an ARC_Vector as an unsigned 32 bit integer
Definition vector.c:146
ARC_Vector_Get
void * ARC_Vector_Get(ARC_Vector *vector, uint32_t index)
gets an item from an ARC_Vector at a position index
Definition vector.c:150
ARC_Vector_Add
void ARC_Vector_Add(ARC_Vector *vector, void *data)
adds an item to an ARC_Vector
Definition vector.c:67
ARC_Vector_Destroy
void ARC_Vector_Destroy(ARC_Vector *vector)
destroys an ARC_Vector
Definition vector.c:51
ARC_Vector_Create
void ARC_Vector_Create(ARC_Vector **vector, ARC_Vector_CompareDataFn *compareDataFn, ARC_Vector_DestroyDataFn *destroyDataFn)
creates an ARC_Vector which is an "expandable" array
Definition vector.c:28

References ARC_ParserCSVData_RunLineTag(), ARC_ParserCSVData_VectorDestroyVectorFn(), ARC_True, ARC_Vector_Add(), ARC_Vector_Create(), ARC_Vector_Destroy(), ARC_Vector_Get(), ARC_Vector_GetSize(), ARC_ParserCSVData::data, ARC_ParserCSVData::hasHeader, ARC_ParserCSVUserData::header, ARC_ParserCSVData::headers, ARC_ParserCSVData::height, and ARC_ParserCSVData::width.

Referenced by ARC_ParserCSV_CreateAsParser().

## ARC_ParserCSVData_DestroyFn()

void ARC_ParserCSVData_DestroyFn | ( | void * | data,
|  | ARC_Bool | clear,
|  | void * | userData )

Definition at line 263 of file csv.c.

{
if(userData == NULL){
return;
}
ARC_ParserCSVUserData *csvUserData = (ARC_ParserCSVUserData *)userData;
if(data != NULL){
ARC_ParserCSVData *csvData = (ARC_ParserCSVData *)data;
//cleanup the headers if they exist
if(csvData->hasHeader == ARC_True){
for(uint32_t x = 0; x < csvData->width; x++){
ARC_String *string = csvData->headers[x];
ARC_String_Destroy(string);
}
free(csvData->headers);
}
for(uint32_t y = 0; y < csvData->height; y++){
//cleanup each element in the data
for(uint32_t x = 0; x < csvData->width; x++){
csvUserData->destroyTypeFn(csvData->data[y][x]);
}
//cleanup each row of data
free(csvData->data[y]);
}
//cleanup the data
free(csvData->data);
free(csvData);
}
if(clear == ARC_False){
free(csvUserData);
}
}
ARC_False
#define ARC_False
Definition bool.h:12

References ARC_False, ARC_String_Destroy(), ARC_True, ARC_ParserCSVData::data, ARC_ParserCSVUserData::destroyTypeFn, ARC_ParserCSVData::hasHeader, ARC_ParserCSVData::headers, ARC_ParserCSVData::height, and ARC_ParserCSVData::width.

Referenced by ARC_ParserCSV_CreateAsParser().

## ARC_ParserCSVData_GetDataTag()

void ARC_ParserCSVData_GetDataTag | ( | ARC_Vector * | dataVector,
|  | ARC_ParserTagToken * | tagToken,
|  | ARC_ParserCSVUserData * | userData )

Definition at line 69 of file csv.c.

{
//cast the csv data back to its original type
ARC_ParserCSVUserData *csvUserData = (ARC_ParserCSVUserData *)userData;
//loop through the tags either recursing to next body or adding data to vector
for(uint32_t index = 0; index < ARC_Vector_GetSize(tagToken->tagTokens); index++){
ARC_ParserTagToken *childTagToken = (ARC_ParserTagToken *)ARC_Vector_Get(tagToken->tagTokens, index);
ARC_String *stringData = NULL;
ARC_Vector *row = NULL;
uint32_t rowIndex = 0;
switch(childTagToken->id){
//recuse to run the next line
case ARC_PARSER_CSV_STRING:
//get the string of the data
ARC_String_Create(&stringData, NULL, 0);
ARC_ParserData_HelperRecurseStringAdd(&stringData, childTagToken);
//move data string and cleanup
void *data = (void *)stringData;
//get the last row vector
rowIndex = ARC_Vector_GetSize(dataVector) - 1;
row = (ARC_Vector *)ARC_Vector_Get(dataVector, rowIndex);
//only call the userData cast type callback if it is not a header
if(rowIndex != 0 || csvUserData->header == ARC_False){
data = NULL;
userData->castTypeFn(&data, stringData);
ARC_String_Destroy(stringData);
}
//add the data to the row vector
ARC_Vector_Add(row, data);
continue;
case ARC_PARSER_CSV_DATA:
ARC_ParserCSVData_GetDataTag(dataVector, childTagToken, userData);
continue;
default:
//this should only be the case for the comma
continue;
}
}
}
ARC_ParserCSVData_GetDataTag
void ARC_ParserCSVData_GetDataTag(ARC_Vector *dataVector, ARC_ParserTagToken *tagToken, ARC_ParserCSVUserData *userData)
Definition csv.c:69
ARC_ParserData_HelperRecurseStringAdd
void ARC_ParserData_HelperRecurseStringAdd(ARC_String **data, ARC_ParserTagToken *tagToken)
recurses through a tag token adding token strings to a main string
Definition helpers.c:4
ARC_String_Create
void ARC_String_Create(ARC_String **string, char *data, uint64_t length)
creates ARC_String type
Definition string.c:9
ARC_ParserTagToken
a parser type used inside of the parser data create function
Definition parser.h:35
ARC_ParserTagToken::id
uint32_t id
Definition parser.h:36
ARC_ParserTagToken::tagTokens
ARC_Vector * tagTokens
Definition parser.h:39

References ARC_False, ARC_PARSER_CSV_DATA, ARC_PARSER_CSV_STRING, ARC_ParserCSVData_GetDataTag(), ARC_ParserData_HelperRecurseStringAdd(), ARC_String_Create(), ARC_String_Destroy(), ARC_Vector_Add(), ARC_Vector_Get(), ARC_Vector_GetSize(), ARC_ParserCSVUserData::castTypeFn, ARC_ParserCSVUserData::header, ARC_ParserTagToken::id, and ARC_ParserTagToken::tagTokens.

Referenced by ARC_ParserCSVData_GetDataTag(), and ARC_ParserCSVData_RunLineTag().

## ARC_ParserCSVData_RunLineTag()

void ARC_ParserCSVData_RunLineTag | ( | ARC_Vector * | dataVector,
|  | ARC_ParserTagToken * | tagToken,
|  | ARC_ParserCSVUserData * | userData )

Definition at line 118 of file csv.c.

{
//loop through the tags either going to the next line or the next body
for(uint32_t index = 0; index < ARC_Vector_GetSize(tagToken->tagTokens); index++){
ARC_ParserTagToken *childTagToken = (ARC_ParserTagToken *)ARC_Vector_Get(tagToken->tagTokens, index);
ARC_Vector *row = NULL;
uint32_t rowIndex = 0;
switch(childTagToken->id){
//recuse to run the next line
case ARC_PARSER_CSV_LINE:
ARC_ParserCSVData_RunLineTag(dataVector, childTagToken, userData);
continue;
//get the row data
case ARC_PARSER_CSV_DATA:
ARC_ParserCSVData_GetDataTag(dataVector, childTagToken, userData);
continue;
//add a new row for each new line
case ARC_PARSER_CSV_CHAR_NEWLINE:
//check if current is not empty (no need to create another empty row)
rowIndex = ARC_Vector_GetSize(dataVector) - 1;
row = (ARC_Vector *)ARC_Vector_Get(dataVector, rowIndex);
if(ARC_Vector_GetSize(row) == 0){
continue;
}
//create and add a new row
ARC_Vector_Create(&row, NULL, NULL);
ARC_Vector_Add(dataVector, (void *)row);
continue;
default:
continue;
}
}
}

References ARC_PARSER_CSV_CHAR_NEWLINE, ARC_PARSER_CSV_DATA, ARC_PARSER_CSV_LINE, ARC_ParserCSVData_GetDataTag(), ARC_ParserCSVData_RunLineTag(), ARC_Vector_Add(), ARC_Vector_Create(), ARC_Vector_Get(), ARC_Vector_GetSize(), ARC_ParserTagToken::id, and ARC_ParserTagToken::tagTokens.

Referenced by ARC_ParserCSVData_CreateFn(), and ARC_ParserCSVData_RunLineTag().

## ARC_ParserCSVData_VectorDestroyVectorFn()

void ARC_ParserCSVData_VectorDestroyVectorFn | ( | void * | data | ) |

Definition at line 64 of file csv.c.

{
ARC_Vector *vector = (ARC_Vector *)data;
ARC_Vector_Destroy(vector);
}

References ARC_Vector_Destroy().

Referenced by ARC_ParserCSVData_CreateFn().