OpenM++ runtime library (libopenm)
openm::IniFileReader Class Reference

ini-file reader: load all entries in memory and provide search methods. More...

Public Member Functions

 IniFileReader (const char *i_filePath, const char *i_codePageName=nullptr)
 load all ini-file entries in memory and convert into UTF-8. More...
 
bool isLoaded (void) const noexcept
 return true if ini-file loaded correctly or false on error
 
bool isExist (const char *i_section, const char *i_key) const noexcept
 return true if section and key exist in ini-file.
 
bool isExist (const char *i_sectionKey) const noexcept
 return true if section.key exist in ini-file.
 
const string strValue (const char *i_section, const char *i_key, const string &i_default="") const noexcept
 return string value by section and key or deafult value if not found.
 
const string strValue (const char *i_sectionKey, const string &i_default="") const noexcept
 return string value by section.key or deafult value if not found.
 
const IniEntryVec & rowsCRef (void) const
 return const reference to ini-file entries.
 
const NoCaseSet sectionSet (void) const noexcept
 return names of ini-file sections as case-neutral set of strings.
 
const NoCaseMap getSection (const char *i_section) const noexcept
 return section by name as case-neutral map of (key,value).
 

Static Public Member Functions

static void loadMessages (const char *i_iniMsgPath, const string &i_language="") noexcept
 read language specific messages from path/to/theExe.message.ini and pass it to the log
 

Detailed Description

ini-file reader: load all entries in memory and provide search methods.

Constructor & Destructor Documentation

◆ IniFileReader()

IniFileReader::IniFileReader ( const char *  i_filePath,
const char *  i_codePageName = nullptr 
)

load all ini-file entries in memory and convert into UTF-8.

Parameters
[in]i_filePathpath to ini-file.
[in]i_codePageName(optional) name of encoding or Windows code page, ie: English_US.1252
[in]i_filePathpath to ini-file.
[in]i_codePageName(optional) name of encoding or Windows code page, ie: English_US.1252

Ini file example:

[section] ; section is required, global entries are not allowed

this is also a comment

rem = ; comment only and empty value ; next line is empty value without comment non = val = no comments dsn = "DSN='server'; UID='user'; PWD='secret';" ; comment: database connection string lst = "the # quick" brown 'fox # jumps ; over' # use "quote" and 'apostrophe' to escape characters and keep spaces unb = "unbalanced quote ; this is not a comment: it is a value started from " quote

trim = Aname,Bname, \ ; comment: multi-line value joined with spaces trimmed Cname,DName ; comment: result is: Aname,Bname,Cname,DName

abcd = Aname,Bname, \ ; multi-line value ended with empty line Cname,DName \ ; result is: ; Aname,Bname,Cname,DName

; multi-line value started with " quote or ' apostrophe ; right spaces before \ is not trimmed, result is: ; Multi line text with spaces ; keep = "Multi line \ text with spaces"

; multi-line value started with " quote or ' apostrophe ; result is the same as above: ; Multi line text with spaces ; same = "\ Multi line \ text with spaces\ "


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