Basic datatypes

This commit is contained in:
maelstrom 2024-11-22 18:27:34 +01:00
parent cd906be4c9
commit 29c85b58c7
3 changed files with 45 additions and 0 deletions

10
src/datatype.h Normal file
View file

@ -0,0 +1,10 @@
#pragma once
#include <variant>
#include "datatypes/primitives.h"
typedef std::variant<StringData, IntData, FloatData> DataValue;
const uint DAT_STRING = 0;
const uint DAT_INT = 1;
const uint DAT_FLOAT = 2;

View file

@ -0,0 +1,11 @@
#include "primitives.h"
StringData::StringData(std::string str) : wrapped(str) {}
StringData::operator std::string() { return wrapped; }
IntData::IntData(int in) : wrapped(in) {}
IntData::operator int() { return wrapped; }
FloatData::FloatData(float in) : wrapped(in) {}
FloatData::operator float() { return wrapped; }

View file

@ -0,0 +1,24 @@
#pragma once
#include <string>
class StringData {
std::string wrapped;
public:
StringData(std::string);
operator std::string();
};
class IntData {
int wrapped;
public:
IntData(int);
operator int();
};
class FloatData {
float wrapped;
public:
FloatData(float);
operator float();
};