settings_upgrade.h 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <cstddef>
  3. #include <span>
  4. #include <string_view>
  5. namespace sunrise::core::settings::upgrade {
  6. /**
  7. * @param document Borrowed settings file text.
  8. * @return True when the document was written against an older layout version.
  9. */
  10. [[nodiscard]] bool needed(std::string_view document) noexcept;
  11. /**
  12. * Rewrites an older settings document onto the current layout. Members whose value form changed
  13. * take the bundled default, and every other member is copied through unchanged.
  14. * @param document Borrowed settings file text.
  15. * @param bundled Borrowed default document holding the replacement members.
  16. * @param output Receives the rewritten document.
  17. * @param written Receives the rewritten length.
  18. * @return True when the whole rewritten document fits the output.
  19. */
  20. [[nodiscard]] bool apply(std::string_view document,
  21. std::string_view bundled,
  22. std::span<char> output,
  23. std::size_t& written) noexcept;
  24. } // namespace sunrise::core::settings::upgrade