AuroraRuntime/Include/Aurora/Data/Data.hpp

62 lines
2.1 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Data.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
#include "EDataType.hpp"
#include "PrimitiveValue.hpp"
#include "Value.hpp"
#include "TypedValue.hpp"
2021-06-27 21:25:29 +00:00
namespace Aurora::Data
{
2021-09-06 10:58:08 +00:00
#if !defined(_CPPSHARP)
template<EDataType type>
2021-06-27 21:25:29 +00:00
static constexpr AuUInt GetDatatypeLength()
{
switch /*constexpr*/ (type)
{
case EDataType::kTypeBoolean: return 1;
case EDataType::kTypeStructFloat: return 4;
case EDataType::kTypeStructDouble: return 8;
case EDataType::kTypeVec3: return 3 * 4;
case EDataType::kTypeVec4: return 4 * 4;
case EDataType::kTypeStructUInt8: return 1;
case EDataType::kTypeStructInt8: return 1;
case EDataType::kTypeStructUInt16: return 2;
case EDataType::kTypeStructInt16: return 2;
case EDataType::kTypeStructUInt32: return 4;
case EDataType::kTypeStructInt32: return 4;
case EDataType::kTypeStructUInt64: return 8;
case EDataType::kTypeStructInt64: return 8;
default: return 0;//static_assert(false, "invalid datatype");
2021-06-27 21:25:29 +00:00
}
}
static AuUInt GetDatatypeLength(EDataType type)
2021-06-27 21:25:29 +00:00
{
switch /*constexpr*/ (type)
{
case EDataType::kTypeBoolean: return 1;
case EDataType::kTypeStructFloat: return 4;
case EDataType::kTypeStructDouble: return 8;
case EDataType::kTypeVec3: return 3 * 4;
case EDataType::kTypeVec4: return 4 * 4;
case EDataType::kTypeStructUInt8: return 1;
case EDataType::kTypeStructInt8: return 1;
case EDataType::kTypeStructUInt16: return 2;
case EDataType::kTypeStructInt16: return 2;
case EDataType::kTypeStructUInt32: return 4;
case EDataType::kTypeStructInt32: return 4;
case EDataType::kTypeStructUInt64: return 8;
case EDataType::kTypeStructInt64: return 8;
default: return 0;
2021-06-27 21:25:29 +00:00
}
}
2021-09-06 10:58:08 +00:00
#endif
}