26 namespace catapult {
namespace ionet {
29 template<
typename TEntity,
typename TIsVal
idPredicate>
35 <<
"entity (header size = " <<
sizeof(TEntity)
36 <<
") has failed validity check with size " << entity.Size;
43 template<
typename TEntity,
typename TIsVal
idPredicate>
45 using ResultType = std::vector<size_t>;
49 #define CATAPULT_LOG_EXCEEDS_REMAINING_BYTES(SIZE, MESSAGE) \
50 CATAPULT_LOG(warning) << MESSAGE << " (" << SIZE << ") exceeds remaining bytes (" << remainingBytes << ")"
52 std::vector<size_t> offsets;
53 auto remainingBytes = buffer.Size;
54 while (0 != remainingBytes) {
55 if (
sizeof(TEntity) > remainingBytes) {
60 auto offset = buffer.Size - remainingBytes;
61 const auto& entity = reinterpret_cast<const TEntity&>(*(buffer.pData + offset));
65 if (entity.Size > remainingBytes) {
70 offsets.push_back(offset);
71 remainingBytes -= entity.Size;
74 #undef CATAPULT_LOG_EXCEEDS_REMAINING_BYTES
79 #define CATAPULT_LOG_DATA_SIZE_ERROR(SIZE, MESSAGE) \
80 CATAPULT_LOG(warning) << "buffer data size (" << buffer.Size << ") " << MESSAGE << " (" << SIZE << ")"
84 template<
typename TEntity,
typename TIsVal
idPredicate>
89 if (buffer.Size <
sizeof(TEntity)) {
94 const auto& entity = reinterpret_cast<const TEntity&>(*buffer.pData);
98 if (entity.Size != buffer.Size) {
108 template<
typename TStructure>
110 if (0 == buffer.Size)
113 constexpr
auto Structure_Size =
sizeof(TStructure);
114 if (0 != buffer.Size % Structure_Size) {
119 return buffer.Size / Structure_Size;
122 #undef CATAPULT_LOG_DATA_SIZE_ERROR