IniFile

class IniFile

Public Functions

inline void CaseSensitive()

Sets whether or not keynames and valuenames should be case sensitive. The default is case insensitive.

inline void Path(std::string const newPath)

Sets path of ini file to read and write from.

inline std::string Path() const

Return the path of the ini file as a string.

bool ReadFile()

Reads ini file specified using path. Returns true if successful, false otherwise.

bool WriteFile()

Writes data stored in class to ini file.

void Erase()

Deletes all stored ini data.

long FindKey(std::string const keyname) const

Returns index of specified key, or noID if not found.

long FindValue(unsigned const keyID, std::string const valuename) const

Returns index of specified value, in the specified key, or noID if not found.

inline unsigned NumKeys() const

Returns number of keys currently in the ini.

unsigned AddKeyName(std::string const keyname)

Add a key name.

std::string KeyName(unsigned const keyID) const

Returns key names by index.

unsigned NumValues(unsigned const keyID)

Returns number of values stored for specified key ID.

unsigned NumValues(std::string const keyname)

Returns number of values stored for specified keyname.

std::string ValueName(unsigned const keyID, unsigned const valueID) const

Returns value name by index for a given keyname or keyID.

std::string GetValue(unsigned const keyID, unsigned const valueID, std::string const defValue = "") const

Gets value of [keyname] valuename =. Overloaded to return std::string, int, and double. Returns defValue if key/value not found.

unsigned GetValueV(std::string const keyname, std::string const valuename, char *format, void *v1 = 0, void *v2 = 0, void *v3 = 0, void *v4 = 0, void *v5 = 0, void *v6 = 0, void *v7 = 0, void *v8 = 0, void *v9 = 0, void *v10 = 0, void *v11 = 0, void *v12 = 0, void *v13 = 0, void *v14 = 0, void *v15 = 0, void *v16 = 0)

This is a variable length formatted GetValue routine. All these voids are required because there is no vsscanf() like there is a vsprintf(). Only a maximum of 8 variable can be read.

bool SetValue(unsigned const keyID, unsigned const valueID, std::string const value)

Sets value of [keyname] valuename =. Specify the optional paramter as false (0) if you do not want it to create the key if it doesn’t exist. Returns true if data entered, false otherwise. Overloaded to accept std::string, int, and double.

bool DeleteValue(std::string const keyname, std::string const valuename)

Deletes specified value. Returns true if value existed and deleted, false otherwise.

bool DeleteKey(std::string keyname)

Deletes specified key and all values contained within. Returns true if key existed and deleted, false otherwise.

inline unsigned NumHeaderComments()

Number of header comments.

void HeaderComment(std::string const comment)

Add a header comment.

std::string HeaderComment(unsigned const commentID) const

Return a header comment.

bool DeleteHeaderComment(unsigned commentID)

Delete a header comment.

inline void DeleteHeaderComments()

Delete all header comments.

unsigned NumKeyComments(unsigned const keyID) const

Number of key comments.

Key comment functions. Key comments are those comments within a key. Any comments defined within value names will be added to this list. Therefore, these comments will be moved to the top of the key definition when the IniFile::WriteFile() is called.

bool KeyComment(unsigned const keyID, std::string const comment)

Add a key comment.

std::string KeyComment(unsigned const keyID, unsigned const commentID) const

Return a key comment.

bool DeleteKeyComment(unsigned const keyID, unsigned const commentID)

Delete a key comment.

bool DeleteKeyComments(unsigned const keyID)

Delete all comments for a key.