SettingsHandler.h 865 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2008 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. // Thanks to Treeki for writing the original class - 29/01/2012
  4. #pragma once
  5. #include <array>
  6. #include <string>
  7. #include <string_view>
  8. #include "Common/CommonTypes.h"
  9. namespace Common
  10. {
  11. using SettingsBuffer = std::array<u8, 0x100>;
  12. class SettingsWriter
  13. {
  14. public:
  15. SettingsWriter();
  16. void AddSetting(std::string_view key, std::string_view value);
  17. const SettingsBuffer& GetBytes() const;
  18. static std::string GenerateSerialNumber();
  19. private:
  20. void WriteLine(std::string_view str);
  21. void WriteByte(u8 b);
  22. SettingsBuffer m_buffer;
  23. u32 m_position, m_key;
  24. };
  25. class SettingsReader
  26. {
  27. public:
  28. explicit SettingsReader(const SettingsBuffer& buffer);
  29. std::string GetValue(std::string_view key) const;
  30. private:
  31. std::string m_decoded;
  32. };
  33. } // namespace Common