CatapultServer  v0.5.0.1 (Elephant)
TrailingVariableDataLayout.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include <stdint.h>
23 
24 namespace catapult { namespace model {
25 
26 #pragma pack(push, 1)
27 
30  template<typename TDerived, typename TVariableDataType>
32  public:
34  uint32_t Size;
35 
36  protected:
38  template<typename T>
39  static auto PayloadStart(T& derived) {
40  return derived.Size != TDerived::CalculateRealSize(derived) ? nullptr : ToBytePointer(derived) + sizeof(T);
41  }
42 
44  static const TVariableDataType* ToTypedPointer(const uint8_t* pData) {
45  return reinterpret_cast<const TVariableDataType*>(pData);
46  }
47 
49  static TVariableDataType* ToTypedPointer(uint8_t* pData) {
50  return reinterpret_cast<TVariableDataType*>(pData);
51  }
52 
53  private:
54  static const uint8_t* ToBytePointer(const TDerived& derived) {
55  return reinterpret_cast<const uint8_t*>(&derived);
56  }
57 
58  static uint8_t* ToBytePointer(TDerived& derived) {
59  return reinterpret_cast<uint8_t*>(&derived);
60  }
61  };
62 
63 #pragma pack(pop)
64 }}
catapult::model::TrailingVariableDataLayout::PayloadStart
static auto PayloadStart(T &derived)
Gets the start of the variable data part of derived.
Definition: TrailingVariableDataLayout.h:39
catapult::model::TrailingVariableDataLayout::ToBytePointer
static uint8_t * ToBytePointer(TDerived &derived)
Definition: TrailingVariableDataLayout.h:58
catapult::model::TrailingVariableDataLayout::Size
uint32_t Size
Data size.
Definition: TrailingVariableDataLayout.h:34
catapult::observers::DEFINE_OBSERVER
DEFINE_OBSERVER(AccountAddress, model::AccountAddressNotification, [](const auto &notification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.Address);})
Observers.h
catapult::model::TrailingVariableDataLayout::ToBytePointer
static const uint8_t * ToBytePointer(const TDerived &derived)
Definition: TrailingVariableDataLayout.h:54
catapult::model::TrailingVariableDataLayout::ToTypedPointer
static TVariableDataType * ToTypedPointer(uint8_t *pData)
Gets a typed pointer to the variable data pData.
Definition: TrailingVariableDataLayout.h:49
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::model::TrailingVariableDataLayout::ToTypedPointer
static const TVariableDataType * ToTypedPointer(const uint8_t *pData)
Gets a typed pointer to the variable data pData.
Definition: TrailingVariableDataLayout.h:44
catapult::model::TrailingVariableDataLayout
Definition: TrailingVariableDataLayout.h:31