2023-03-14 18:01:05 -04:00
|
|
|
/*
|
|
|
|
* Created by Brett on 14/03/23.
|
|
|
|
* Licensed under GNU General Public License V3.0
|
|
|
|
* See LICENSE file for license detail
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BLT_TESTS_LOG_UTIL_H
|
|
|
|
#define BLT_TESTS_LOG_UTIL_H
|
|
|
|
|
|
|
|
#include <blt/math/vectors.h>
|
|
|
|
#include <blt/math/matrix.h>
|
2023-07-21 03:32:42 -04:00
|
|
|
#include <blt/std/logging.h>
|
2024-04-09 19:09:50 -04:00
|
|
|
#include <blt/std/utility.h>
|
|
|
|
#include "blt/std/string.h"
|
2023-03-14 18:01:05 -04:00
|
|
|
|
2024-04-09 19:09:50 -04:00
|
|
|
namespace blt
|
|
|
|
{
|
|
|
|
|
|
|
|
template<typename Writer = blt::logging::logger, typename T, blt::u32 size>
|
|
|
|
static inline Writer& operator<<(Writer& log, const blt::vec<T, size>& vec)
|
|
|
|
{
|
|
|
|
std::string type_string;
|
|
|
|
const auto tstr = blt::type_string<T>();
|
|
|
|
|
|
|
|
if constexpr (std::is_arithmetic_v<T>)
|
|
|
|
{
|
|
|
|
type_string += tstr[0];
|
|
|
|
// for unsigned long / unsigned int
|
|
|
|
auto split = blt::string::split_sv(tstr, ' ');
|
2024-09-19 15:12:38 -04:00
|
|
|
if (tstr[0] == 'u')
|
|
|
|
{
|
|
|
|
if (split.size() > 1)
|
|
|
|
{
|
2024-04-09 19:09:50 -04:00
|
|
|
type_string += split[1][0];
|
|
|
|
} else
|
|
|
|
type_string += tstr[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
} else
|
|
|
|
type_string = tstr;
|
|
|
|
|
|
|
|
log << "Vec" << size << type_string << "(";
|
|
|
|
for (blt::u32 i = 0; i < size; i++)
|
|
|
|
log << vec[i] << ((i == size - 1) ? ")" : ", ");
|
2023-03-14 18:01:05 -04:00
|
|
|
return log;
|
|
|
|
}
|
2024-04-09 19:09:50 -04:00
|
|
|
|
|
|
|
template<typename Writer = std::ostream>
|
|
|
|
inline Writer& operator<<(Writer& out, const mat4x4& v)
|
|
|
|
{
|
2024-05-01 03:27:17 -04:00
|
|
|
out << "Mat4x4(";
|
|
|
|
out << "{" << v.m00() << ", " << v.m01() << ", " << v.m02() << ", " << v.m03() << "},";
|
|
|
|
out << "\t{" << v.m10() << ", " << v.m11() << ", " << v.m12() << ", " << v.m13() << "},";
|
|
|
|
out << "\t{" << v.m20() << ", " << v.m21() << ", " << v.m22() << ", " << v.m23() << "},";
|
2024-04-09 19:09:50 -04:00
|
|
|
out << "\t{" << v.m30() << ", " << v.m31() << ", " << v.m32() << ", " << v.m33() << "})";
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2024-09-19 15:12:38 -04:00
|
|
|
template<typename Writer = std::ostream, typename T, blt::u32 rows, blt::u32 columns>
|
|
|
|
inline Writer& operator<<(Writer& out, const generalized_matrix<T, rows, columns>& mat)
|
|
|
|
{
|
|
|
|
out << "Mat" << rows << 'x' << columns << "(\n";
|
|
|
|
for (blt::u32 c = 0; c < columns; c++)
|
|
|
|
{
|
|
|
|
out << "\t{";
|
|
|
|
for (blt::u32 r = 0; r < rows; r++)
|
|
|
|
out << mat[c][r] << ((r < rows - 1) ? ", " : "");
|
|
|
|
out << '}' << ((c < columns - 1) ? "," : "") << "\n";
|
|
|
|
}
|
|
|
|
out << ")";
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2023-03-14 18:01:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //BLT_TESTS_LOG_UTIL_H
|