enh: support get msg string and msg number
This commit is contained in:
parent
cbd9f86a34
commit
ed33493521
|
@ -37,6 +37,7 @@ extern "C" {
|
||||||
#define TD_MSG_NUMBER_
|
#define TD_MSG_NUMBER_
|
||||||
#undef TD_MSG_DICT_
|
#undef TD_MSG_DICT_
|
||||||
#undef TD_MSG_INFO_
|
#undef TD_MSG_INFO_
|
||||||
|
#undef TD_MSG_TYPE_INFO_
|
||||||
#undef TD_MSG_RANGE_CODE_
|
#undef TD_MSG_RANGE_CODE_
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
@ -44,6 +45,7 @@ extern "C" {
|
||||||
#undef TD_MSG_NUMBER_
|
#undef TD_MSG_NUMBER_
|
||||||
#undef TD_MSG_DICT_
|
#undef TD_MSG_DICT_
|
||||||
#undef TD_MSG_INFO_
|
#undef TD_MSG_INFO_
|
||||||
|
#undef TD_MSG_TYPE_INFO_
|
||||||
#undef TD_MSG_RANGE_CODE_
|
#undef TD_MSG_RANGE_CODE_
|
||||||
#define TD_MSG_SEG_CODE_
|
#define TD_MSG_SEG_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
@ -51,6 +53,7 @@ extern "C" {
|
||||||
#undef TD_MSG_NUMBER_
|
#undef TD_MSG_NUMBER_
|
||||||
#undef TD_MSG_DICT_
|
#undef TD_MSG_DICT_
|
||||||
#undef TD_MSG_INFO_
|
#undef TD_MSG_INFO_
|
||||||
|
#undef TD_MSG_TYPE_INFO_
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#undef TD_MSG_RANGE_CODE_
|
#undef TD_MSG_RANGE_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#undef TD_MSG_INFO_
|
#undef TD_MSG_INFO_
|
||||||
|
#undef TD_MSG_TYPE_INFO_
|
||||||
#undef TD_MSG_NUMBER_
|
#undef TD_MSG_NUMBER_
|
||||||
#undef TD_MSG_DICT_
|
#undef TD_MSG_DICT_
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
|
@ -76,6 +77,23 @@
|
||||||
#define TD_CLOSE_MSG_SEG(TYPE)
|
#define TD_CLOSE_MSG_SEG(TYPE)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
#elif defined(TD_MSG_TYPE_INFO_)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
const char *rspName;
|
||||||
|
int32_t type;
|
||||||
|
int32_t rspType;
|
||||||
|
} SMsgTypeInfo;
|
||||||
|
|
||||||
|
#undef TD_NEW_MSG_SEG
|
||||||
|
#undef TD_DEF_MSG_TYPE
|
||||||
|
#undef TD_CLOSE_MSG_SEG
|
||||||
|
#define TD_NEW_MSG_SEG(TYPE)
|
||||||
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) { #TYPE, #TYPE "_RSP", TYPE, TYPE##_RSP },
|
||||||
|
#define TD_CLOSE_MSG_SEG(TYPE)
|
||||||
|
|
||||||
|
SMsgTypeInfo tMsgTypeInfo[] = {
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
|
|
|
@ -20,11 +20,13 @@
|
||||||
#undef TD_MSG_DICT_
|
#undef TD_MSG_DICT_
|
||||||
#undef TD_MSG_RANGE_CODE_
|
#undef TD_MSG_RANGE_CODE_
|
||||||
#define TD_MSG_INFO_
|
#define TD_MSG_INFO_
|
||||||
|
#undef TD_MSG_TYPE_INFO_
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
|
||||||
#undef TD_MSG_NUMBER_
|
#undef TD_MSG_NUMBER_
|
||||||
#undef TD_MSG_INFO_
|
#undef TD_MSG_INFO_
|
||||||
|
#undef TD_MSG_TYPE_INFO_
|
||||||
#undef TD_MSG_RANGE_CODE_
|
#undef TD_MSG_RANGE_CODE_
|
||||||
#define TD_MSG_DICT_
|
#define TD_MSG_DICT_
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
|
@ -32,6 +34,7 @@
|
||||||
|
|
||||||
#undef TD_MSG_NUMBER_
|
#undef TD_MSG_NUMBER_
|
||||||
#undef TD_MSG_INFO_
|
#undef TD_MSG_INFO_
|
||||||
|
#undef TD_MSG_TYPE_INFO_
|
||||||
#undef TD_MSG_DICT_
|
#undef TD_MSG_DICT_
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#define TD_MSG_RANGE_CODE_
|
#define TD_MSG_RANGE_CODE_
|
||||||
|
|
|
@ -41,11 +41,11 @@ add_test(
|
||||||
)
|
)
|
||||||
|
|
||||||
# tmsg test
|
# tmsg test
|
||||||
# add_executable(tmsgTest "")
|
add_executable(tmsgTest "")
|
||||||
# target_sources(tmsgTest
|
target_sources(tmsgTest
|
||||||
# PRIVATE
|
PRIVATE
|
||||||
# "tmsgTest.cpp"
|
"tmsgTest.cpp"
|
||||||
# "../src/tmsg.c"
|
"../src/tmsg.c"
|
||||||
# )
|
)
|
||||||
# target_include_directories(tmsgTest PUBLIC "${TD_SOURCE_DIR}/include/common/")
|
target_include_directories(tmsgTest PUBLIC "${TD_SOURCE_DIR}/include/common/")
|
||||||
# target_link_libraries(tmsgTest PUBLIC os util gtest gtest_main)
|
target_link_libraries(tmsgTest PUBLIC os util gtest gtest_main)
|
|
@ -4,8 +4,23 @@
|
||||||
|
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
|
|
||||||
|
#undef TD_MSG_NUMBER_
|
||||||
|
#undef TD_MSG_DICT_
|
||||||
|
#undef TD_MSG_INFO_
|
||||||
|
#define TD_MSG_TYPE_INFO_
|
||||||
|
#undef TD_MSG_RANGE_CODE_
|
||||||
|
#undef TD_MSG_SEG_CODE_
|
||||||
|
#include "tmsgdef.h"
|
||||||
|
|
||||||
TEST(td_msg_test, simple_msg_test) {
|
TEST(td_msg_test, simple_msg_test) {
|
||||||
// std::cout << TMSG_INFO(TDMT_VND_DROP_TABLE) << std::endl;
|
// std::cout << TMSG_INFO(TDMT_VND_DROP_TABLE) << std::endl;
|
||||||
// std::cout << TMSG_INFO(TDMT_MND_DROP_SUPER_TABLE) << std::endl;
|
// std::cout << TMSG_INFO(TDMT_MND_DROP_SUPER_TABLE) << std::endl;
|
||||||
// std::cout << TMSG_INFO(TDMT_MND_CREATE_SUPER_TABLE) << std::endl;
|
// std::cout << TMSG_INFO(TDMT_MND_CREATE_SUPER_TABLE) << std::endl;
|
||||||
|
|
||||||
|
int32_t msgSize = sizeof(tMsgTypeInfo) / sizeof(SMsgTypeInfo);
|
||||||
|
for (size_t i = 0; i < msgSize; ++i) {
|
||||||
|
SMsgTypeInfo *pInfo = &tMsgTypeInfo[i];
|
||||||
|
std::cout << i * 2 + 1 << " " << pInfo->name << " " << pInfo->type << std::endl;
|
||||||
|
std::cout << i * 2 + 2 << " " << pInfo->rspName << " " << pInfo->rspType << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue