2015-05-14 10:47:51 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class cSettingsRepositoryInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum errors
|
|
|
|
{
|
|
|
|
noID = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~cSettingsRepositoryInterface() = default;
|
|
|
|
|
2015-05-16 07:46:43 -04:00
|
|
|
/** Returns true iff the specified key exists */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual bool KeyExists(const AString keyname) const = 0;
|
|
|
|
|
2015-05-16 07:46:43 -04:00
|
|
|
/** Returns true iff the specified value exists. */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual bool HasValue(const AString & a_KeyName, const AString & a_ValueName) const = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Add a key name. Return value is not required to mean anything */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual int AddKeyName(const AString & keyname) = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Add a key comment, will always fail if the repository does not support comments */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual bool AddKeyComment(const AString & keyname, const AString & comment) = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Return a key comment, returns "" for repositories that do not return comments */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual AString GetKeyComment(const AString & keyname, const int commentID) const = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Delete a key comment, will always fail if the repository does not support comments */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual bool DeleteKeyComment(const AString & keyname, const int commentID) = 0;
|
|
|
|
|
2015-05-16 07:46:43 -04:00
|
|
|
/** Adds a new value to the specified key.
|
2015-07-31 10:49:10 -04:00
|
|
|
If a value of the same name already exists, creates another one */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual void AddValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value) = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** returns a vector containing a name, value pair for each value under the key */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual std::vector<std::pair<AString, AString>> GetValues(AString a_keyName) = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Get the value at the specified key and value, returns defValue on failure */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual AString GetValue (const AString & keyname, const AString & valuename, const AString & defValue = "") const = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Gets the value; if not found, write the default to the repository */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual AString GetValueSet (const AString & keyname, const AString & valuename, const AString & defValue = "") = 0;
|
|
|
|
virtual int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0) = 0;
|
|
|
|
virtual Int64 GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue = 0) = 0;
|
|
|
|
virtual bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false) = 0;
|
|
|
|
|
2015-05-16 07:46:43 -04:00
|
|
|
/** Overwrites the value of the key, value pair
|
|
|
|
Specify the optional parameter as false if you do not want the value created if it doesn't exist.
|
2015-07-31 10:49:10 -04:00
|
|
|
Returns true if value set, false otherwise. */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual bool SetValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value, const bool a_CreateIfNotExists = true) = 0;
|
|
|
|
virtual bool SetValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value, const bool a_CreateIfNotExists = true) = 0;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Deletes the specified key, value pair */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual bool DeleteValue(const AString & keyname, const AString & valuename) = 0;
|
|
|
|
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Writes the changes to the backing store, if the repository has one */
|
2015-05-14 10:47:51 -04:00
|
|
|
virtual bool Flush() = 0;
|
|
|
|
};
|