// Copyright (c) 2021 Dominic Masters
// 
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

#pragma once
#include <dawn/dawn.h>
#include "array.h"

/**
 * Replaces handlebars within the string with items from the list of variables.
 * Output of replacement is stored in the buffer provided. Handlebars within the
 * string should be in the format of; "{{ key }}", spaces within the bars will
 * be skipped. Variable keys cannot exceed STRING_HANDLEBAR_KEY_MAXLENGTH in
 * length.
 * 
 * @param string String to parse.
 * @param variables Variables to use in the parsing.
 * @param variableCount How many variables in the array.
 * @param buffer Buffer to write characters in to.
 * @return The count of characters that were written to the buffer.
 */
int32_t stringHandlebarsBuffer(char *source,
  stringhandlebarvariable_t *variables, int32_t variableCount, char *buffer
);

/**
 * Initializes a string stack for pushing strings on to.
 * @param stack Stack to initialize.
 */
void stringStackInit(stringstack_t *stack);

/**
 * Push a string onto the stack. The source string will be copied so you can
 * change the original pointer after this push operation.
 * @param stack Stack to push onto.
 * @param string String to copy and push.
 */
void stringStackPush(stringstack_t *stack, char *string);

/**
 * Pop an element off the end of a string stack.
 * @param stack Stack to pop from.
 */
void stringStackPop(stringstack_t *stack);