Skip to content

Commit 4df476e

Browse files
committed
Add getOutputMessage() accessor to Statement
Symmetrical with the existing getInputMessage(), provides direct access to the raw output message buffer for consumers that need to read fetched row data at the raw byte level. Closes #42 (REQ-2).
1 parent 3ad2069 commit 4df476e

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/fb-cpp/Statement.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ namespace fbcpp
408408
return outMetadata;
409409
}
410410

411+
///
412+
/// @brief Provides direct access to the raw output message buffer.
413+
///
414+
std::vector<std::byte>& getOutputMessage() noexcept
415+
{
416+
return outMessage;
417+
}
418+
411419
///
412420
/// @brief Returns the type classification reported by the server.
413421
///

src/test/Statement.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,27 @@ BOOST_AUTO_TEST_CASE(descriptorMetadataFields)
325325
BOOST_CHECK(inDescriptors[0].alias.empty());
326326
}
327327

328+
BOOST_AUTO_TEST_CASE(getOutputMessageMatchesMetadataLength)
329+
{
330+
const auto database = getTempFile("Statement-getOutputMessageMatchesMetadataLength.fdb");
331+
332+
Attachment attachment{CLIENT, database, AttachmentOptions().setCreateDatabase(true)};
333+
FbDropDatabase attachmentDrop{attachment};
334+
335+
Transaction transaction{attachment};
336+
Statement stmt{attachment, transaction, "select 42 from rdb$database"};
337+
338+
auto& outMsg = stmt.getOutputMessage();
339+
BOOST_CHECK(!outMsg.empty());
340+
341+
// After fetch, the output message buffer contains the fetched data.
342+
BOOST_REQUIRE(stmt.execute(transaction));
343+
BOOST_CHECK_EQUAL(stmt.getInt32(0).value(), 42);
344+
345+
// The buffer reference should remain the same object.
346+
BOOST_CHECK_EQUAL(&outMsg, &stmt.getOutputMessage());
347+
}
348+
328349
BOOST_AUTO_TEST_SUITE_END()
329350

330351

0 commit comments

Comments
 (0)