|
GlobalObjects
|
An INI file contains information for programs. More...
#include <IniFile.h>
Public Member Functions | |
| File () | |
| File (const std::string &rsFullFileName, TdOpenInifileMode openMode) | |
| virtual | ~File () |
| int | getAsBlob (eut::Blob *&prBlob) |
| std::string | getFileName () |
| int | getKeyValue (std::string &rsValue, std::string *psSection, std::string *psKey) |
| int | getLine (Line *&prRetVal, std::size_t nPosition, ptl::SeekMode eMode) |
| int | getLine (Line *&prRetVal, std::string *psSection, std::string *psKey=0) |
| int | insertLine (Line *pIniLine, ptl::InsertPosition eInsertPosition=ptl::InsertCURRENT, ptl::VH eBeforeBehind=ptl::BEHIND) |
| int | makeLines (eut::Blob *pBlob) |
| int | refresh () |
| int | removeKey (const std::string &rsSection, const std::string &rsKey) |
| int | removeLine (ptl::ElementPosition eFirstLastCurrent=ptl::CURRENT_POS) |
| void | setFullFileName (const std::string &rsFullFileName) |
| int | setKeyValue (const std::string &rsSection, const std::string &rsKey, const std::string &rsValue) |
| int | store () |
Private Member Functions | |
| File (const File &) | |
| File & | operator= (const File &) |
Private Attributes | |
| LineFactory | m_LineFactory |
| ptl::TDVList< Line > | m_LineList |
| std::string | m_sFileName |
An INI file contains information for programs.
An INI file can contain sections with variables and values and comments. The information can be created, read and maintained with ini::File.
In the following an INI file "test.ini" is created:
The INI file "test.ini" has the following contents:
In the INI file "test.ini" the key "Key 1.2" is fetched from the section "[Section 1]", displayed and changed to "new Value":
The INI file "test.ini" now has the following content:
All entries can be identified...
... and results in the following output:
| ini::File::File | ( | const std::string & | rsFullFileName, |
| TdOpenInifileMode | openMode ) |
Constructor with parameter passing.
| [in] | rsFullFileName | The complete file name such as: "c:\windows\system.ini" |
| [in] | openMode | If openMode is ini::bCreateInifile, then an attempt is made to generate a new INI-file. If openMode is ini::bOpenInifile, then an attempt is made to read in the INI-file with the specified name. |
| eut::ErrorNException | An exception is thrown if an error occurs. |
Referenced by File(), and operator=().
| ini::File::File | ( | ) |
Default constructor.
|
virtual |
Destructor, memory is released.
| int ini::File::getAsBlob | ( | eut::Blob *& | prBlob | ) |
Returns all entries of the file in one blob.
| [in,out] | prBlob | The File as blob. |
| std::string ini::File::getFileName | ( | ) |
Returns the name of the INI file.
| int ini::File::getKeyValue | ( | std::string & | rsValue, |
| std::string * | psSection, | ||
| std::string * | psKey ) |
Returns a KeyValue.
| [in,out] | rsValue | The found KeyValue as std::string. |
| [in] | psSection | |
| [in] | psKey | See psSection. |
If there should be the following entry in an INI file:
returns this function when calling:
in rsValue "app850.fon" back.
| int ini::File::getLine | ( | Line *& | prRetVal, |
| std::size_t | nPosition, | ||
| ptl::SeekMode | eMode ) |
Returns an Line from the m_LineList with respect to the pass parameters.
| [in,out] | prRetVal | passed reference into which the found object "comes in" |
| [in] | nPosition | Offset relative to... |
| [in] | eMode | ...Position |
Parameter examples:
| int ini::File::getLine | ( | Line *& | prRetVal, |
| std::string * | psSection, | ||
| std::string * | psKey = 0 ) |
Returns a section or a key.
| [in,out] | prRetVal | If found, depending on the other parameters a pointer to an object of type Section or Key. |
| [in] | psSection | |
| [in] | psKey | See psSection. |
| int ini::File::insertLine | ( | Line * | pIniLine, |
| ptl::InsertPosition | eInsertPosition = ptl::InsertCURRENT, | ||
| ptl::VH | eBeforeBehind = ptl::BEHIND ) |
Inserts the transferred entry into the m_LineList.
| [in] | pIniLine | The object of the class Line to be inserted |
| [in] | eInsertPosition | Shows where the data object is inserted in the list is to be inserted. Possible parameters are ptl::InsertHEAD (on Start), ptl::InsertLAST (at the end) or ptl::InsertCURRENT (at the current element). |
| [in] | eBeforeBehind | Specifies whether the new element is before or after the, element specified in the eInsertPosition parameter. Possible Parameters are BEHIND and BEFORE |
References ptl::BEHIND, and ptl::InsertCURRENT.
| int ini::File::makeLines | ( | eut::Blob * | pBlob | ) |
Creates the individual entries in the INI file from the blob passed.
| [in] | pBlob | The blob with the contents of an INI file. The blob is evaluated and all entries are created. |
Assignment operator is not available.
References File().
| int ini::File::refresh | ( | ) |
The INI file from m_sFileName is read in.
| int ini::File::removeKey | ( | const std::string & | rsSection, |
| const std::string & | rsKey ) |
Removes an entry
| [in] | rsSection | Section |
| [in] | rsKey | entry |
Removes an entry as follows:
| int ini::File::removeLine | ( | ptl::ElementPosition | eFirstLastCurrent = ptl::CURRENT_POS | ) |
Removes the entry from the m_LineList.
If a subsequent element exists, it becomes the current element, otherwise the previous element if it exists. The destructor is called from the removed entry.
| [in] | eFirstLastCurrent | The following values are possible: ptl::FIRST_POS, ptl::LAST_POS, (default) ptl::CURRENT_POS, ptl::NEXT_POS and ptl::PREVIOUS_POS. |
References ptl::CURRENT_POS.
| void ini::File::setFullFileName | ( | const std::string & | rsFullFileName | ) |
Sets the name of the INI file.
| [in] | rsFullFileName | The complete file name such as: "c:\windows\system.ini" |
| int ini::File::setKeyValue | ( | const std::string & | rsSection, |
| const std::string & | rsKey, | ||
| const std::string & | rsValue ) |
Sets an entry
| [in] | rsSection | The section either with '[' and ']' or without these two characters. |
| [in] | rsKey | The entry |
| [in] | rsValue | The value |
Sets an entry like this:
| int ini::File::store | ( | ) |
The INI file from m_sFileName is saved.
|
private |
The LineFactory returns an INI file entry according to type.
|
private |
List of entries in this INI file.
|
private |
The name of the INI file is stored in this attribute.