Finish converting GSL to absl::Span
One less dependency.
Change-Id: Iaac25a3c1312a21a8a2b77b8cfee2463bdb51196
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/motors/peripheral/uart_buffer.h b/motors/peripheral/uart_buffer.h
index 19015bb..c324a2d 100644
--- a/motors/peripheral/uart_buffer.h
+++ b/motors/peripheral/uart_buffer.h
@@ -2,8 +2,9 @@
#define MOTORS_PERIPHERAL_UART_BUFFER_H_
#include <array>
+#include <cstring>
-#include "third_party/GSL/include/gsl/gsl"
+#include "absl/types/span.h"
namespace frc971 {
namespace teensy {
@@ -13,14 +14,14 @@
class UartBuffer {
public:
// Returns the number of characters added.
- __attribute__((warn_unused_result)) int PushSpan(gsl::span<const char> data);
+ __attribute__((warn_unused_result)) int PushSpan(absl::Span<const char> data);
// max is the maximum size the returned span should be.
// The data in the result is only valid until another method is called.
// Note that this may not return all available data when doing so would
// require wrapping around, but it will always return a non-empty span if any
// data is available.
- gsl::span<const char> PopSpan(int max);
+ absl::Span<const char> PopSpan(int max);
bool empty() const { return size_ == 0; }
bool full() const { return size_ == kSize; }
@@ -44,7 +45,7 @@
};
template <int kSize>
-int UartBuffer<kSize>::PushSpan(gsl::span<const char> data) {
+int UartBuffer<kSize>::PushSpan(absl::Span<const char> data) {
const int end_location = (start_ + size_) % kSize;
const int remaining_end = ::std::min(kSize - size_, kSize - end_location);
const int on_end = ::std::min<int>(data.size(), remaining_end);
@@ -65,9 +66,10 @@
}
template <int kSize>
-gsl::span<const char> UartBuffer<kSize>::PopSpan(int max) {
+absl::Span<const char> UartBuffer<kSize>::PopSpan(int max) {
const size_t result_size = std::min(max, std::min(kSize - start_, size_));
- const auto result = gsl::span<const char>(data_).subspan(start_, result_size);
+ const auto result =
+ absl::Span<const char>(data_).subspan(start_, result_size);
start_ = (start_ + result_size) % kSize;
size_ -= result_size;
return result;