kmessage_codec.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // automatically generated by the FlatBuffers compiler, do not modify
  2. #ifndef FLATBUFFERS_GENERATED_KMESSAGE_KDATA_H_
  3. #define FLATBUFFERS_GENERATED_KMESSAGE_KDATA_H_
  4. #include "flatbuffers/flatbuffers.h"
  5. namespace KData {
  6. struct Message;
  7. struct Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
  8. enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
  9. VT_ID = 4,
  10. VT_DATA = 6
  11. };
  12. int32_t id() const {
  13. return GetField<int32_t>(VT_ID, 0);
  14. }
  15. const flatbuffers::Vector<uint8_t> *data() const {
  16. return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_DATA);
  17. }
  18. bool Verify(flatbuffers::Verifier &verifier) const {
  19. return VerifyTableStart(verifier) &&
  20. VerifyField<int32_t>(verifier, VT_ID) &&
  21. VerifyOffset(verifier, VT_DATA) &&
  22. verifier.VerifyVector(data()) &&
  23. verifier.EndTable();
  24. }
  25. };
  26. struct MessageBuilder {
  27. flatbuffers::FlatBufferBuilder &fbb_;
  28. flatbuffers::uoffset_t start_;
  29. void add_id(int32_t id) {
  30. fbb_.AddElement<int32_t>(Message::VT_ID, id, 0);
  31. }
  32. void add_data(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> data) {
  33. fbb_.AddOffset(Message::VT_DATA, data);
  34. }
  35. explicit MessageBuilder(flatbuffers::FlatBufferBuilder &_fbb)
  36. : fbb_(_fbb) {
  37. start_ = fbb_.StartTable();
  38. }
  39. MessageBuilder &operator=(const MessageBuilder &);
  40. flatbuffers::Offset<Message> Finish() {
  41. const auto end = fbb_.EndTable(start_);
  42. auto o = flatbuffers::Offset<Message>(end);
  43. return o;
  44. }
  45. };
  46. inline flatbuffers::Offset<Message> CreateMessage(
  47. flatbuffers::FlatBufferBuilder &_fbb,
  48. int32_t id = 0,
  49. flatbuffers::Offset<flatbuffers::Vector<uint8_t>> data = 0) {
  50. MessageBuilder builder_(_fbb);
  51. builder_.add_data(data);
  52. builder_.add_id(id);
  53. return builder_.Finish();
  54. }
  55. inline flatbuffers::Offset<Message> CreateMessageDirect(
  56. flatbuffers::FlatBufferBuilder &_fbb,
  57. int32_t id = 0,
  58. const std::vector<uint8_t> *data = nullptr) {
  59. auto data__ = data ? _fbb.CreateVector<uint8_t>(*data) : 0;
  60. return KData::CreateMessage(
  61. _fbb,
  62. id,
  63. data__);
  64. }
  65. inline const KData::Message *GetMessage(const void *buf) {
  66. return flatbuffers::GetRoot<KData::Message>(buf);
  67. }
  68. inline const KData::Message *GetSizePrefixedMessage(const void *buf) {
  69. return flatbuffers::GetSizePrefixedRoot<KData::Message>(buf);
  70. }
  71. inline bool VerifyMessageBuffer(
  72. flatbuffers::Verifier &verifier) {
  73. return verifier.VerifyBuffer<KData::Message>(nullptr);
  74. }
  75. inline bool VerifySizePrefixedMessageBuffer(
  76. flatbuffers::Verifier &verifier) {
  77. return verifier.VerifySizePrefixedBuffer<KData::Message>(nullptr);
  78. }
  79. inline void FinishMessageBuffer(
  80. flatbuffers::FlatBufferBuilder &fbb,
  81. flatbuffers::Offset<KData::Message> root) {
  82. fbb.Finish(root);
  83. }
  84. inline void FinishSizePrefixedMessageBuffer(
  85. flatbuffers::FlatBufferBuilder &fbb,
  86. flatbuffers::Offset<KData::Message> root) {
  87. fbb.FinishSizePrefixed(root);
  88. }
  89. } // namespace KData
  90. #endif // FLATBUFFERS_GENERATED_KMESSAGE_KDATA_H_