settings.cpp 563 B

123456789101112131415161718192021222324
  1. Settings settings;
  2. auto Settings::serialize() -> string {
  3. string s;
  4. #define write(name) s.append(#name, ": ", name, "\n")
  5. write(createManifests);
  6. write(useDatabase);
  7. write(useHeuristics);
  8. write(recent);
  9. #undef write
  10. return s;
  11. }
  12. auto Settings::unserialize(const string& markup) -> void {
  13. *this = {};
  14. auto s = BML::unserialize(markup);
  15. #define read(name, type) if(auto node = s[#name]) name = node.type()
  16. read(createManifests, boolean);
  17. read(useDatabase, boolean);
  18. read(useHeuristics, boolean);
  19. read(recent, string);
  20. #undef read
  21. }