Loading...
Searching...
No Matches
helpers.c File Reference
`#include "arc/std/parser/helpers.h"`
`#include "arc/std/errno.h"`

Go to the source code of this file.

## Functions

void | ARC_ParserData_HelperRecurseStringAdd (ARC_String **data, ARC_ParserTagToken *tagToken)
| recurses through a tag token adding token strings to a main string

## Function Documentation

## 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

Note
  the string needs to be created otherwise this will break
  this will only add tokens that have data

Parameters

  | [in/out] | data
  [in] | tagToken | the tag token to recurse through

Definition at line 4 of file helpers.c.

{
if(*data == NULL){
arc_errno = ARC_ERRNO_NULL;
ARC_DEBUG_LOG_ERROR("ARC_ParserData_RecurseStringAdd(data, tagToken), string data was NULL");
return;
}
//only adds tokens with data (check the header for more information)
if(tagToken->token != NULL && tagToken->token->data != NULL){
ARC_String_Append(data, tagToken->token->data);
return;
}
//TODO: probs don't need this
if(tagToken->tagTokens == NULL){
return;
}
//recurse through all the tag tokens
for(uint32_t index = 0; index < ARC_Vector_GetSize(tagToken->tagTokens); index++){
ARC_ParserData_HelperRecurseStringAdd(data, (ARC_ParserTagToken *)ARC_Vector_Get(tagToken->tagTokens, index));
}
}
arc_errno
int32_t arc_errno
Definition errno.c:5
ARC_ERRNO_NULL
#define ARC_ERRNO_NULL
Definition errno.h:6
ARC_DEBUG_LOG_ERROR
#define ARC_DEBUG_LOG_ERROR(STR)
Definition errno.h:39
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_Append
void ARC_String_Append(ARC_String **string, ARC_String *append)
appends to an ARC_String with an ARC_String
Definition string.c:126
ARC_LexerToken::data
ARC_String * data
Definition lexer.h:20
ARC_ParserTagToken
a parser type used inside of the parser data create function
Definition parser.h:35
ARC_ParserTagToken::token
ARC_LexerToken * token
Definition parser.h:38
ARC_ParserTagToken::tagTokens
ARC_Vector * tagTokens
Definition parser.h:39
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:149
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:153

References ARC_DEBUG_LOG_ERROR, arc_errno, ARC_ERRNO_NULL, ARC_ParserData_HelperRecurseStringAdd(), ARC_String_Append(), ARC_Vector_Get(), ARC_Vector_GetSize(), ARC_LexerToken::data, ARC_ParserTagToken::tagTokens, and ARC_ParserTagToken::token.

Referenced by ARC_ParserCSVData_GetDataTag(), ARC_ParserData_HelperRecurseStringAdd(), and TEST_ParserData_CreateStringFn().