#pragma once #include #include #include namespace sp { namespace details { template struct IdPrinter {}; template <> struct IdPrinter<> { static std::string PrintMessageId() { return ""; } }; template struct IdPrinter { static std::string PrintMessageId() { return IdPrinter::PrintMessageId(); } }; template struct IdPrinter, TOptions...> { static std::string PrintMessageId() { return "(Id: " + std::to_string(TId) + ")"; } }; template std::string PrintFields(const std::tuple& a_Fields); template struct FieldPrinter { static std::string PrintField(const sp::Field& a_Field) { return Reflector::GetClassName() + "=" + PrintData(a_Field.GetValue()); } }; template struct FieldPrinter, IAlignment> { static std::string PrintField(const Field, IAlignment>& a_Field) { return "BitField<" + Reflector::GetClassName() + ">[" + PrintFields(a_Field.GetValue().GetFields()) + "]"; } }; template std::string PrintFields(const std::tuple& a_Fields) { std::string concat; TupleForEach( [&concat](const auto& a_Field) { using TField = typename std::decay::type; constexpr std::size_t alignment = TField::AlignmentValue; concat += FieldPrinter::PrintField(a_Field) + ", "; }, a_Fields); return concat.substr(0, concat.size() - 2); } template std::string PrintMessage(const MessageBase& a_Message) { return sp::GetBasicClassName(a_Message) + sp::details::IdPrinter::PrintMessageId() + "[" + sp::details::PrintFields(a_Message.GetFields()) + "]"; } } // namespace details } // namespace sp