diff --git a/modules/ipc/apps/zenoh_topic_echo.cpp b/modules/ipc/apps/zenoh_topic_echo.cpp index fd097fdb..45dfc5f1 100644 --- a/modules/ipc/apps/zenoh_topic_echo.cpp +++ b/modules/ipc/apps/zenoh_topic_echo.cpp @@ -27,10 +27,10 @@ #include "hephaestus/ipc/zenoh/session.h" #include "hephaestus/serdes/dynamic_deserializer.h" #include "hephaestus/serdes/type_info.h" -#include "hephaestus/types/type_formatting.h" #include "hephaestus/utils/exception.h" #include "hephaestus/utils/signal_handler.h" #include "hephaestus/utils/stack_trace.h" +#include "hephaestus/utils/string/type_formatting.h" namespace { constexpr auto DEFAULT_MAX_ARRAY_LENGTH = 100; @@ -95,7 +95,7 @@ class TopicEcho { truncateLongItems(msg_json, noarr_, max_array_length_); fmt::println("From: {}. Topic: {}\nSequence: {} | Timestamp: {}\n{}", metadata.sender_id, metadata.topic, metadata.sequence_id, - types::toString(std::chrono::time_point( + utils::string::toString(std::chrono::time_point( std::chrono::duration_cast(metadata.timestamp))), msg_json); } diff --git a/modules/serdes/CMakeLists.txt b/modules/serdes/CMakeLists.txt index 0712f55c..bfa5e2e0 100644 --- a/modules/serdes/CMakeLists.txt +++ b/modules/serdes/CMakeLists.txt @@ -19,6 +19,7 @@ set(SOURCES src/serdes.cpp src/type_info.cpp src/dynamic_deserializer.cpp + src/protobuf/buffers.cpp src/protobuf/dynamic_deserializer.cpp src/protobuf/buffers.cpp src/protobuf/protobuf.cpp @@ -27,6 +28,7 @@ set(SOURCES include/hephaestus/serdes/dynamic_deserializer.h include/hephaestus/serdes/serdes.h include/hephaestus/serdes/type_info.h + include/hephaestus/serdes/protobuf/buffers.h include/hephaestus/serdes/protobuf/concepts.h include/hephaestus/serdes/protobuf/buffers.h include/hephaestus/serdes/protobuf/dynamic_deserializer.h diff --git a/modules/types/CMakeLists.txt b/modules/types/CMakeLists.txt index 87310e6e..9c30a540 100644 --- a/modules/types/CMakeLists.txt +++ b/modules/types/CMakeLists.txt @@ -13,14 +13,8 @@ find_package(magic_enum REQUIRED) find_package(range-v3 REQUIRED) # library sources -set(SOURCES - src/bounds.cpp - src/dummy_type.cpp - src/type_formatting.cpp - README.md - include/hephaestus/types/bounds.h - include/hephaestus/types/dummy_type.h - include/hephaestus/types/type_formatting.h +set(SOURCES src/bounds.cpp src/dummy_type.cpp README.md include/hephaestus/types/bounds.h + include/hephaestus/types/dummy_type.h ) # library target diff --git a/modules/types/src/dummy_type.cpp b/modules/types/src/dummy_type.cpp index b9f08a0f..07cce712 100644 --- a/modules/types/src/dummy_type.cpp +++ b/modules/types/src/dummy_type.cpp @@ -11,7 +11,7 @@ #include #include "hephaestus/random/random_object_creator.h" -#include "hephaestus/types/type_formatting.h" +#include "hephaestus/utils/string/type_formatting.h" namespace heph::types { @@ -54,12 +54,11 @@ auto DummyType::random(std::mt19937_64& mt) -> DummyType { } auto operator<<(std::ostream& os, const DummyType& dummy_type) -> std::ostream& { - return os << "DummyType{" - << "\n" + return os << "DummyType{\n" << " dummy_primitives_type={" << dummy_type.dummy_primitives_type << "}\n" << " dummy_enum=" << magic_enum::enum_name(dummy_type.dummy_enum) << "\n" << " dummy_string=" << dummy_type.dummy_string << "\n" - << " dummy_vector=" << toString(dummy_type.dummy_vector) << "\n" + << " dummy_vector=" << utils::string::toString(dummy_type.dummy_vector) << "\n" << "}"; } diff --git a/modules/types/tests/CMakeLists.txt b/modules/types/tests/CMakeLists.txt index 05f215c0..ed840707 100644 --- a/modules/types/tests/CMakeLists.txt +++ b/modules/types/tests/CMakeLists.txt @@ -11,8 +11,3 @@ define_module_test( NAME tests SOURCES tests.cpp ) - -define_module_test( - NAME type_formatting_tests - SOURCES type_formatting_tests.cpp -) diff --git a/modules/utils/CMakeLists.txt b/modules/utils/CMakeLists.txt index bb42442a..d67718cb 100644 --- a/modules/utils/CMakeLists.txt +++ b/modules/utils/CMakeLists.txt @@ -22,6 +22,7 @@ set(SOURCES src/filesystem/scoped_path.cpp src/string/string_literal.cpp src/string/string_utils.cpp + src/string/type_formatting.cpp src/timing/watchdog.cpp src/bit_flag.cpp src/concepts.cpp @@ -35,6 +36,7 @@ set(SOURCES include/hephaestus/utils/filesystem/scoped_path.h include/hephaestus/utils/string/string_literal.h include/hephaestus/utils/string/string_utils.h + include/hephaestus/utils/string/type_formatting.h include/hephaestus/utils/timing/watchdog.h include/hephaestus/utils/bit_flag.h include/hephaestus/utils/concepts.h diff --git a/modules/types/include/hephaestus/types/type_formatting.h b/modules/utils/include/hephaestus/utils/string/type_formatting.h similarity index 95% rename from modules/types/include/hephaestus/types/type_formatting.h rename to modules/utils/include/hephaestus/utils/string/type_formatting.h index 8e0b4a19..83e87da9 100644 --- a/modules/types/include/hephaestus/types/type_formatting.h +++ b/modules/utils/include/hephaestus/utils/string/type_formatting.h @@ -15,7 +15,7 @@ #include "hephaestus/utils/concepts.h" -namespace heph::types { +namespace heph::utils::string { //================================================================================================= // Array and Vector @@ -46,7 +46,8 @@ template std::stringstream ss; for (const auto& [key, value] : umap) { - ss << " Key: " << key << ", Value: " << value << '\n'; + const std::string str = fmt::format(" Key: {}, Value: {}\n", key, value); + ss << str; } return ss.str(); @@ -86,4 +87,4 @@ template return fmt::format("{}d {:02}h:{:02}m:{:02}.{:09}s", days, hours, minutes, seconds, sub_seconds * SCALER); } -}; // namespace heph::types +}; // namespace heph::utils::string diff --git a/modules/types/src/type_formatting.cpp b/modules/utils/src/string/type_formatting.cpp similarity index 74% rename from modules/types/src/type_formatting.cpp rename to modules/utils/src/string/type_formatting.cpp index d6559693..8c0c2a86 100644 --- a/modules/types/src/type_formatting.cpp +++ b/modules/utils/src/string/type_formatting.cpp @@ -2,4 +2,4 @@ // Copyright (C) 2023-2024 HEPHAESTUS Contributors //================================================================================================= -#include "hephaestus/types/type_formatting.h" // NOLINT(misc-include-cleaner) +#include "hephaestus/utils/string/type_formatting.h" // NOLINT(misc-include-cleaner) diff --git a/modules/utils/tests/CMakeLists.txt b/modules/utils/tests/CMakeLists.txt index 15ff5abc..9f4a2b46 100644 --- a/modules/utils/tests/CMakeLists.txt +++ b/modules/utils/tests/CMakeLists.txt @@ -2,6 +2,13 @@ # Copyright (C) 2023-2024 HEPHAESTUS Contributors # ================================================================================================= +define_module_test( + NAME bit_flag_tests + SOURCES bit_flag_tests.cpp + PUBLIC_INCLUDE_PATHS $ + PUBLIC_LINK_LIBS "" +) + define_module_test( NAME concepts_tests SOURCES concepts_tests.cpp @@ -38,8 +45,8 @@ define_module_test( ) define_module_test( - NAME bit_flag_tests - SOURCES bit_flag_tests.cpp + NAME type_formatting_tests + SOURCES type_formatting_tests.cpp PUBLIC_INCLUDE_PATHS $ PUBLIC_LINK_LIBS "" ) diff --git a/modules/types/tests/type_formatting_tests.cpp b/modules/utils/tests/type_formatting_tests.cpp similarity index 97% rename from modules/types/tests/type_formatting_tests.cpp rename to modules/utils/tests/type_formatting_tests.cpp index 88d82d16..72e612e3 100644 --- a/modules/types/tests/type_formatting_tests.cpp +++ b/modules/utils/tests/type_formatting_tests.cpp @@ -13,11 +13,11 @@ #include #include -#include "hephaestus/types/type_formatting.h" +#include "hephaestus/utils/string/type_formatting.h" using namespace ::testing; // NOLINT(google-build-using-namespace) -namespace heph::types::tests { +namespace heph::utils::string::tests { //================================================================================================= // Array @@ -175,4 +175,4 @@ TEST(TypeFormattingTests, ChronoTimestampFormattingSystemClock) { ASSERT_EQ(str[19], '.'); } -} // namespace heph::types::tests +} // namespace heph::utils::string::tests