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