Skip to content

Commit

Permalink
Implement StructArray GetLastValue
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJohnson committed Jun 2, 2024
1 parent a6ca861 commit e666e60
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions wpiutil/src/main/native/include/wpi/DataLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -1424,9 +1424,19 @@ class StructArrayLogEntry : public DataLogEntry {
if (m_lastValue.empty()) {
return std::nullopt;
}
// FIXME
return std::apply(
[&](const I&... info) { m_buf.Read(m_lastValue, info...); }, m_info);
size_t size = std::apply(S::GetSize, m_info);
std::vector<T> rv;
rv.value.reserve(m_lastValue.size() / size);
for (auto in = m_lastValue.begin(), end = m_lastValue.end(); in < end;
in += size) {
std::apply(
[&](const I&... info) {
rv.value.emplace_back(S::Unpack(
std::span<const uint8_t>{std::to_address(in), size}, info...));
},
m_info);
}
return rv;
}

private:
Expand Down

0 comments on commit e666e60

Please sign in to comment.