Allowed pointers to be logged/printed
This commit is contained in:
@@ -13,10 +13,14 @@
|
||||
// Standard libraries //
|
||||
|
||||
#include <unordered_map>
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <span>
|
||||
|
||||
// LXC util files //
|
||||
|
||||
|
||||
@@ -156,7 +156,16 @@ namespace LXC::Util
|
||||
requires Internal::HasLogStrFunc<T> || Internal::Logable<T>
|
||||
inline void PrintLn(T&& arg)
|
||||
{
|
||||
if constexpr (Internal::HasLogStrFunc<T>)
|
||||
if constexpr (std::is_pointer_v<T>)
|
||||
{
|
||||
if (arg != nullptr) _LIKELY
|
||||
PrintLn(*arg);
|
||||
|
||||
else
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, "Nullptr to: [", typeid(std::remove_pointer_t<T>).name(), "]");
|
||||
}
|
||||
|
||||
else if constexpr (Internal::HasLogStrFunc<T>)
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, arg.LogStr());
|
||||
|
||||
else
|
||||
@@ -176,12 +185,21 @@ namespace LXC::Util
|
||||
// Logs a singular argument to the log, calls Log() if it can on the object //
|
||||
template<typename T>
|
||||
requires Internal::HasLogStrFunc<T> || Internal::Logable<T>
|
||||
inline void Log(T arg)
|
||||
inline void Log(T&& arg)
|
||||
{
|
||||
std::ofstream& log = Internal::Log();
|
||||
if (log.is_open()) _UNLIKELY
|
||||
{
|
||||
if constexpr (Internal::HasLogStrFunc<T>)
|
||||
if constexpr (std::is_pointer_v<T>)
|
||||
{
|
||||
if (arg != nullptr) _LIKELY
|
||||
Log(*arg);
|
||||
|
||||
else
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(log, "[LXC] Nullptr to: [", typeid(std::remove_pointer_t<T>).name(), "]");
|
||||
}
|
||||
|
||||
else if constexpr (Internal::HasLogStrFunc<T>)
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(log, "[LXC] ", '{', arg.LogStr(), '}');
|
||||
|
||||
else
|
||||
|
||||
@@ -69,6 +69,10 @@ int main(int argc, char** argv)
|
||||
|
||||
// Turns the tokens into into an abstract syntax tree //
|
||||
Util::ReturnVal functionsAST = Parser::TurnTokensIntoAST(tokens);
|
||||
if (functionsAST.Failed()) _UNLIKELY
|
||||
{
|
||||
Util::Stop();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user