duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

memory_settings_interface.h (3013B)


      1 // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
      3 
      4 #pragma once
      5 #include "heterogeneous_containers.h"
      6 #include "settings_interface.h"
      7 #include <string>
      8 
      9 class MemorySettingsInterface final : public SettingsInterface
     10 {
     11 public:
     12   MemorySettingsInterface();
     13   ~MemorySettingsInterface() override;
     14 
     15   bool Save(Error* error = nullptr) override;
     16 
     17   void Clear() override;
     18 
     19   bool IsEmpty() override;
     20 
     21   bool GetIntValue(const char* section, const char* key, s32* value) const override;
     22   bool GetUIntValue(const char* section, const char* key, u32* value) const override;
     23   bool GetFloatValue(const char* section, const char* key, float* value) const override;
     24   bool GetDoubleValue(const char* section, const char* key, double* value) const override;
     25   bool GetBoolValue(const char* section, const char* key, bool* value) const override;
     26   bool GetStringValue(const char* section, const char* key, std::string* value) const override;
     27   bool GetStringValue(const char* section, const char* key, SmallStringBase* value) const override;
     28 
     29   void SetIntValue(const char* section, const char* key, s32 value) override;
     30   void SetUIntValue(const char* section, const char* key, u32 value) override;
     31   void SetFloatValue(const char* section, const char* key, float value) override;
     32   void SetDoubleValue(const char* section, const char* key, double value) override;
     33   void SetBoolValue(const char* section, const char* key, bool value) override;
     34   void SetStringValue(const char* section, const char* key, const char* value) override;
     35 
     36   std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
     37   void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
     38 
     39   bool ContainsValue(const char* section, const char* key) const override;
     40   void DeleteValue(const char* section, const char* key) override;
     41   void ClearSection(const char* section) override;
     42   void RemoveSection(const char* section) override;
     43   void RemoveEmptySections() override;
     44 
     45   std::vector<std::string> GetStringList(const char* section, const char* key) const override;
     46   void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
     47   bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
     48   bool AddToStringList(const char* section, const char* key, const char* item) override;
     49 
     50   // default parameter overloads
     51   using SettingsInterface::GetBoolValue;
     52   using SettingsInterface::GetDoubleValue;
     53   using SettingsInterface::GetFloatValue;
     54   using SettingsInterface::GetIntValue;
     55   using SettingsInterface::GetStringValue;
     56   using SettingsInterface::GetUIntValue;
     57 
     58 private:
     59   using KeyMap = PreferUnorderedStringMultimap<std::string>;
     60   using SectionMap = PreferUnorderedStringMap<KeyMap>;
     61 
     62   void SetValue(const char* section, const char* key, std::string value);
     63 
     64   SectionMap m_sections;
     65 };