#include "arc/std/parser/helpers.h"
#include "arc/std/errno.h"

void ARC_ParserData_HelperRecurseStringAdd(ARC_String **data, ARC_ParserTagToken *tagToken){
    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));
    }
}
