From 7865d47ed7a8507d8e7073f28434fc85b1382079 Mon Sep 17 00:00:00 2001 From: Thomas Debrunner Date: Tue, 26 Sep 2023 14:42:56 +0200 Subject: [PATCH] read-api: reformat, make build under ubuntu 22 --- CMakeLists.txt | 2 +- test/CMakeLists.txt | 24 ++++++++++++++++++------ ulog_cpp/messages.hpp | 7 ++++--- ulog_cpp/subscription.hpp | 13 ++++++------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eed2e3b..56123ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.24 FATAL_ERROR) +cmake_minimum_required(VERSION 3.22 FATAL_ERROR) project(ulog_cpp LANGUAGES CXX) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 978f50c..da9ca46 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,12 +1,24 @@ include(FetchContent) -FetchContent_Declare( - DocTest - GIT_REPOSITORY "https://github.com/doctest/doctest.git" - GIT_TAG "v2.4.11" - SYSTEM -) + +# cmake < 3.25 fails with system attribute +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25") + FetchContent_Declare( + DocTest + GIT_REPOSITORY "https://github.com/doctest/doctest.git" + GIT_TAG "v2.4.11" + SYSTEM + ) + +else() + FetchContent_Declare( + DocTest + GIT_REPOSITORY "https://github.com/doctest/doctest.git" + GIT_TAG "v2.4.11" + ) +endif () + FetchContent_MakeAvailable(DocTest) diff --git a/ulog_cpp/messages.hpp b/ulog_cpp/messages.hpp index 97044c6..773b414 100644 --- a/ulog_cpp/messages.hpp +++ b/ulog_cpp/messages.hpp @@ -146,14 +146,14 @@ class Value { std::vector, std::vector, std::vector, std::string>; template - struct is_vector : std::false_type { // NOLINT(*-identifier-naming) + struct is_vector : std::false_type { // NOLINT(*-identifier-naming) }; template struct is_vector> : std::true_type { }; template - struct is_string : std::is_same, std::string> { // NOLINT(*-identifier-naming) + struct is_string : std::is_same, std::string> { // NOLINT(*-identifier-naming) }; Value(const Field& field_ref, const std::vector::const_iterator& backing_ref_begin, @@ -247,7 +247,8 @@ class Value { backing_end - backing_start - total_offset < static_cast(sizeof(v))) { throw ParsingException("Unexpected data type size"); } - std::copy(backing_start + total_offset, backing_start + total_offset + sizeof(v), reinterpret_cast(&v)); + std::copy(backing_start + total_offset, backing_start + total_offset + sizeof(v), + reinterpret_cast(&v)); return v; } diff --git a/ulog_cpp/subscription.hpp b/ulog_cpp/subscription.hpp index 7675763..092f458 100644 --- a/ulog_cpp/subscription.hpp +++ b/ulog_cpp/subscription.hpp @@ -52,17 +52,16 @@ class TypedDataView { template class SubscriptionIterator { public: - SubscriptionIterator(const base_iterator_type& it, - std::shared_ptr message_format) + SubscriptionIterator(const base_iterator_type& it, std::shared_ptr message_format) : _it(it), _message_format(std::move(message_format)) { } - using iterator_category = std::random_access_iterator_tag; // NOLINT(*-identifier-naming) - using value_type = TypedDataView; // NOLINT(*-identifier-naming) - using difference_type = std::ptrdiff_t; // NOLINT(*-identifier-naming) - using Pointer = TypedDataView*; // NOLINT(*-identifier-naming) - using reference = TypedDataView&; // NOLINT(*-identifier-naming) + using iterator_category = std::random_access_iterator_tag; // NOLINT(*-identifier-naming) + using value_type = TypedDataView; // NOLINT(*-identifier-naming) + using difference_type = std::ptrdiff_t; // NOLINT(*-identifier-naming) + using Pointer = TypedDataView*; // NOLINT(*-identifier-naming) + using reference = TypedDataView&; // NOLINT(*-identifier-naming) TypedDataView operator*() { return TypedDataView(*_it, *_message_format); }