Enables manipulation with the config file and its settings.
More...
#include <ConfigFile.hpp>
|
| ConfigFile (const std::vector< std::string > &known_names=std::vector< std::string >()) |
| Constructs ConfigFile object. More...
|
|
| ~ConfigFile () |
| Destructs ConfigFile object. More...
|
|
void | open (const std::string &path, bool readonly=false) |
| Opens the config file. More...
|
|
void | write () |
| Writes changes into config file. More...
|
|
void | close () |
| Closes the config file. More...
|
|
void | setSettingValue (const std::string &name, std::string &value) |
| Sets value of given key to a given value. More...
|
|
bool | hasSettingValue (const std::string &name) const |
| Checks if the config file contains key with a given name. More...
|
|
const std::string & | getSettingValue (const std::string &name) const |
| Retreives value of the given key. More...
|
|
Enables manipulation with the config file and its settings.
◆ ConfigFile()
usbguard::ConfigFile::ConfigFile |
( |
const std::vector< std::string > & |
known_names = std::vector<std::string>() | ) |
|
Constructs ConfigFile object.
- Parameters
-
known_names | Names present in this vector will be considered as known key names in the config file. If this vector is empty, then any key name will be considered as known. |
◆ ~ConfigFile()
usbguard::ConfigFile::~ConfigFile |
( |
| ) |
|
|
default |
Destructs ConfigFile object.
Calls close() before destroying ConfigFile object.
- See also
- close()
◆ close()
void usbguard::ConfigFile::close |
( |
| ) |
|
Closes the config file.
If any changes were made and config file was not opened as readonly, changes are written to the config file before stream is closed. If config file is not opened, nothing happens.
◆ getSettingValue()
const std::string & usbguard::ConfigFile::getSettingValue |
( |
const std::string & |
name | ) |
const |
Retreives value of the given key.
- Parameters
-
name | Name of the key to search for. |
- Returns
- Value that is assigned to a given key.
◆ hasSettingValue()
bool usbguard::ConfigFile::hasSettingValue |
( |
const std::string & |
name | ) |
const |
Checks if the config file contains key with a given name.
- Parameters
-
name | Name of the key to search for. |
- Returns
- True if config file contains key with a given name, false otherwise.
◆ open()
void usbguard::ConfigFile::open |
( |
const std::string & |
path, |
|
|
bool |
readonly = false |
|
) |
| |
Opens the config file.
Opens stream to config file and parses the config file.
- Parameters
-
path | Path to the config file. |
readonly | Determines if the config file will be opened in readonly mode. |
◆ setSettingValue()
void usbguard::ConfigFile::setSettingValue |
( |
const std::string & |
name, |
|
|
std::string & |
value |
|
) |
| |
Sets value of given key to a given value.
- Parameters
-
name | Name of the key to set. |
value | Value to set. |
◆ write()
void usbguard::ConfigFile::write |
( |
| ) |
|
Writes changes into config file.
If the config file was not opened or was opened as readonly, then this call will fail.
The documentation for this class was generated from the following files: