diff options
Diffstat (limited to 'src/MemorySettingsRepository.h')
-rw-r--r-- | src/MemorySettingsRepository.h | 115 |
1 files changed, 66 insertions, 49 deletions
diff --git a/src/MemorySettingsRepository.h b/src/MemorySettingsRepository.h index a2dec8548..b4fa5ed0c 100644 --- a/src/MemorySettingsRepository.h +++ b/src/MemorySettingsRepository.h @@ -5,8 +5,7 @@ class cMemorySettingsRepository : public cSettingsRepositoryInterface { -public: - + public: virtual bool KeyExists(const AString keyname) const override; virtual bool HasValue(const AString & a_KeyName, const AString & a_ValueName) const override; @@ -19,76 +18,95 @@ public: virtual bool DeleteKeyComment(const AString & keyname, const int commentID) override; - virtual void AddValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value) override; - void AddValue (const AString & a_KeyName, const AString & a_ValueName, const Int64 a_Value); - void AddValue (const AString & a_KeyName, const AString & a_ValueName, const bool a_Value); + virtual void AddValue(const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value) override; + void AddValue(const AString & a_KeyName, const AString & a_ValueName, const Int64 a_Value); + void AddValue(const AString & a_KeyName, const AString & a_ValueName, const bool a_Value); virtual std::vector<std::pair<AString, AString>> GetValues(AString a_keyName) override; - virtual AString GetValue (const AString & keyname, const AString & valuename, const AString & defValue = "") const override; - - - virtual AString GetValueSet (const AString & keyname, const AString & valuename, const AString & defValue = "") override; - virtual int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0) override; - virtual Int64 GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue = 0) override; - virtual bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false) override; - - virtual bool SetValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value, const bool a_CreateIfNotExists = true) override; - virtual bool SetValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value, const bool a_CreateIfNotExists = true) override; + virtual AString GetValue(const AString & keyname, const AString & valuename, const AString & defValue = "") + const override; + + + virtual AString GetValueSet(const AString & keyname, const AString & valuename, const AString & defValue = "") + override; + virtual int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0) override; + virtual Int64 GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue = 0) override; + virtual bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false) override; + + virtual bool SetValue( + const AString & a_KeyName, + const AString & a_ValueName, + const AString & a_Value, + const bool a_CreateIfNotExists = true + ) override; + virtual bool SetValueI( + const AString & a_KeyName, + const AString & a_ValueName, + const int a_Value, + const bool a_CreateIfNotExists = true + ) override; virtual bool DeleteValue(const AString & keyname, const AString & valuename) override; virtual bool Flush() override; - void SetReadOnly() - { - m_Writable = false; - } - -private: + void SetReadOnly() { m_Writable = false; } + private: bool m_Writable = true; struct sValue { - sValue(AString value): - #ifndef NDEBUG - m_Type(eType::String), - #endif - m_stringValue (std::move(value)) + sValue(AString value) : +#ifndef NDEBUG + m_Type(eType::String), +#endif + m_stringValue(std::move(value)) { } - sValue(Int64 value): - #ifndef NDEBUG - m_Type(eType::Int64), - #endif + sValue(Int64 value) : +#ifndef NDEBUG + m_Type(eType::Int64), +#endif m_intValue(value) { } - sValue(bool value): - #ifndef NDEBUG - m_Type(eType::Bool), - #endif + sValue(bool value) : +#ifndef NDEBUG + m_Type(eType::Bool), +#endif m_boolValue(value) { } - AString getStringValue() const { ASSERT(m_Type == eType::String); return m_stringValue; } - Int64 getIntValue() const { ASSERT(m_Type == eType::Int64); return m_intValue; } - bool getBoolValue() const { ASSERT(m_Type == eType::Bool); return m_boolValue; } - - private: + AString getStringValue() const + { + ASSERT(m_Type == eType::String); + return m_stringValue; + } + Int64 getIntValue() const + { + ASSERT(m_Type == eType::Int64); + return m_intValue; + } + bool getBoolValue() const + { + ASSERT(m_Type == eType::Bool); + return m_boolValue; + } - #ifndef NDEBUG - enum class eType - { - String, - Int64, - Bool - } m_Type; - #endif + private: +#ifndef NDEBUG + enum class eType + { + String, + Int64, + Bool + } m_Type; +#endif AString m_stringValue; union @@ -98,6 +116,5 @@ private: }; }; - std::unordered_map<AString, std::unordered_multimap<AString, sValue>> m_Map{}; + std::unordered_map<AString, std::unordered_multimap<AString, sValue>> m_Map {}; }; - |