67 lines
2.6 KiB
C++
67 lines
2.6 KiB
C++
#pragma once
|
|
#include <algorithm>
|
|
#include <any>
|
|
#include <json/json.h>
|
|
#include <chrono>
|
|
#include <google/protobuf/descriptor.h>
|
|
#include <google/protobuf/generated_message_reflection.h>
|
|
#include <google/protobuf/message.h>
|
|
#include <memory>
|
|
#include <type_traits>
|
|
#include <cstdarg>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include "thirdparty/CRC.hpp"
|
|
#include <string>
|
|
#include <functional>
|
|
#include <thread>
|
|
#include <type_traits>
|
|
#include <vector>
|
|
#include <optional>
|
|
#include <thread>
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <string.h>
|
|
#include <map>
|
|
#include <variant>
|
|
#include <filesystem>
|
|
#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__)
|