Skip to content

Commit 508b09c

Browse files
committed
Make Row::message a std::span<const std::byte>
1 parent fd787d8 commit 508b09c

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/fb-cpp/Row.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <cstddef>
4040
#include <cstdint>
4141
#include <optional>
42+
#include <span>
4243
#include <stdexcept>
4344
#include <string>
4445
#include <vector>
@@ -69,9 +70,9 @@ namespace fbcpp
6970
///
7071
/// @param client Client used to build conversion helpers.
7172
/// @param descriptors Column descriptors.
72-
/// @param message Pointer to the raw row data.
73+
/// @param message Span over the raw row data.
7374
///
74-
Row(Client& client, const std::vector<Descriptor>& descriptors, const std::byte* message)
75+
Row(Client& client, const std::vector<Descriptor>& descriptors, std::span<const std::byte> message)
7576
: message{message},
7677
descriptors{&descriptors},
7778
client{&client},
@@ -1016,7 +1017,7 @@ namespace fbcpp
10161017
}
10171018

10181019
private:
1019-
const std::byte* message = nullptr;
1020+
std::span<const std::byte> message;
10201021
const std::vector<Descriptor>* descriptors = nullptr;
10211022
Client* client = nullptr;
10221023
impl::StatusWrapper statusWrapper;

src/fb-cpp/RowSet.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ namespace fbcpp
129129
Row getRow(unsigned index)
130130
{
131131
assert(index < count);
132-
const auto* data = buffer.data() + static_cast<std::size_t>(index) * messageLength;
133-
return Row{*client, descriptors, data};
132+
return Row{*client, descriptors, getRawRow(index)};
134133
}
135134

136135
///

src/fb-cpp/Statement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Statement::Statement(
178178
outMetadata.reset(statementHandle->getOutputMetadata(&statusWrapper));
179179
processMetadata(outMetadata, outDescriptors, outMessage);
180180

181-
outRow = std::make_unique<Row>(attachment.getClient(), outDescriptors, outMessage.data());
181+
outRow = std::make_unique<Row>(attachment.getClient(), outDescriptors, std::span{outMessage});
182182
}
183183

184184
void Statement::free()

src/fb-cpp/Statement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ namespace fbcpp
287287
outMetadata{std::move(o.outMetadata)},
288288
outDescriptors{std::move(o.outDescriptors)},
289289
outMessage{std::move(o.outMessage)},
290-
outRow{std::make_unique<Row>(attachment->getClient(), outDescriptors, outMessage.data())},
290+
outRow{std::make_unique<Row>(attachment->getClient(), outDescriptors, std::span{outMessage})},
291291
type{o.type},
292292
cursorFlags{o.cursorFlags}
293293
{
@@ -316,7 +316,7 @@ namespace fbcpp
316316
outMetadata = std::move(o.outMetadata);
317317
outDescriptors = std::move(o.outDescriptors);
318318
outMessage = std::move(o.outMessage);
319-
outRow = std::make_unique<Row>(attachment->getClient(), outDescriptors, outMessage.data());
319+
outRow = std::make_unique<Row>(attachment->getClient(), outDescriptors, std::span{outMessage});
320320
type = o.type;
321321
cursorFlags = o.cursorFlags;
322322

0 commit comments

Comments
 (0)