![]() |
Scanframe Modular Application 0.1.0
|
Class for reading and writing ini-profiles. More...
#include <IniProfile.h>

Classes | |
| class | Entry |
| Internal storage class for keys. More... | |
| class | Section |
| Internal storage class for sections. More... | |
Public Types | |
| typedef TVector< Entry * > | EntryVector |
| Internally used type. | |
| typedef EntryVector::size_type | size_type |
| Type definition for the used size. | |
| typedef std::unordered_map< std::string, std::string > | KeyValueMap |
| Type for retrieving key and values. | |
Public Member Functions | |
| IniProfile () | |
| Default constructor for empty instance. | |
| IniProfile (const std::string &path) | |
| Initializing constructor. | |
| IniProfile (const IniProfile &)=delete | |
| Copying this class is not possible. | |
| IniProfile (const IniProfile &&)=delete | |
| No move constructor either. | |
| IniProfile & | operator= (IniProfile &)=delete |
| No copy operator either. | |
| IniProfile & | operator= (IniProfile &&)=delete |
| No move operator either. | |
| IniProfile (const std::string §ion, const std::string &path) | |
| Initializing constructor. If the filename is empty, the startup path is selected. | |
| IniProfile (const std::string_view &data) | |
| Initializing constructor using string. Create by reading from std::istream current position. | |
| IniProfile (std::istream &is) | |
| Initializing constructor. Create by reading from std::istream current position. | |
| virtual | ~IniProfile () |
| Virtual destructor writes to filepath when dirty. | |
| bool | getStringByRef (const std::string &key, std::string &value, const std::string &defaultString={}) const |
| Works the same as TProfile from OWL. | |
| void | flush () |
| Flushes/Removes all sections from this instance. | |
| void | setKeyPrefix (const std::string &prefix={}) |
| Prepends prefix to key if prefix not null. | |
| std::string | getString (const std::string &key, const std::string &defaultString={}) const |
| Gets a string class value. | |
| bool | setString (const std::string &key, const std::string &value) |
| Sets a string class value making the Dirty flag true. | |
| bool | setInt (const std::string &key, int value) |
| Sets an integer value and sets the Dirty flag to true. | |
| int | getInt (const std::string &key, int defaultInt=0) const |
| Gets an integer value. | |
| bool | setFloat (const std::string &key, double value) |
| Gets a boolean value. | |
| double | getFloat (const std::string &key, double defaultFloat=0.0) const |
| Sets a double value and sets the Dirty flag to true. | |
| bool | setBool (const std::string &key, bool value) |
| Sets a boolean value and sets the Dirty flag to true. | |
| bool | getBool (const std::string &key, bool defaultBool=false) const |
| Gets a boolean value. | |
| bool | setSection (const std::string §ion, bool create=true) |
| Sets the current section. | |
| bool | selectSection (const std::string §ion) const |
| bool | setSection (size_type index) |
| Sets the current section by index. | |
| size_type | getSectionCount () const |
| Gets the section count. | |
| std::string | getSection (size_type p=npos) const |
| Gets the current or specific section name where p is the index in the section list. | |
| string_list | getSections () const |
| Get all section names in a std::string vector. | |
| size_type | findSection (const std::string §ion) const |
| Finds current or specific section location in the list. | |
| bool | sectionExists (const std::string §ion) const |
| Returns whether the passed section exists in the profile. | |
| bool | keyExists (const std::string &key) const |
| Returns whether the passed key exists in the current selected in the section of the profile. | |
| bool | removeSection (const std::string §ion) |
| Removes a section by name. | |
| bool | removeSection (size_type p) |
| Removes a section by position. | |
| bool | removeKeys (size_type section=npos) |
| Removes all keys from a section by position or the current selected one if none has been passed. | |
| bool | insertComment (const std::string &key, const std::string &comment) |
| Inserts comment before existing key. | |
| size_type | getEntryCount () const |
| Gets the number of entries in the current section. | |
| size_type | findEntry (const std::string &key) |
| Finds in the current section the key, on failure it returns npos. | |
| std::string | getEntryKey (size_type pos) |
| Gets the value in the current section from the given pos position. In the case of a comment-line, it returns a string of length zero when pos is the index to comment-line. | |
| string_list | getKeys (const std::string §ion) const |
| Gets all keys from the given section. | |
| string_list | getKeys (size_type section=npos) const |
| Gets the keys of the current section or of the passed section index. | |
| void | setMap (const KeyValueMap &map, size_type section=npos) |
| Replaces the section with the given value map. | |
| KeyValueMap | getMap (size_type section=npos) const |
| Gets the key value map from the current selected section by default or the section provided. | |
| std::string | getEntryValue (size_type p) |
| Gets entry value string in the current section by the given pos position. | |
| bool | removeKey (const std::string &key) |
| Removes entry by key name. | |
| bool | removeEntry (size_type p) |
| Removes entry or comment by position. | |
| bool | setFilepath (const std::string &path) |
| Set the path of this instance. When the current dirty-flag has been set, it is first written to disk before loading this file. | |
| const std::string & | getFilepath () const |
| bool | exists () const |
| Checks the existence of the associated file. | |
| void | setWriteOnDirty (bool enable) |
| Set the write-on-dirty flag so changes are written on destruction. The default is true. | |
| bool | sync () |
| Syncs the content to file when the dirty-flag has been set. If the instance was created using a filepath the content is written when the dirty flag was set. | |
| virtual std::ostream & | write (std::ostream &os) const |
| read to std::ostream 'os' current position. | |
| std::ostream & | writeSection (std::ostream &os) const |
| Writes the current section to an 'ostream'. | |
| bool | isDirty () const |
| Tells if there write functions are used or not. | |
| bool | read (std::istream &is) |
| Add sections from other std::istream. | |
Static Public Attributes | |
| static constexpr size_t | npos = EntryVector::npos |
| Index-not-found return value. | |
Protected Types | |
| typedef TVector< Section * > | SectionVector |
| Internally used type. | |
Protected Member Functions | |
| void | initialize () |
| Function called in any constructor. | |
| bool | load (const std::string &filepath) |
| Initialize the base from the filepath. | |
| bool | load (std::istream &is) |
| Initialize the base from the input stream. | |
| Entry * | getEntry (EntryVector::size_type p) |
| Gets nullptr if not exist. | |
Protected Attributes | |
| class _MISC_CLASS | Entry |
| Forward declaration and also having export attributes. | |
| class _MISC_CLASS | Section |
| Forward declaration and also having export attributes. | |
| SectionVector | _sections |
| Vector holding all sections. | |
| SectionVector::size_type | _sectionIndex {npos} |
| Current index to section. | |
| std::string | _path |
| Path to file if it was created with one otherwise 'length' is zero. | |
| bool | _dirty {false} |
| Is Set to true if an entry has been changed. | |
| bool | _flagClearOnRead {true} |
| If this flag is set, all fields read with 'ReadType' will be cleared. | |
| bool | _writeOnDirty {true} |
| When true, the profile is written to the filepath that was used to read it. | |
| std::string | _prefix |
| olds the prefix for all entered 'key's'. | |
Class for reading and writing ini-profiles.
| typedef TVector<Entry*> sf::IniProfile::EntryVector |
Internally used type.
| typedef std::unordered_map<std::string, std::string> sf::IniProfile::KeyValueMap |
Type for retrieving key and values.
|
protected |
Internally used type.
Type definition for the used size.
| sf::IniProfile::IniProfile | ( | ) |
Default constructor for empty instance.
|
explicit |
Initializing constructor.
| path | Filepath to the ini-file. |
|
delete |
Copying this class is not possible.
|
delete |
No move constructor either.
| sf::IniProfile::IniProfile | ( | const std::string & | section, |
| const std::string & | path | ||
| ) |
Initializing constructor. If the filename is empty, the startup path is selected.
|
explicit |
Initializing constructor using string. Create by reading from std::istream current position.
|
explicit |
Initializing constructor. Create by reading from std::istream current position.
|
virtual |
Virtual destructor writes to filepath when dirty.
| bool sf::IniProfile::exists | ( | ) | const |
Checks the existence of the associated file.
| size_type sf::IniProfile::findEntry | ( | const std::string & | key | ) |
Finds in the current section the key, on failure it returns npos.
| size_type sf::IniProfile::findSection | ( | const std::string & | section | ) | const |
Finds current or specific section location in the list.
| void sf::IniProfile::flush | ( | ) |
Flushes/Removes all sections from this instance.
| bool sf::IniProfile::getBool | ( | const std::string & | key, |
| bool | defaultBool = false |
||
| ) | const |
Gets a boolean value.
|
protected |
Gets nullptr if not exist.
| size_type sf::IniProfile::getEntryCount | ( | ) | const |
Gets the number of entries in the current section.
| std::string sf::IniProfile::getEntryKey | ( | size_type | pos | ) |
Gets the value in the current section from the given pos position. In the case of a comment-line, it returns a string of length zero when pos is the index to comment-line.
| std::string sf::IniProfile::getEntryValue | ( | size_type | p | ) |
Gets entry value string in the current section by the given pos position.
| const std::string & sf::IniProfile::getFilepath | ( | ) | const |
Gets the file path when it is set.
| double sf::IniProfile::getFloat | ( | const std::string & | key, |
| double | defaultFloat = 0.0 |
||
| ) | const |
Sets a double value and sets the Dirty flag to true.
| int sf::IniProfile::getInt | ( | const std::string & | key, |
| int | defaultInt = 0 |
||
| ) | const |
Gets an integer value.
| string_list sf::IniProfile::getKeys | ( | const std::string & | section | ) | const |
Gets all keys from the given section.
| section |
| string_list sf::IniProfile::getKeys | ( | size_type | section = npos | ) | const |
| KeyValueMap sf::IniProfile::getMap | ( | size_type | section = npos | ) | const |
Gets the key value map from the current selected section by default or the section provided.
| section | Index of the section (default 'npos' = current) |
Gets the current or specific section name where p is the index in the section list.
| size_type sf::IniProfile::getSectionCount | ( | ) | const |
Gets the section count.
| string_list sf::IniProfile::getSections | ( | ) | const |
Get all section names in a std::string vector.
| std::string sf::IniProfile::getString | ( | const std::string & | key, |
| const std::string & | defaultString = {} |
||
| ) | const |
Gets a string class value.
| bool sf::IniProfile::getStringByRef | ( | const std::string & | key, |
| std::string & | value, | ||
| const std::string & | defaultString = {} |
||
| ) | const |
Works the same as TProfile from OWL.
|
protected |
Function called in any constructor.
| bool sf::IniProfile::insertComment | ( | const std::string & | key, |
| const std::string & | comment | ||
| ) |
Inserts comment before existing key.
|
inline |
Tells if there write functions are used or not.
| bool sf::IniProfile::keyExists | ( | const std::string & | key | ) | const |
Returns whether the passed key exists in the current selected in the section of the profile.
| key | Key name. |
|
protected |
Initialize the base from the filepath.
|
protected |
Initialize the base from the input stream.
|
delete |
No move operator either.
|
delete |
No copy operator either.
| bool sf::IniProfile::read | ( | std::istream & | is | ) |
Add sections from other std::istream.
| bool sf::IniProfile::removeEntry | ( | size_type | p | ) |
Removes entry or comment by position.
| bool sf::IniProfile::removeKey | ( | const std::string & | key | ) |
Removes entry by key name.
Removes all keys from a section by position or the current selected one if none has been passed.
| bool sf::IniProfile::removeSection | ( | const std::string & | section | ) |
Removes a section by name.
| bool sf::IniProfile::removeSection | ( | size_type | p | ) |
Removes a section by position.
| bool sf::IniProfile::sectionExists | ( | const std::string & | section | ) | const |
Returns whether the passed section exists in the profile.
| section | Section name. |
| bool sf::IniProfile::selectSection | ( | const std::string & | section | ) | const |
Selects the section without creating.
| section | Section to set for reading or writing. |
| bool sf::IniProfile::setBool | ( | const std::string & | key, |
| bool | value | ||
| ) |
Sets a boolean value and sets the Dirty flag to true.
| bool sf::IniProfile::setFilepath | ( | const std::string & | path | ) |
Set the path of this instance. When the current dirty-flag has been set, it is first written to disk before loading this file.
| path | Filepath to the ini-file. |
| bool sf::IniProfile::setFloat | ( | const std::string & | key, |
| double | value | ||
| ) |
Gets a boolean value.
| bool sf::IniProfile::setInt | ( | const std::string & | key, |
| int | value | ||
| ) |
Sets an integer value and sets the Dirty flag to true.
| void sf::IniProfile::setKeyPrefix | ( | const std::string & | prefix = {} | ) |
Prepends prefix to key if prefix not null.
| void sf::IniProfile::setMap | ( | const KeyValueMap & | map, |
| size_type | section = npos |
||
| ) |
Replaces the section with the given value map.
| map | Map of keys and values. |
| section | Index of the section (default 'npos' = current) |
| bool sf::IniProfile::setSection | ( | const std::string & | section, |
| bool | create = true |
||
| ) |
Sets the current section.
| section | Section to create. |
| create | When true, it creates the section when it does not exist. |
| bool sf::IniProfile::setSection | ( | size_type | index | ) |
Sets the current section by index.
| index | Section index. |
| bool sf::IniProfile::setString | ( | const std::string & | key, |
| const std::string & | value | ||
| ) |
Sets a string class value making the Dirty flag true.
|
inline |
Set the write-on-dirty flag so changes are written on destruction. The default is true.
| enable |
| bool sf::IniProfile::sync | ( | ) |
Syncs the content to file when the dirty-flag has been set. If the instance was created using a filepath the content is written when the dirty flag was set.
|
virtual |
read to std::ostream 'os' current position.
| std::ostream & sf::IniProfile::writeSection | ( | std::ostream & | os | ) | const |
Writes the current section to an 'ostream'.
|
protected |
Is Set to true if an entry has been changed.
|
protected |
If this flag is set, all fields read with 'ReadType' will be cleared.
|
protected |
Path to file if it was created with one otherwise 'length' is zero.
|
protected |
olds the prefix for all entered 'key's'.
H
|
protected |
Current index to section.
|
protected |
Vector holding all sections.
|
protected |
When true, the profile is written to the filepath that was used to read it.
|
protected |
Forward declaration and also having export attributes.
|
staticconstexpr |
Index-not-found return value.
|
protected |
Forward declaration and also having export attributes.