CatapultServer  v0.5.0.1 (Elephant)
SizePrefixedEntity.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include <stdint.h>
24 
25 namespace catapult { namespace model {
26 
27 #pragma pack(push, 1)
28 
31  public:
33  uint32_t Size;
34 
35  protected:
37  const uint8_t* ToBytePointer() const;
38 
40  uint8_t* ToBytePointer();
41 
43  template<typename T>
44  static auto PayloadStart(T& entity) {
45  return entity.Size != T::CalculateRealSize(entity) ? nullptr : entity.ToBytePointer() + sizeof(T);
46  }
47 
48  public:
50  bool operator==(const SizePrefixedEntity& rhs) const;
51 
53  bool operator!=(const SizePrefixedEntity& rhs) const;
54  };
55 
56 #pragma pack(pop)
57 }}
catapult::model::SizePrefixedEntity::ToBytePointer
const uint8_t * ToBytePointer() const
Returns byte-based const pointer to this entity.
Definition: SizePrefixedEntity.cpp:26
catapult::model::SizePrefixedEntity::operator!=
bool operator!=(const SizePrefixedEntity &rhs) const
Returns true if this entity is not equal to rhs.
Definition: SizePrefixedEntity.cpp:38
catapult::model::SizePrefixedEntity
Binary layout for a size prefixed entity.
Definition: SizePrefixedEntity.h:30
SizePrefixedEntity.h
catapult::model::SizePrefixedEntity::operator==
bool operator==(const SizePrefixedEntity &rhs) const
Returns true if this entity is equal to rhs.
Definition: SizePrefixedEntity.cpp:34
catapult::model::SizePrefixedEntity::PayloadStart
static auto PayloadStart(T &entity)
Gets the start of the variable data part of entity.
Definition: SizePrefixedEntity.h:44
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::utils::NonCopyable
A class that can neither be copied nor moved.
Definition: NonCopyable.h:26
catapult::model::SizePrefixedEntity::Size
uint32_t Size
Entity size.
Definition: SizePrefixedEntity.h:33
NonCopyable.h