Skip to content

Commit

Permalink
Fix build with Boost 1.86.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed Oct 16, 2024
1 parent 4a027a8 commit 2197375
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 28 deletions.
65 changes: 58 additions & 7 deletions hazelcast/include/hazelcast/client/protocol/ClientMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,36 @@ class HAZELCAST_API ClientMessage
return result;
}

template<typename T>
typename std::enable_if<
std::is_same<T, std::vector<typename T::value_type>>::value &&
std::is_same<std::pair<boost::uuids::uuid,
typename T::value_type::second_type>,
typename T::value_type>::value &&
std::is_trivial<typename T::value_type::second_type>::value,
T>::type
get()
{
T result;

auto f = reinterpret_cast<frame_header_type*>(
rd_ptr(SIZE_OF_FRAME_LENGTH_AND_FLAGS));
auto content_length =
static_cast<int32_t>(f->frame_len) - SIZE_OF_FRAME_LENGTH_AND_FLAGS;
size_t item_count =
content_length /
(ClientMessage::get_sizeof<boost::uuids::uuid>() +
ClientMessage::get_sizeof<typename T::value_type::second_type>());
for (size_t i = 0; i < item_count; ++i) {
auto key = get<boost::uuids::uuid>();
auto value = get<typename T::value_type::second_type>();
result.emplace_back(
std::make_pair(std::move(key), std::move(value)));
}

return result;
}

template<typename T>
typename std::enable_if<
std::is_same<T, std::vector<typename T::value_type>>::value &&
Expand All @@ -642,6 +672,28 @@ class HAZELCAST_API ClientMessage
return result;
}

template<typename T>
typename std::enable_if<
std::is_same<T, std::vector<typename T::value_type>>::value &&
std::is_same<std::pair<boost::uuids::uuid,
typename T::value_type::second_type>,
typename T::value_type>::value &&
!std::is_trivial<typename T::value_type::second_type>::value,
T>::type
get()
{
T result;

auto values = get<std::vector<typename T::value_type::second_type>>();
auto keys = get<std::vector<boost::uuids::uuid>>();

for (size_t i = 0; i < keys.size(); ++i) {
result.emplace_back(std::make_pair(keys[i], std::move(values[i])));
}

return result;
}

template<typename T>
typename std::enable_if<
std::is_same<T,
Expand Down Expand Up @@ -1246,12 +1298,11 @@ class HAZELCAST_API ClientMessage
set(nil);
if (!nil) {
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(uuid.data));
*reinterpret_cast<int64_t*>(&uuid.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(uuid.data +
util::Bits::LONG_SIZE_IN_BYTES));
*reinterpret_cast<int64_t*>(&uuid.data[util::Bits::LONG_SIZE_IN_BYTES]));
std::memcpy(wr_ptr(sizeof(boost::uuids::uuid)),
uuid.data,
&uuid.data[0],
sizeof(boost::uuids::uuid));
} else {
wr_ptr(sizeof(boost::uuids::uuid));
Expand Down Expand Up @@ -1525,13 +1576,13 @@ class HAZELCAST_API ClientMessage
boost::uuids::uuid get_uuid()
{
boost::uuids::uuid u;
memcpy(&u.data,
memcpy(&u.data[0],
rd_ptr(sizeof(boost::uuids::uuid)),
sizeof(boost::uuids::uuid));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(u.data));
*reinterpret_cast<int64_t*>(&u.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(u.data + util::Bits::LONG_SIZE_IN_BYTES));
*reinterpret_cast<int64_t*>(&u.data[util::Bits::LONG_SIZE_IN_BYTES]));
return u;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ class data_input
{
check_available(util::Bits::UUID_SIZE_IN_BYTES);
boost::uuids::uuid u;
std::memcpy(&u.data, &buffer_[pos_], util::Bits::UUID_SIZE_IN_BYTES);
std::memcpy(&u.data[0], &buffer_[pos_], util::Bits::UUID_SIZE_IN_BYTES);
pos_ += util::Bits::UUID_SIZE_IN_BYTES;
if (byte_order_ == boost::endian::order::little) {
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(u.data));
*reinterpret_cast<int64_t*>(&u.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(
&u.data[util::Bits::LONG_SIZE_IN_BYTES]));
Expand Down
17 changes: 1 addition & 16 deletions hazelcast/include/hazelcast/client/spi/impl/ClientInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,7 @@ class HAZELCAST_API ClientInvocation
const std::string& name,
int partition = UNASSIGNED_PARTITION,
const std::shared_ptr<connection::Connection>& conn = nullptr,
boost::uuids::uuid uuid = { 0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0 });
boost::uuids::uuid uuid = {});

void invoke_on_selection();

Expand Down
2 changes: 1 addition & 1 deletion hazelcast/src/hazelcast/client/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ operator<<(std::ostream& os, const ClientMessage& msg)
void
ClientMessage::set(unsigned char* /* memory */, boost::uuids::uuid uuid)
{
std::memcpy(wr_ptr(uuid.size()), uuid.data, uuid.size());
std::memcpy(wr_ptr(uuid.size()), &uuid.data[0], uuid.size());
}

void
Expand Down
4 changes: 2 additions & 2 deletions hazelcast/src/hazelcast/client/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,12 @@ data_output::write(boost::uuids::uuid v)
}
if (byte_order_ == boost::endian::order::little) {
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(v.data));
*reinterpret_cast<int64_t*>(&v.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(&v.data[util::Bits::LONG_SIZE_IN_BYTES]));
}
output_stream_.insert(
output_stream_.end(), v.data, v.data + util::Bits::UUID_SIZE_IN_BYTES);
output_stream_.end(), &v.data[0], &v.data[util::Bits::LONG_SIZE_IN_BYTES]);
}

template<>
Expand Down

0 comments on commit 2197375

Please sign in to comment.