Skip to content

Commit

Permalink
compile
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Jul 2, 2024
1 parent 3667195 commit e51fa7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
16 changes: 8 additions & 8 deletions include/ylt/standalone/iguana/dynamic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ constexpr inline uint8_t ENABLE_ALL = 0x0F;
template <typename T, uint8_t ENABLE_FLAG = ENABLE_PB>
struct base_impl : public base {
void to_pb(std::string& str) override {
if constexpr (ENABLE_FLAG & ENABLE_PB) {
if constexpr ((ENABLE_FLAG & ENABLE_PB) != 0) {
to_pb_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand All @@ -27,7 +27,7 @@ struct base_impl : public base {
}

void from_pb(std::string_view str) override {
if constexpr (ENABLE_FLAG & ENABLE_PB) {
if constexpr ((ENABLE_FLAG & ENABLE_PB) != 0) {
from_pb_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand All @@ -36,7 +36,7 @@ struct base_impl : public base {
}

void to_json(std::string& str) override {
if constexpr (ENABLE_FLAG & ENABLE_JSON) {
if constexpr ((ENABLE_FLAG & ENABLE_JSON) != 0) {
to_json_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand All @@ -45,7 +45,7 @@ struct base_impl : public base {
}

void from_json(std::string_view str) override {
if constexpr (ENABLE_FLAG & ENABLE_JSON) {
if constexpr ((ENABLE_FLAG & ENABLE_JSON) != 0) {
from_json_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand All @@ -54,7 +54,7 @@ struct base_impl : public base {
}

void to_xml(std::string& str) override {
if constexpr (ENABLE_FLAG & ENABLE_XML) {
if constexpr ((ENABLE_FLAG & ENABLE_XML) != 0) {
to_xml_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand All @@ -63,7 +63,7 @@ struct base_impl : public base {
}

void from_xml(std::string_view str) override {
if constexpr (ENABLE_FLAG & ENABLE_XML) {
if constexpr ((ENABLE_FLAG & ENABLE_XML) != 0) {
from_xml_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand All @@ -72,7 +72,7 @@ struct base_impl : public base {
}

void to_yaml(std::string& str) override {
if constexpr (ENABLE_FLAG & ENABLE_YAML) {
if constexpr ((ENABLE_FLAG & ENABLE_YAML) != 0) {
to_yaml_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand All @@ -81,7 +81,7 @@ struct base_impl : public base {
}

void from_yaml(std::string_view str) override {
if constexpr (ENABLE_FLAG & ENABLE_YAML) {
if constexpr ((ENABLE_FLAG & ENABLE_YAML) != 0) {
from_yaml_adl((iguana_adl_t*)nullptr, *(static_cast<T*>(this)), str);
}
else {
Expand Down
30 changes: 14 additions & 16 deletions src/struct_pb/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@ endif()

set(TEST_PROTO main.cpp)

if (Protobuf_FOUND)
if(${Protobuf_VERSION} GREATER_EQUAL 3.21)
message(STATUS "Gen proto files")
add_definitions(-DSTRUCT_PB_WITH_PROTO)
message(STATUS "Found Protobuf: ${Protobuf_VERSION}")
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/)
file(GLOB PROTO_FILES ${PROTO_SRC_DIR}/*.proto)
if (TEST_STRUCT_PB_WITH_PROTO)
message(STATUS "Gen proto files")
add_definitions(-DSTRUCT_PB_WITH_PROTO)
message(STATUS "Found Protobuf: ${Protobuf_VERSION}")
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/)
file(GLOB PROTO_FILES ${PROTO_SRC_DIR}/*.proto)

protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
# message(STATUS "Proto source files: ${PROTO_SRCS}")
# message(STATUS "Proto header files: ${PROTO_HDRS}")
add_executable(struct_pb_test ${PROTO_SRCS} ${TEST_PROTO})
target_link_libraries(struct_pb_test PRIVATE protobuf::libprotobuf)
add_test(NAME struct_pb_test COMMAND struct_pb_test)
endif()
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
# message(STATUS "Proto source files: ${PROTO_SRCS}")
# message(STATUS "Proto header files: ${PROTO_HDRS}")
add_executable(struct_pb_test ${PROTO_SRCS} ${TEST_PROTO})
target_link_libraries(struct_pb_test PRIVATE protobuf::libprotobuf)
add_test(NAME struct_pb_test COMMAND struct_pb_test)
else()
add_executable(struct_pb_test ${TEST_PROTO})
add_test(NAME struct_pb_test COMMAND struct_pb_test)
Expand Down

0 comments on commit e51fa7a

Please sign in to comment.