#pragma once

#include <cstdio>
#include <common.h>
#include <vector>

inline vec2f parseVec2f(const char *str) noexcept
{
    vec2f result;
    if(sscanf(str, "%f%*[;,]%f", &result.x, &result.y) == 1) {
        result.y = result.x;
    }
    return result;
}

inline vec3f parseVec3f(const char *str) noexcept
{
    vec3f result;
    sscanf(str, "%f%*[;,]%f%*[;,]%f", &result.x, &result.y, &result.z);
    return result;
}

inline void parseVector(const char *str, std::vector<uint32_t> &data)
{
    if(!str) {
        return;
    }

    for (uint32_t i = 0; str[i]; i++) {
        if(str[i] == ';' || !i) {
            if(!i) {
                data.push_back(atoi(str));
            } else {
                data.push_back(atoi(&str[i+1]));
            }
        }
    }
}
