Remove FlatbufferString
FlatbufferSpan does most of the same things, with stronger typing and
more flexibility.
Change-Id: I8aec46d05be6db9395a47b260b7413b0f1b247e6
diff --git a/aos/flatbuffers.h b/aos/flatbuffers.h
index aa1e279..5bef204 100644
--- a/aos/flatbuffers.h
+++ b/aos/flatbuffers.h
@@ -176,40 +176,6 @@
absl::Span<const uint8_t> data_;
};
-// String backed flatbuffer.
-template <typename T>
-class FlatbufferString : public NonSizePrefixedFlatbuffer<T> {
- public:
- // Builds a flatbuffer using the contents of the string.
- FlatbufferString(const std::string_view data) : data_(data) {}
- // Builds a Flatbuffer by copying the data from the other flatbuffer.
- FlatbufferString(const NonSizePrefixedFlatbuffer<T> &other) {
- absl::Span<const uint8_t> d = other.span();
- data_ = std::string(reinterpret_cast<const char *>(d.data()), d.size());
- }
-
- // Copies the data from the other flatbuffer.
- FlatbufferString &operator=(const NonSizePrefixedFlatbuffer<T> &other) {
- absl::Span<const uint8_t> d = other.span();
- data_ = std::string(reinterpret_cast<const char *>(d.data()), d.size());
- return *this;
- }
-
- virtual ~FlatbufferString() override {}
-
- absl::Span<uint8_t> span() override {
- return absl::Span<uint8_t>(reinterpret_cast<uint8_t *>(data_.data()),
- data_.size());
- }
- absl::Span<const uint8_t> span() const override {
- return absl::Span<const uint8_t>(
- reinterpret_cast<const uint8_t *>(data_.data()), data_.size());
- }
-
- private:
- std::string data_;
-};
-
// ResizeableBuffer backed flatbuffer.
template <typename T>
class FlatbufferVector : public NonSizePrefixedFlatbuffer<T> {
diff --git a/aos/testing/flatbuffer_eq.h b/aos/testing/flatbuffer_eq.h
index b6b93d9..c4b708b 100644
--- a/aos/testing/flatbuffer_eq.h
+++ b/aos/testing/flatbuffer_eq.h
@@ -51,7 +51,7 @@
template <typename T>
class FlatbufferEqMatcher : public ::testing::MatcherInterface<const T *> {
public:
- FlatbufferEqMatcher(aos::FlatbufferString<T> expected)
+ FlatbufferEqMatcher(aos::FlatbufferSpan<T> expected)
: expected_(std::move(expected)) {}
~FlatbufferEqMatcher() override = default;
@@ -70,7 +70,7 @@
}
private:
- const aos::FlatbufferString<T> expected_;
+ const aos::FlatbufferSpan<T> expected_;
};
// Returns a googlemock matcher which will compare a `const T *` or a `const
@@ -81,7 +81,7 @@
template <typename T>
inline auto FlatbufferEq(const aos::NonSizePrefixedFlatbuffer<T> &expected) {
return FlatbufferUnwrapped(::testing::MakeMatcher(
- new FlatbufferEqMatcher(aos::FlatbufferString<T>(expected))));
+ new FlatbufferEqMatcher(aos::FlatbufferSpan<T>(expected))));
}
} // namespace testing