Container for Preference instances.
More...
#include <PrefContainer.h>
Container for Preference instances.
A PrefContainer is very similar to a PropertyContainer. What sets them apart is that a PrefContainer can load/save its contents from/to a file on the disk. In addition, a PrefContainer is convertible to a PropertyContainer
Definition at line 42 of file PrefContainer.h.
◆ addPref()
bool ime::PrefContainer::addPref |
( |
const Preference & |
pref | ) |
|
Add a preference to the container.
- Parameters
-
pref | The preference to be added |
- Returns
- True if the preference was added or false if a preference with the same key already exits in the container
◆ asPropertyContainer()
Convert preference to properties.
- Returns
- Preferences as properties
- Attention
- This function was released in IME v2.1.0 and is intended for compatibility with previous release (IME v2.0.0). In IME v2.1.0, ime::utility::ConfigFileParser is deprecated and replaced by ime::PrefContainer, thus you can load configs with ime::PrefContainer and use this function to convert ime::PrefContainer into ime::PropertyContainer which was returned by ime::utility::ConfigFileParser without the need to change your code to work with ime::PrefContainer instances.
◆ clear()
void ime::PrefContainer::clear |
( |
| ) |
|
Remove all preferences from the container.
◆ getCount()
std::size_t ime::PrefContainer::getCount |
( |
| ) |
const |
Get the number of preferences in the container.
- Returns
- The number of preferences in the container
◆ getPref()
Preference & ime::PrefContainer::getPref |
( |
const std::string & |
key | ) |
|
Get a preference.
- Parameters
-
key | The key of the preference to retrieve |
- Returns
- A preference with the specified key
◆ hasPref()
bool ime::PrefContainer::hasPref |
( |
const std::string & |
key | ) |
|
Check if the container has a preference or not.
- Parameters
-
key | The key of the preference to be checked |
- Returns
- True if the preference exist, otherwise false
◆ load()
void ime::PrefContainer::load |
( |
const std::string & |
filename | ) |
|
Load preferences from the disk.
- Parameters
-
filename | The name of the file to load the preferences from |
- Exceptions
-
- Note
- All current data is destroyed on subsequent function calls
- See also
- save
◆ removePref()
void ime::PrefContainer::removePref |
( |
const std::string & |
key | ) |
|
Remove a preference from the container.
- Parameters
-
key | The key of the preference to be removed |
◆ save()
void ime::PrefContainer::save |
( |
const std::string & |
filename = "sameAsLoadFile" | ) |
|
Save preferences to the disk.
- Parameters
-
filename | The name of the file to save the preferences to |
- Exceptions
-
If filename is left unspecified, the engine will attempt to write the data to the same file as the load file.
- Warning
- This function will overwrite the file
- See also
- load
The documentation for this class was generated from the following file: