Overload  1.1
Game engine with editor
Public Types | Public Member Functions | List of all members
OvTools::Filesystem::IniFile Class Referencefinal

#include <IniFile.h>

Public Types

using AttributePair = std::pair< std::string, std::string >
 
using AttributeMap = std::unordered_map< std::string, std::string >
 

Public Member Functions

 IniFile (const std::string &p_filePath)
 
void Reload ()
 
void Rewrite () const
 
template<typename T >
Get (const std::string &p_key)
 
template<typename T >
bool Set (const std::string &p_key, const T &p_value)
 
template<typename T >
bool Add (const std::string &p_key, const T &p_value)
 
bool Remove (const std::string &p_key)
 
void RemoveAll ()
 
bool IsKeyExisting (const std::string &p_key) const
 
std::vector< std::string > GetFormattedContent () const
 

Detailed Description

The IniFile class represents a file .ini that stores a set of attributes/values that can get read and written

Member Typedef Documentation

◆ AttributeMap

using OvTools::Filesystem::IniFile::AttributeMap = std::unordered_map<std::string, std::string>

◆ AttributePair

using OvTools::Filesystem::IniFile::AttributePair = std::pair<std::string, std::string>

Constructor & Destructor Documentation

◆ IniFile()

OvTools::Filesystem::IniFile::IniFile ( const std::string &  p_filePath)

Create an IniFile by parsing the given file path and extracting key/values pairs for future usage

Parameters
p_filePath@project: Overload
Author
: Overload Tech. @restrictions: This software may not be resold, redistributed or otherwise conveyed to a third party.

Member Function Documentation

◆ Add()

template<typename T >
bool OvTools::Filesystem::IniFile::Add ( const std::string &  p_key,
const T &  p_value 
)
inline

Add a new key/value to the IniFile object (Not applied to the real file untill Rewrite() or Save() is called)

Parameters
p_key
p_value

◆ Get()

template<typename T >
T OvTools::Filesystem::IniFile::Get ( const std::string &  p_key)
inline

Return the value attached to the given key If the key doesn't exist, a default value is returned (0, false, "NULL")

Parameters
p_key

◆ GetFormattedContent()

std::vector< std::string > OvTools::Filesystem::IniFile::GetFormattedContent ( ) const

Get the content stored in the ini file as a vector of strings (Each string correspond to an attribute pair : Attribute=Value

◆ IsKeyExisting()

bool OvTools::Filesystem::IniFile::IsKeyExisting ( const std::string &  p_key) const

Verify if the given key exists

Parameters
p_key

◆ Reload()

void OvTools::Filesystem::IniFile::Reload ( )

Overwrite the content of the current data by reloading the file

◆ Remove()

bool OvTools::Filesystem::IniFile::Remove ( const std::string &  p_key)

Remove an key/value pair identified by the given key (Not applied to the real file untill Rewrite() or Save() is called)

Parameters
p_key

◆ RemoveAll()

void OvTools::Filesystem::IniFile::RemoveAll ( )

Remove all key/value pairs (Not applied to the real file untill Rewrite() or Save() is called)

◆ Rewrite()

void OvTools::Filesystem::IniFile::Rewrite ( ) const

Rewrite the entiere .ini file with the current values. This operation is destructive and can't be undone. Any comment or line break in your .ini file will get destroyed

◆ Set()

template<typename T >
bool OvTools::Filesystem::IniFile::Set ( const std::string &  p_key,
const T &  p_value 
)
inline

Set a new value to the given key (Not applied to the real file untill Rewrite() or Save() is called)

Parameters
p_key
p_value

The documentation for this class was generated from the following files: