23 #define MAX_KEYNAME 128
24 #define MAX_VALUENAME 128
25 #define MAX_VALUEDATA 2048
81 virtual std::vector<std::pair<AString, AString>>
GetValues(
AString a_keyName)
override;
96 bool ReadFile(
const AString & a_FileName,
bool a_AllowExampleRedirect =
true);
142 return (
GetValueI(keyname, valuename, defValue ? 1 : 0) != 0);
152 return (
GetValueSetI(keyname, valuename, defValue ? 1 : 0) != 0);
161 return AddValueI(a_KeyName, a_ValueName, a_Value ? 1 : 0);
169 bool SetValue (
const int keyID,
const int valueID,
const AString & value);
170 bool SetValue (
const AString & a_KeyName,
const AString & a_ValueName,
const AString & a_Value,
const bool a_CreateIfNotExists =
true)
override;
171 bool SetValueI(
const AString & a_KeyName,
const AString & a_ValueName,
const int a_Value,
const bool a_CreateIfNotExists =
true)
override;
173 bool SetValueB(
const AString & a_KeyName,
const AString & a_ValueName,
const bool a_Value,
const bool a_CreateIfNotExists =
true)
175 return SetValueI(a_KeyName, a_ValueName,
int(a_Value), a_CreateIfNotExists);
177 bool SetValueF(
const AString & a_KeyName,
const AString & a_ValueName,
const double a_Value,
const bool a_CreateIfNotExists =
true);
251 const AString & a_PortsValueName,
252 const AString & a_OldIPv4ValueName,
253 const AString & a_OldIPv6ValueName,
AStringVector ReadUpgradeIniPorts(cSettingsRepositoryInterface &a_Settings, const AString &a_KeyName, const AString &a_PortsValueName, const AString &a_OldIPv4ValueName, const AString &a_OldIPv6ValueName, const AString &a_DefaultValue)
Reads the list of ports from the INI file, possibly upgrading from IPv4 / IPv6-specific values into n...
std::vector< AString > AStringVector
AString GetHeaderComment(const int commentID) const
Returns a header comment, or empty string if out of range.
void RemoveBom(AString &a_line) const
Removes the UTF-8 BOMs (Byte order makers), if present.
bool DeleteValueByID(const int keyID, const int valueID)
void AddValueB(const AString &a_KeyName, const AString &a_ValueName, const bool a_Value)
void DeleteHeaderComments(void)
Deletes all header comments.
bool HasValue(const AString &a_KeyName, const AString &a_ValueName) const override
Returns true iff the specified value exists.
int AddKeyName(const AString &keyname) override
Add a key name.
AString GetKeyName(const int keyID) const
bool DeleteKeyComments(const int keyID)
int FindKey(const AString &keyname) const
Returns index of specified key, or noID if not found.
AString GetValue(const AString &keyname, const AString &valuename, const AString &defValue="") const override
Get the value at the specified key and value, returns defValue on failure.
bool WriteFile(const AString &a_FileName) const
Writes data stored in class to the specified ini file.
bool AddKeyComment(const int keyID, const AString &comment)
Add a key comment.
std::vector< AString > m_Comments
int GetNumValues(const AString &keyname) const
bool DeleteValue(const AString &keyname, const AString &valuename) override
Deletes the specified key, value pair.
bool ReadFile(const AString &a_FileName, bool a_AllowExampleRedirect=true)
Reads the contents of the specified ini file If the file doesn't exist and a_AllowExampleRedirect is ...
bool SetValueF(const AString &a_KeyName, const AString &a_ValueName, const double a_Value, const bool a_CreateIfNotExists=true)
void CaseInsensitive(void)
virtual bool KeyExists(const AString a_keyName) const override
Returns true iff the specified key exists.
void Clear(void)
Deletes all stored ini data (but doesn't touch the file)
bool SetValueB(const AString &a_KeyName, const AString &a_ValueName, const bool a_Value, const bool a_CreateIfNotExists=true)
int GetNumHeaderComments(void)
Returns the number of header comments.
virtual std::vector< std::pair< AString, AString > > GetValues(AString a_keyName) override
returns a vector containing a name, value pair for each value under the key
AString GetValueName(const AString &keyname, const int valueID) const
virtual bool Flush() override
Writes the changes to the backing store, if the repository has one.
void AddValue(const AString &a_KeyName, const AString &a_ValueName, const AString &a_Value) override
Adds a new value to the specified key.
int GetValueI(const AString &keyname, const AString &valuename, const int defValue=0) const
bool DeleteKeyComment(const int keyID, const int commentID)
void AddHeaderComment(const AString &comment)
Adds a header comment.
int GetValueSetI(const AString &keyname, const AString &valuename, const int defValue=0) override
bool DeleteKey(const AString &keyname)
cIniFile(void)
Creates a new instance with no data.
bool GetValueB(const AString &keyname, const AString &valuename, const bool defValue=false) const
void AddValueF(const AString &a_KeyName, const AString &a_ValueName, const double a_Value)
bool SetValueI(const AString &a_KeyName, const AString &a_ValueName, const int a_Value, const bool a_CreateIfNotExists=true) override
bool SetValue(const int keyID, const int valueID, const AString &value)
AString GetValueSet(const AString &keyname, const AString &valuename, const AString &defValue="") override
Gets the value; if not found, write the default to the repository.
std::vector< AString > m_Names
bool DeleteHeaderComment(int commentID)
Deletes a header comment.
void AddValueI(const AString &a_KeyName, const AString &a_ValueName, const int a_Value)
int GetNumKeys(void) const
Returns number of keys currently in the ini.
int GetNumKeyComments(const int keyID) const
Get number of key comments.
bool GetValueSetB(const AString &keyname, const AString &valuename, const bool defValue=false) override
double GetValueSetF(const AString &keyname, const AString &valuename, const double defValue=0.0)
double GetValueF(const AString &keyname, const AString &valuename, const double defValue=0) const
std::vector< key > m_Keys
AString CheckCase(const AString &s) const
If the object is case-insensitive, returns s as lowercase; otherwise returns s as-is.
int FindValue(const int keyID, const AString &valuename) const
Returns index of specified value, in the specified key, or noID if not found.
AString GetKeyComment(const int keyID, const int commentID) const
Return a key comment.
std::vector< AString > m_Names
std::vector< AString > m_Comments
std::vector< AString > m_Values
cSettingsRepositoryInterface()=default