#include "Variant.h" using namespace osdev::components; Variant::Type Variant::getType() { if(std::holds_alternative(m_variable)) { return Variant::Type::Bool; } else if(std::holds_alternative(m_variable)) { return Variant::Type::Int; } else if(std::holds_alternative(m_variable)) { return Variant::Type::Double; } else if(std::holds_alternative(m_variable)) { return Variant::Type::Float; } else if(std::holds_alternative(m_variable)) { return Variant::Type::Char; } else if(std::holds_alternative(m_variable)) { return Variant::Type::String; } else if(std::holds_alternative(m_variable)) { return Variant::Type::UInt8; } else if(std::holds_alternative(m_variable)) { return Variant::Type::UInt16; } else if(std::holds_alternative(m_variable)) { return Variant::Type::UInt64; } return Variant::Type::Invalid; } bool Variant::CanConvert(Variant::Type typeWanted) { switch(typeWanted) { case Variant::Bool: { return std::holds_alternative(m_variable); } case Variant::Int: { return std::holds_alternative(m_variable); } case Variant::Double: { return std::holds_alternative(m_variable); } case Variant::Float: { return std::holds_alternative(m_variable); } case Variant::Char: { return std::holds_alternative(m_variable); } case Variant::String: { return std::holds_alternative(m_variable); } case Variant::UInt8: { return std::holds_alternative(m_variable); } case Variant::UInt16: { return std::holds_alternative(m_variable); } case Variant::UInt64: { return std::holds_alternative(m_variable); } case Variant::Invalid: { return false; } } return false; } bool Variant::toBool() { return std::get(m_variable); } int Variant::toInt() { return std::get(m_variable); } double Variant::toDouble() { return std::get(m_variable); } float Variant::toFloat() { return std::get(m_variable); } char Variant::toChar() { return std::get(m_variable); } std::string Variant::toString() { return std::get(m_variable); } uint8_t Variant::toUInt8() { return std::get(m_variable); } uint16_t Variant::toUInt16() { return std::get(m_variable); } uint64_t Variant::toUInt64() { return std::get(m_variable); }