mirror of
https://github.com/boostorg/mysql.git
synced 2026-02-15 13:12:21 +00:00
Deserialization now appends to vector
This commit is contained in:
@@ -81,6 +81,7 @@ inline void process_rows(
|
||||
// Process all read messages until they run out, an error happens
|
||||
// or an EOF is received
|
||||
std::size_t num_rows = 0;
|
||||
channel.shared_values().clear();
|
||||
while (channel.num_read_messages())
|
||||
{
|
||||
// Get the row message
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <boost/mysql/detail/protocol/constants.hpp>
|
||||
#include <boost/mysql/detail/protocol/date.hpp>
|
||||
#include <boost/mysql/detail/protocol/bit_deserialization.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace mysql {
|
||||
@@ -371,6 +372,8 @@ inline boost::mysql::error_code boost::mysql::detail::deserialize_binary_row(
|
||||
std::vector<value>& output
|
||||
)
|
||||
{
|
||||
std::size_t old_size = output.size();
|
||||
|
||||
// Skip packet header (it is not part of the message in the binary
|
||||
// protocol but it is in the text protocol, so we include it for homogeneity)
|
||||
// The caller will have checked we have this byte already for us
|
||||
@@ -379,7 +382,7 @@ inline boost::mysql::error_code boost::mysql::detail::deserialize_binary_row(
|
||||
|
||||
// Number of fields
|
||||
auto num_fields = meta.size();
|
||||
output.resize(num_fields);
|
||||
output.resize(old_size + num_fields);
|
||||
|
||||
// Null bitmap
|
||||
null_bitmap_traits null_bitmap (binary_row_null_bitmap_offset, num_fields);
|
||||
@@ -393,11 +396,11 @@ inline boost::mysql::error_code boost::mysql::detail::deserialize_binary_row(
|
||||
{
|
||||
if (null_bitmap.is_null(null_bitmap_begin, i))
|
||||
{
|
||||
output[i] = value(nullptr);
|
||||
output[old_size + i] = value(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto err = deserialize_binary_value(ctx, meta[i], output[i]);
|
||||
auto err = deserialize_binary_value(ctx, meta[i], output[old_size + i]);
|
||||
if (err != errc::ok)
|
||||
return make_error_code(err);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
#include <boost/mysql/detail/protocol/constants.hpp>
|
||||
#include <boost/mysql/detail/protocol/date.hpp>
|
||||
#include <boost/mysql/detail/protocol/bit_deserialization.hpp>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/lexical_cast/try_lexical_convert.hpp>
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning( push )
|
||||
@@ -360,13 +361,14 @@ boost::mysql::error_code boost::mysql::detail::deserialize_text_row(
|
||||
std::vector<value>& output
|
||||
)
|
||||
{
|
||||
output.resize(fields.size());
|
||||
std::size_t old_size = output.size();
|
||||
output.resize(old_size + fields.size());
|
||||
for (std::vector<value>::size_type i = 0; i < fields.size(); ++i)
|
||||
{
|
||||
if (is_next_field_null(ctx))
|
||||
{
|
||||
ctx.advance(1);
|
||||
output[i] = value(nullptr);
|
||||
output[old_size + i] = value(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -374,7 +376,7 @@ boost::mysql::error_code boost::mysql::detail::deserialize_text_row(
|
||||
errc err = deserialize(ctx, value_str);
|
||||
if (err != errc::ok)
|
||||
return make_error_code(err);
|
||||
err = deserialize_text_value(value_str.value, fields[i], output[i]);
|
||||
err = deserialize_text_value(value_str.value, fields[i], output[old_size + i]);
|
||||
if (err != errc::ok)
|
||||
return make_error_code(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user