Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <IniFile.h>
Classes | |
struct | key |
Public Types | |
enum | { noID = Super::noID } |
Public Types inherited from cSettingsRepositoryInterface | |
enum | errors { noID = -1 } |
Public Member Functions | |
void | AddHeaderComment (const AString &comment) |
Adds a header comment. More... | |
bool | AddKeyComment (const AString &keyname, const AString &comment) override |
Add a key comment. More... | |
bool | AddKeyComment (const int keyID, const AString &comment) |
Add a key comment. More... | |
int | AddKeyName (const AString &keyname) override |
Add a key name. More... | |
void | AddValue (const AString &a_KeyName, const AString &a_ValueName, const AString &a_Value) override |
Adds a new value to the specified key. More... | |
void | AddValueB (const AString &a_KeyName, const AString &a_ValueName, const bool a_Value) |
void | AddValueF (const AString &a_KeyName, const AString &a_ValueName, const double a_Value) |
void | AddValueI (const AString &a_KeyName, const AString &a_ValueName, const int a_Value) |
void | CaseInsensitive (void) |
void | CaseSensitive (void) |
cIniFile (void) | |
Creates a new instance with no data. More... | |
void | Clear (void) |
Deletes all stored ini data (but doesn't touch the file) More... | |
bool | DeleteHeaderComment (int commentID) |
Deletes a header comment. More... | |
void | DeleteHeaderComments (void) |
Deletes all header comments. More... | |
bool | DeleteKey (const AString &keyname) |
bool | DeleteKeyComment (const AString &keyname, const int commentID) override |
Delete a key comment, will always fail if the repository does not support comments. More... | |
bool | DeleteKeyComment (const int keyID, const int commentID) |
bool | DeleteKeyComments (const AString &keyname) |
bool | DeleteKeyComments (const int keyID) |
bool | DeleteValue (const AString &keyname, const AString &valuename) override |
Deletes the specified key, value pair. More... | |
bool | DeleteValueByID (const int keyID, const int valueID) |
int | FindKey (const AString &keyname) const |
Returns index of specified key, or noID if not found. More... | |
int | FindValue (const int keyID, const AString &valuename) const |
Returns index of specified value, in the specified key, or noID if not found. More... | |
virtual bool | Flush () override |
Writes the changes to the backing store, if the repository has one. More... | |
AString | GetHeaderComment (const int commentID) const |
Returns a header comment, or empty string if out of range. More... | |
AString | GetKeyComment (const AString &keyname, const int commentID) const override |
Return a key comment, returns "" for repositories that do not return comments. More... | |
AString | GetKeyComment (const int keyID, const int commentID) const |
Return a key comment. More... | |
AString | GetKeyName (const int keyID) const |
int | GetNumHeaderComments (void) |
Returns the number of header comments. More... | |
int | GetNumKeyComments (const AString &keyname) const |
Get number of key comments. More... | |
int | GetNumKeyComments (const int keyID) const |
Get number of key comments. More... | |
int | GetNumKeys (void) const |
Returns number of keys currently in the ini. More... | |
int | GetNumValues (const AString &keyname) const |
int | GetNumValues (const int keyID) const |
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. More... | |
AString | GetValue (const int keyID, const int valueID, const AString &defValue="") const |
bool | GetValueB (const AString &keyname, const AString &valuename, const bool defValue=false) const |
double | GetValueF (const AString &keyname, const AString &valuename, const double defValue=0) const |
int | GetValueI (const AString &keyname, const AString &valuename, const int defValue=0) const |
AString | GetValueName (const AString &keyname, const int valueID) const |
AString | GetValueName (const int keyID, const int valueID) const |
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 More... | |
AString | GetValueSet (const AString &keyname, const AString &valuename, const AString &defValue="") override |
Gets the value; if not found, write the default to the repository. More... | |
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) |
int | GetValueSetI (const AString &keyname, const AString &valuename, const int defValue=0) override |
Int64 | GetValueSetI (const AString &keyname, const AString &valuename, const Int64 defValue=0) override |
bool | HasValue (const AString &a_KeyName, const AString &a_ValueName) const override |
Returns true iff the specified value exists. More... | |
virtual bool | KeyExists (const AString a_keyName) const override |
Returns true iff the specified key exists. More... | |
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 true, tries to read <basename>.example.ini, and writes its contents as <basename>.ini, if successful. More... | |
bool | SetValue (const AString &a_KeyName, const AString &a_ValueName, const AString &a_Value, const bool a_CreateIfNotExists=true) override |
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. More... | |
bool | SetValue (const int keyID, const int valueID, const AString &value) |
bool | SetValueB (const AString &a_KeyName, const AString &a_ValueName, const bool a_Value, const bool a_CreateIfNotExists=true) |
bool | SetValueF (const AString &a_KeyName, const AString &a_ValueName, const double a_Value, const bool a_CreateIfNotExists=true) |
bool | SetValueI (const AString &a_KeyName, const AString &a_ValueName, const int a_Value, const bool a_CreateIfNotExists=true) override |
bool | SetValueI (const AString &a_Keyname, const AString &a_ValueName, const Int64 a_Value, const bool a_CreateIfNotExists=true) |
bool | WriteFile (const AString &a_FileName) const |
Writes data stored in class to the specified ini file. More... | |
Public Member Functions inherited from cSettingsRepositoryInterface | |
cSettingsRepositoryInterface ()=default | |
DISALLOW_COPY_AND_ASSIGN (cSettingsRepositoryInterface) | |
virtual | ~cSettingsRepositoryInterface ()=default |
Private Types | |
using | Super = cSettingsRepositoryInterface |
Private Member Functions | |
AString | CheckCase (const AString &s) const |
If the object is case-insensitive, returns s as lowercase; otherwise returns s as-is. More... | |
void | RemoveBom (AString &a_line) const |
Removes the UTF-8 BOMs (Byte order makers), if present. More... | |
Private Attributes | |
std::vector< AString > | m_Comments |
AString | m_Filename |
bool | m_IsCaseInsensitive |
std::vector< key > | m_Keys |
std::vector< AString > | m_Names |
|
private |
cIniFile::cIniFile | ( | void | ) |
Creates a new instance with no data.
Definition at line 41 of file IniFile.cpp.
void cIniFile::AddHeaderComment | ( | const AString & | comment | ) |
Adds a header comment.
Definition at line 674 of file IniFile.cpp.
Add a key comment.
Implements cSettingsRepositoryInterface.
Definition at line 753 of file IniFile.cpp.
bool cIniFile::AddKeyComment | ( | const int | keyID, |
const AString & | comment | ||
) |
Add a key comment.
Definition at line 739 of file IniFile.cpp.
|
overridevirtual |
Add a key name.
Implements cSettingsRepositoryInterface.
Definition at line 282 of file IniFile.cpp.
|
overridevirtual |
Adds a new value to the specified key.
If a value of the same name already exists, creates another one
Implements cSettingsRepositoryInterface.
Definition at line 363 of file IniFile.cpp.
void cIniFile::AddValueF | ( | const AString & | a_KeyName, |
const AString & | a_ValueName, | ||
const double | a_Value | ||
) |
Definition at line 388 of file IniFile.cpp.
void cIniFile::AddValueI | ( | const AString & | a_KeyName, |
const AString & | a_ValueName, | ||
const int | a_Value | ||
) |
Definition at line 379 of file IniFile.cpp.
If the object is case-insensitive, returns s as lowercase; otherwise returns s as-is.
Definition at line 851 of file IniFile.cpp.
void cIniFile::Clear | ( | void | ) |
Deletes all stored ini data (but doesn't touch the file)
Definition at line 645 of file IniFile.cpp.
bool cIniFile::DeleteHeaderComment | ( | int | commentID | ) |
|
inline |
bool cIniFile::DeleteKey | ( | const AString & | keyname | ) |
Definition at line 625 of file IniFile.cpp.
|
overridevirtual |
Delete a key comment, will always fail if the repository does not support comments.
Implements cSettingsRepositoryInterface.
Definition at line 809 of file IniFile.cpp.
bool cIniFile::DeleteKeyComment | ( | const int | keyID, |
const int | commentID | ||
) |
Definition at line 794 of file IniFile.cpp.
bool cIniFile::DeleteKeyComments | ( | const AString & | keyname | ) |
Definition at line 837 of file IniFile.cpp.
bool cIniFile::DeleteKeyComments | ( | const int | keyID | ) |
Definition at line 823 of file IniFile.cpp.
Deletes the specified key, value pair.
Implements cSettingsRepositoryInterface.
Definition at line 604 of file IniFile.cpp.
bool cIniFile::DeleteValueByID | ( | const int | keyID, |
const int | valueID | ||
) |
Definition at line 586 of file IniFile.cpp.
int cIniFile::FindKey | ( | const AString & | keyname | ) | const |
Returns index of specified key, or noID if not found.
Definition at line 243 of file IniFile.cpp.
int cIniFile::FindValue | ( | const int | keyID, |
const AString & | valuename | ||
) | const |
Returns index of specified value, in the specified key, or noID if not found.
Definition at line 260 of file IniFile.cpp.
|
inlineoverridevirtual |
Writes the changes to the backing store, if the repository has one.
Implements cSettingsRepositoryInterface.
AString cIniFile::GetHeaderComment | ( | const int | commentID | ) | const |
Returns a header comment, or empty string if out of range.
Definition at line 684 of file IniFile.cpp.
|
overridevirtual |
Return a key comment, returns "" for repositories that do not return comments.
Implements cSettingsRepositoryInterface.
Definition at line 780 of file IniFile.cpp.
AString cIniFile::GetKeyComment | ( | const int | keyID, |
const int | commentID | ||
) | const |
Return a key comment.
Definition at line 767 of file IniFile.cpp.
AString cIniFile::GetKeyName | ( | const int | keyID | ) | const |
Definition at line 293 of file IniFile.cpp.
|
inline |
int cIniFile::GetNumKeyComments | ( | const AString & | keyname | ) | const |
Get number of key comments.
Definition at line 725 of file IniFile.cpp.
int cIniFile::GetNumKeyComments | ( | const int | keyID | ) | const |
Get number of key comments.
Definition at line 712 of file IniFile.cpp.
|
inline |
int cIniFile::GetNumValues | ( | const AString & | keyname | ) | const |
Definition at line 322 of file IniFile.cpp.
int cIniFile::GetNumValues | ( | const int | keyID | ) | const |
Definition at line 309 of file IniFile.cpp.
|
overridevirtual |
Get the value at the specified key and value, returns defValue on failure.
Implements cSettingsRepositoryInterface.
Definition at line 485 of file IniFile.cpp.
AString cIniFile::GetValue | ( | const int | keyID, |
const int | valueID, | ||
const AString & | defValue = "" |
||
) | const |
Definition at line 472 of file IniFile.cpp.
double cIniFile::GetValueF | ( | const AString & | keyname, |
const AString & | valuename, | ||
const double | defValue = 0 |
||
) | const |
Definition at line 516 of file IniFile.cpp.
int cIniFile::GetValueI | ( | const AString & | keyname, |
const AString & | valuename, | ||
const int | defValue = 0 |
||
) | const |
Definition at line 506 of file IniFile.cpp.
Definition at line 349 of file IniFile.cpp.
AString cIniFile::GetValueName | ( | const int | keyID, |
const int | valueID | ||
) | const |
Definition at line 336 of file IniFile.cpp.
|
overridevirtual |
returns a vector containing a name, value pair for each value under the key
Implements cSettingsRepositoryInterface.
Definition at line 904 of file IniFile.cpp.
|
overridevirtual |
Gets the value; if not found, write the default to the repository.
Implements cSettingsRepositoryInterface.
Definition at line 526 of file IniFile.cpp.
|
inlineoverridevirtual |
Implements cSettingsRepositoryInterface.
double cIniFile::GetValueSetF | ( | const AString & | keyname, |
const AString & | valuename, | ||
const double | defValue = 0.0 |
||
) |
Definition at line 549 of file IniFile.cpp.
|
overridevirtual |
Implements cSettingsRepositoryInterface.
Definition at line 559 of file IniFile.cpp.
|
overridevirtual |
Implements cSettingsRepositoryInterface.
Definition at line 569 of file IniFile.cpp.
|
overridevirtual |
Returns true iff the specified value exists.
Implements cSettingsRepositoryInterface.
Definition at line 656 of file IniFile.cpp.
|
overridevirtual |
Returns true iff the specified key exists.
Implements cSettingsRepositoryInterface.
Definition at line 895 of file IniFile.cpp.
bool cIniFile::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 true, tries to read <basename>.example.ini, and writes its contents as <basename>.ini, if successful.
Returns true if successful, false otherwise.
Definition at line 50 of file IniFile.cpp.
|
private |
Removes the UTF-8 BOMs (Byte order makers), if present.
Definition at line 870 of file IniFile.cpp.
|
overridevirtual |
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.
Returns true if value set, false otherwise.
Implements cSettingsRepositoryInterface.
Definition at line 411 of file IniFile.cpp.
bool cIniFile::SetValue | ( | const int | keyID, |
const int | valueID, | ||
const AString & | value | ||
) |
Definition at line 397 of file IniFile.cpp.
bool cIniFile::SetValueF | ( | const AString & | a_KeyName, |
const AString & | a_ValueName, | ||
const double | a_Value, | ||
const bool | a_CreateIfNotExists = true |
||
) |
Definition at line 463 of file IniFile.cpp.
|
overridevirtual |
Implements cSettingsRepositoryInterface.
Definition at line 445 of file IniFile.cpp.
bool cIniFile::SetValueI | ( | const AString & | a_Keyname, |
const AString & | a_ValueName, | ||
const Int64 | a_Value, | ||
const bool | a_CreateIfNotExists = true |
||
) |
Definition at line 454 of file IniFile.cpp.
bool cIniFile::WriteFile | ( | const AString & | a_FileName | ) | const |
Writes data stored in class to the specified ini file.
Returns true on success, false on failure.
Definition at line 190 of file IniFile.cpp.