Skip to content

Commit

Permalink
Change binary type buffer from uint8_t to std::byte (#3233)
Browse files Browse the repository at this point in the history
  • Loading branch information
XanthosXanthopoulos committed Nov 17, 2024
1 parent 1979e28 commit 37800f7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libtiledbsoma/src/geometry/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum GeometryType : uint32_t {
GEOMETRYCOLLECTION = 7
};

using BinaryBuffer = std::vector<uint8_t>;
using BinaryBuffer = std::vector<std::byte>;

struct GeometryCollection;
using GenericGeometry = std::variant<
Expand Down
2 changes: 1 addition & 1 deletion libtiledbsoma/src/geometry/operators/io/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Reader<BinaryBuffer> {
return value;
}

std::vector<uint8_t> buffer;
std::vector<std::byte> buffer;
size_t position;
};

Expand Down
4 changes: 2 additions & 2 deletions libtiledbsoma/src/geometry/operators/io/write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ size_t wkb_size(const GenericGeometry& geometry) {
}

WKBWriteOperator::WKBWriteOperator(
uint8_t* buffer, size_t& position, size_t size)
std::byte* buffer, size_t& position, size_t size)
: buffer(buffer)
, position(position)
, size(size) {
Expand Down Expand Up @@ -185,7 +185,7 @@ void WKBWriteOperator::operator()(const GeometryCollection& collection) {
}
}

void to_wkb(const GenericGeometry& geometry, uint8_t* buffer, size_t size) {
void to_wkb(const GenericGeometry& geometry, std::byte* buffer, size_t size) {
size_t position = 0;

std::visit(WKBWriteOperator{buffer, position, size}, geometry);
Expand Down
4 changes: 2 additions & 2 deletions libtiledbsoma/src/geometry/operators/io/write.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct WKBSizeOperator {
};

struct WKBWriteOperator {
WKBWriteOperator(uint8_t* buffer, size_t& position, size_t size);
WKBWriteOperator(std::byte* buffer, size_t& position, size_t size);

template <typename T>
void write(const T& value) {
Expand All @@ -47,7 +47,7 @@ struct WKBWriteOperator {
void operator()(const MultiPolygon& multi_polygon);
void operator()(const GeometryCollection& collection);

uint8_t* buffer;
std::byte* buffer;
size_t& position;
size_t size;
};
Expand Down
5 changes: 1 addition & 4 deletions libtiledbsoma/test/unit_soma_geometry_dataframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,7 @@ TEST_CASE("SOMAGeometryDataFrame: Roundtrip", "[SOMAGeometryDataFrame]") {
CHECK(
std::vector<double_t>({1}) ==
std::vector<double_t>(d4span.begin(), d4span.end()));
auto a = geometry::to_wkb(polygon);
for (size_t i = 0; i < wkbs[0].size(); ++i) {
CHECK(a[i] == (unsigned char)wkbs[0][i]);
}
CHECK(geometry::to_wkb(polygon) == wkbs[0]);
CHECK(
std::vector<double_t>({63}) ==
std::vector<double>(a0span.begin(), a0span.end()));
Expand Down

0 comments on commit 37800f7

Please sign in to comment.