#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include "thirdparty/CRC.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "log.hpp" using namespace std::literals; #define _FORMAT_CPP_TYPE(fdesc, value, prefix, int32, int64, uint32, uint64, float, double, bool, string, enum, message, ...) \ switch (fdesc->cpp_type()) { \ case google::protobuf::FieldDescriptor::CPPTYPE_BOOL: \ value = prefix##bool(__VA_ARGS__) ? "true" : "false"; \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE: \ value = fmt::format("{0}", prefix##double(__VA_ARGS__)); \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: \ value = fmt::format("{0}", prefix##float(__VA_ARGS__)); \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_INT32: \ value = fmt::format("{0}", prefix##int32(__VA_ARGS__)); \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: \ value = fmt::format("{0}", prefix##uint32(__VA_ARGS__)); \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_INT64: \ value = fmt::format("{0}", prefix##int64(__VA_ARGS__)); \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_UINT64: \ value = fmt::format("{0}", prefix##uint64(__VA_ARGS__)); \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_STRING: \ value = prefix##string(__VA_ARGS__); \ break; \ case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {\ const auto *enum_desc = prefix##enum(__VA_ARGS__); \ value = fmt::format("{0} = {1}", enum_desc->full_name(), enum_desc->index()); \ } break; \ case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: \ value = "(Message)"; \ break; \ } #define FORMAT_CPP_TYPE_LOWERCASE(fdesc, value, prefix, ...) _FORMAT_CPP_TYPE(fdesc, value, prefix, int32, int64, uint32, uint64, float, double, bool, string, enum, message __VA_OPT__(,) __VA_ARGS__) #define FORMAT_CPP_TYPE_TITLECASE(fdesc, value, prefix, ...) _FORMAT_CPP_TYPE(fdesc, value, prefix, Int32, Int64, UInt32, UInt64, Float, Double, Bool, String, Enum, Message __VA_OPT__(,) __VA_ARGS__)