| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#pragma once |
| 7 |
|
| 8 |
#include <array> |
| 9 |
#include <string> |
| 10 |
#include <string_view> |
| 11 |
|
| 12 |
#include "Common/CommonTypes.h" |
| 13 |
|
| 14 |
namespace Common |
| 15 |
{ |
| 16 |
using SettingsBuffer = std::array<u8, 0x100>; |
| 17 |
|
| 18 |
class SettingsWriter |
| 19 |
{ |
| 20 |
public: |
| 21 |
SettingsWriter(); |
| 22 |
|
| 23 |
void AddSetting(std::string_view key, std::string_view value); |
| 24 |
|
| 25 |
const SettingsBuffer& GetBytes() const; |
| 26 |
|
| 27 |
static std::string GenerateSerialNumber(); |
| 28 |
|
| 29 |
private: |
| 30 |
void WriteLine(std::string_view str); |
| 31 |
void WriteByte(u8 b); |
| 32 |
|
| 33 |
SettingsBuffer m_buffer; |
| 34 |
u32 m_position, m_key; |
| 35 |
}; |
| 36 |
|
| 37 |
class SettingsReader |
| 38 |
{ |
| 39 |
public: |
| 40 |
explicit SettingsReader(const SettingsBuffer& buffer); |
| 41 |
|
| 42 |
std::string GetValue(std::string_view key) const; |
| 43 |
|
| 44 |
private: |
| 45 |
std::string m_decoded; |
| 46 |
}; |
| 47 |
} |