Advertisement
Guest User

Untitled

a guest
Dec 8th, 2021
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void WritePerson0(flatbuffers::FlatBufferBuilder& builder)
  2. {
  3. auto pName = builder.CreateString("BiasdasdgFoot");
  4. auto pAge = 91;
  5. auto pWeight = 123.5;
  6.  
  7. auto Person = CreatePerson(builder, pName, pAge, pWeight, Gender_Male);
  8.  
  9. // builder.FinishSizePrefixed(Person);
  10. builder.Finish(Person);
  11. }
  12.  
  13. void WritePerson(flatbuffers::FlatBufferBuilder& builder)
  14. {
  15. auto pName = builder.CreateString("Ram");
  16. auto pAge = 21;
  17. auto pWeight = 76.5;
  18.  
  19. auto Person = CreatePerson(builder, pName, pAge, pWeight, Gender_Male);
  20.  
  21. builder.FinishSizePrefixed(Person);
  22. }
  23.  
  24. int main()
  25. {
  26. flatbuffers::FlatBufferBuilder builder(1024);
  27.  
  28. // Create Person.
  29. WritePerson0(builder);
  30.  
  31. // Create Group.
  32. WritePerson(builder);
  33.  
  34. // Getting ready to the write buffer to a file.
  35. uint8_t *buf = builder.GetBufferPointer();
  36. int size = builder.GetSize();
  37.  
  38. // std::cout << size << "\n";
  39. // Writing to a file.
  40. std::ofstream writer("fb_bytes.bin", std::ios::binary);
  41. writer.write((char*)buf, size);
  42. writer.close();
  43.  
  44. return 0;
  45. }
  46.  
Advertisement
RAW Paste Data Copied
Advertisement