Guest User

Untitled

a guest
Jul 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include "ThorSerialize/YamlThor.h"
  2. #include "ThorSerialize/SerUtil.h"
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. struct InventoryItem {
  7. std::string name;
  8. int baseValue;
  9. float weight;
  10. };
  11. ThorsAnvil_MakeTrait(InventoryItem, name, baseValue, weight);
  12.  
  13. struct Inventory {
  14. float maximumWeight;
  15. std::vector<InventoryItem> items;
  16. };
  17. ThorsAnvil_MakeTrait(Inventory, maximumWeight, items);
  18.  
  19. int main()
  20. {
  21. InventoryItem car {"Audi", 1000000, 12.45};
  22. InventoryItem bike{"pedal", 10, 2.32};
  23. InventoryItem bus {"Big Red", 6789, 45.001};
  24.  
  25. Inventory inventory{200, {car, bike, bus}};
  26.  
  27. std::cout << ThorsAnvil::Serialize::yamlExport(inventory);
  28. }
Add Comment
Please, Sign In to add comment