Skip to content

Commit

Permalink
read-api: reformat, make build under ubuntu 22
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasDebrunner committed Sep 26, 2023
1 parent 589512f commit 7865d47
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
24 changes: 18 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
7 changes: 4 additions & 3 deletions ulog_cpp/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ class Value {
std::vector<float>, std::vector<double>, std::vector<bool>, std::string>;

template <typename T>
struct is_vector : std::false_type { // NOLINT(*-identifier-naming)
struct is_vector : std::false_type { // NOLINT(*-identifier-naming)
};
template <typename T>
struct is_vector<std::vector<T>> : std::true_type {
};

template <typename T>
struct is_string : std::is_same<std::decay_t<T>, std::string> { // NOLINT(*-identifier-naming)
struct is_string : std::is_same<std::decay_t<T>, std::string> { // NOLINT(*-identifier-naming)
};

Value(const Field& field_ref, const std::vector<uint8_t>::const_iterator& backing_ref_begin,
Expand Down Expand Up @@ -247,7 +247,8 @@ class Value {
backing_end - backing_start - total_offset < static_cast<int64_t>(sizeof(v))) {
throw ParsingException("Unexpected data type size");
}
std::copy(backing_start + total_offset, backing_start + total_offset + sizeof(v), reinterpret_cast<uint8_t*>(&v));
std::copy(backing_start + total_offset, backing_start + total_offset + sizeof(v),
reinterpret_cast<uint8_t*>(&v));
return v;
}

Expand Down
13 changes: 6 additions & 7 deletions ulog_cpp/subscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,16 @@ class TypedDataView {
template <typename base_iterator_type>
class SubscriptionIterator {
public:
SubscriptionIterator(const base_iterator_type& it,
std::shared_ptr<MessageFormat> message_format)
SubscriptionIterator(const base_iterator_type& it, std::shared_ptr<MessageFormat> 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); }

Expand Down

0 comments on commit 7865d47

Please sign in to comment.