2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2012-02-09 21:04:07 -08:00
|
|
|
|
|
|
|
// Thanks to Treeki for writing the original class - 29/01/2012
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-01-27 10:01:25 -05:00
|
|
|
#include <array>
|
2012-02-09 21:04:07 -08:00
|
|
|
#include <string>
|
2019-07-16 04:11:53 -04:00
|
|
|
#include <string_view>
|
2012-02-09 21:04:07 -08:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/CommonTypes.h"
|
2012-02-09 21:04:07 -08:00
|
|
|
|
2018-05-12 13:39:35 -04:00
|
|
|
namespace Common
|
|
|
|
{
|
2024-04-27 20:07:17 -07:00
|
|
|
using SettingsBuffer = std::array<u8, 0x100>;
|
|
|
|
|
|
|
|
class SettingsWriter
|
2012-02-09 21:04:07 -08:00
|
|
|
{
|
|
|
|
public:
|
2024-04-27 20:07:17 -07:00
|
|
|
SettingsWriter();
|
2017-01-27 10:01:25 -05:00
|
|
|
|
2023-12-11 07:53:10 -05:00
|
|
|
void AddSetting(std::string_view key, std::string_view value);
|
2012-02-09 21:04:07 -08:00
|
|
|
|
2024-04-27 20:07:17 -07:00
|
|
|
const SettingsBuffer& GetBytes() const;
|
2012-02-09 21:04:07 -08:00
|
|
|
|
2017-01-27 10:11:36 -05:00
|
|
|
static std::string GenerateSerialNumber();
|
2012-02-09 21:04:07 -08:00
|
|
|
|
|
|
|
private:
|
2023-12-11 07:53:10 -05:00
|
|
|
void WriteLine(std::string_view str);
|
2012-02-09 21:04:07 -08:00
|
|
|
void WriteByte(u8 b);
|
|
|
|
|
2024-04-27 20:07:17 -07:00
|
|
|
SettingsBuffer m_buffer;
|
2012-02-09 21:04:07 -08:00
|
|
|
u32 m_position, m_key;
|
2024-04-27 20:07:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class SettingsReader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit SettingsReader(const SettingsBuffer& buffer);
|
|
|
|
|
|
|
|
std::string GetValue(std::string_view key) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_decoded;
|
2012-02-09 21:04:07 -08:00
|
|
|
};
|
2018-05-12 13:39:35 -04:00
|
|
|
} // namespace Common
|