#ifndef RT_CONFIG_H
#define RT_CONFIG_H

#include "runtime.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    RT_CVAR_TYPE_INT,
    RT_CVAR_TYPE_FLOAT,
    RT_CVAR_TYPE_STRING,
    RT_CVAR_TYPE_SIZE,
} rt_cvar_type;

typedef struct {
    const char *name;
    const char *description;
    union {
        int i;
        float f;
        const char *s;
        size_t sz;
    };
    rt_cvar_type type;
} rt_cvar;

/* n variable name, d description string, v default value*/
#define RT_CVAR_I(n, d, v)                                                                         \
    rt_cvar n = {.name = #n, .description = d, .i = (v), .type = RT_CVAR_TYPE_INT}
#define RT_CVAR_F(n, d, v)                                                                         \
    rt_cvar n = {.name = #n, .description = d, .f = (v), .type = RT_CVAR_TYPE_FLOAT}
#define RT_CVAR_S(n, d, v)                                                                         \
    rt_cvar n = {.name = #n, .description = d, .s = (v), .type = RT_CVAR_TYPE_STRING}
#define RT_CVAR_SZ(n, d, v)                                                                        \
    rt_cvar n = {.name = #n, .description = d, .sz = (v), .type = RT_CVAR_TYPE_SIZE}

RT_DLLEXPORT void rtRegisterCVAR(rt_cvar *cvar);

RT_DLLEXPORT rt_cvar *rtGetCVAR(const char *name);

#ifdef __cplusplus
}
#endif

#endif