MRPT  2.0.4
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > Class Template Reference

Detailed Description

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
class mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >

Simple INI file reader.

This can be instantiated with the choice of unicode or native characterset, and case sensitive or insensitive comparisons of section and key names. The supported combinations are pre-defined with the following typedefs:

Interface Case-sensitive Typedef
char No CSimpleIniA
char Yes CSimpleIniCaseA
wchar_t No CSimpleIniW
wchar_t Yes CSimpleIniCaseW

Note that using other types for the SI_CHAR is supported. For instance, unsigned char, unsigned short, etc. Note that where the alternative type is a different size to char/wchar_t you may need to supply new helper classes for SI_STRLESS and SI_CONVERTER.

Definition at line 109 of file SimpleIni.h.

#include <simpleini/SimpleIni.h>

Classes

class  Converter
 Characterset conversion utility class to convert strings to the same format as is used for the storage. More...
 
struct  Entry
 key entry More...
 
class  FileWriter
 OutputWriter class to write the INI data to a file. More...
 
class  OutputWriter
 interface definition for the OutputWriter object to pass to Save() in order to output the INI file data. More...
 
class  StreamWriter
 OutputWriter class to write the INI data to an ostream. More...
 
class  StringWriter
 OutputWriter class to write the INI data to a string. More...
 

Public Types

using TKeyVal = std::multimap< Entry, const SI_CHAR *, typename Entry::KeyOrder >
 map keys to values More...
 
using TSection = std::map< Entry, TKeyVal, typename Entry::KeyOrder >
 map sections to key/value map More...
 
using TNamesDepend = std::list< Entry >
 set of dependent string pointers. More...
 

Public Member Functions

 CSimpleIniTempl (bool a_bMultiKey=false, bool a_bMultiLine=false)
 Default constructor. More...
 
 CSimpleIniTempl (const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > &o)
 Copy. More...
 
CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > & operator= (const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > &o)
 
 ~CSimpleIniTempl ()
 Destructor. More...
 
void Reset ()
 Deallocate all memory stored by this object. More...
 
SI_Error LoadFile (const char *a_pszFile)
 Load an INI file from disk into memory. More...
 
SI_Error LoadFile (const SI_WCHAR_T *a_pwszFile)
 Load an INI file from disk into memory. More...
 
SI_Error LoadFile (FILE *a_fpFile)
 Load the file from a file pointer. More...
 
SI_Error Load (std::istream &a_istream)
 Load INI file data from an istream. More...
 
SI_Error Load (const std::string &a_strData)
 Load INI file data direct from a std::string. More...
 
SI_Error Load (const char *a_pData, size_t a_uDataLen)
 Load INI file data direct from memory. More...
 
SI_Error SaveFile (const char *a_pszFile) const
 Save an INI file from memory to disk. More...
 
SI_Error SaveFile (const SI_WCHAR_T *a_pwszFile) const
 Save an INI file from memory to disk. More...
 
SI_Error SaveFile (FILE *a_pFile) const
 Save the INI data to a file. More...
 
SI_Error Save (OutputWriter &a_oOutput) const
 Save the INI data. More...
 
SI_Error Save (std::ostream &a_ostream) const
 Save the INI data to an ostream. More...
 
SI_Error Save (std::string &a_sBuffer) const
 Append the INI data to a string. More...
 
void GetAllSections (TNamesDepend &a_names) const
 Retrieve all section names. More...
 
bool GetAllKeys (const SI_CHAR *a_pSection, TNamesDepend &a_names) const
 Retrieve all unique key names in a section. More...
 
bool GetAllValues (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, TNamesDepend &a_values) const
 Retrieve all values for a specific key. More...
 
int GetSectionSize (const SI_CHAR *a_pSection) const
 Query the number of keys in a specific section. More...
 
const TKeyValGetSection (const SI_CHAR *a_pSection) const
 Retrieve all key and value pairs for a section. More...
 
const SI_CHAR * GetValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, const SI_CHAR *a_pDefault=nullptr, bool *a_pHasMultiple=nullptr) const
 Retrieve the value for a specific key. More...
 
SI_Error SetValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, const SI_CHAR *a_pValue, const SI_CHAR *a_pComment=nullptr)
 Add or update a section or value. More...
 
bool Delete (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, bool a_bRemoveEmpty=false)
 Delete an entire section, or a key from a section. More...
 
Converter GetConverter () const
 Return a conversion object to convert text to the same encoding as is used by the Save(), SaveFile() and SaveString() functions. More...
 
Settings
void SetMultiKey (bool a_bAllowMultiKey=true)
 Should multiple identical keys be permitted in the file. More...
 
bool IsMultiKey () const
 Get the storage format of the INI data. More...
 
void SetMultiLine (bool a_bAllowMultiLine=true)
 Should data values be permitted to span multiple lines in the file. More...
 
bool IsMultiLine () const
 Query the status of multi-line data. More...
 

Private Member Functions

SI_Error FindFileComment (SI_CHAR *&a_pData, bool a_bCopyStrings)
 Parse the data looking for a file comment and store it if found. More...
 
bool FindEntry (SI_CHAR *&a_pData, const SI_CHAR *&a_pSection, const SI_CHAR *&a_pKey, const SI_CHAR *&a_pVal, const SI_CHAR *&a_pComment) const
 Parse the data looking for the next valid entry. More...
 
SI_Error AddEntry (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, const SI_CHAR *a_pValue, const SI_CHAR *a_pComment, bool a_bCopyStrings)
 Add the section/key/value to our data. More...
 
bool IsSpace (SI_CHAR ch) const
 Is the supplied character a whitespace character? More...
 
bool IsComment (SI_CHAR ch) const
 Does the supplied character start a comment line? More...
 
void SkipNewLine (SI_CHAR *&a_pData) const
 Skip over a newline character (or characters) for either DOS or UNIX. More...
 
SI_Error CopyString (const SI_CHAR *&a_pString)
 Make a copy of the supplied string, replacing the original pointer. More...
 
void DeleteString (const SI_CHAR *a_pString)
 Delete a string from the copied strings buffer if necessary. More...
 
bool IsLess (const SI_CHAR *a_pLeft, const SI_CHAR *a_pRight) const
 Internal use of our string comparison function. More...
 
bool IsMultiLineTag (const SI_CHAR *a_pData) const
 
bool IsMultiLineData (const SI_CHAR *a_pData) const
 
bool LoadMultiLineText (SI_CHAR *&a_pData, const SI_CHAR *&a_pVal, const SI_CHAR *a_pTagName, bool a_bAllowBlankLinesInComment=false) const
 
bool IsNewLineChar (SI_CHAR a_c) const
 
bool OutputMultiLineText (OutputWriter &a_oOutput, Converter &a_oConverter, const SI_CHAR *a_pText) const
 

Private Attributes

SI_CHAR * m_pData
 Copy of the INI file data in our character format. More...
 
size_t m_uDataLen
 Length of the data that we have stored. More...
 
const SI_CHAR * m_pFileComment
 File comment for this data, if one exists. More...
 
TSection m_data
 Parsed INI data. More...
 
TNamesDepend m_strings
 This vector stores allocated memory for copies of strings that have been supplied after the file load. More...
 
bool m_bAllowMultiKey
 Are multiple values permitted for the same key? More...
 
bool m_bAllowMultiLine
 Are data values permitted to span multiple lines? More...
 
int m_nOrder
 Next order value, used to ensure sections and keys are output in the same order that they are loaded/added. More...
 

Member Typedef Documentation

◆ TKeyVal

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
using mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TKeyVal = std::multimap<Entry, const SI_CHAR*, typename Entry::KeyOrder>

map keys to values

Definition at line 171 of file SimpleIni.h.

◆ TNamesDepend

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
using mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TNamesDepend = std::list<Entry>

set of dependent string pointers.

Note that these pointers are dependent on memory owned by CSimpleIni.

Definition at line 179 of file SimpleIni.h.

◆ TSection

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
using mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TSection = std::map<Entry, TKeyVal, typename Entry::KeyOrder>

map sections to key/value map

Definition at line 174 of file SimpleIni.h.

Constructor & Destructor Documentation

◆ CSimpleIniTempl() [1/2]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::CSimpleIniTempl ( bool  a_bMultiKey = false,
bool  a_bMultiLine = false 
)

Default constructor.

Parameters
a_bMultiKeySee the method SetMultiKey() for details.
a_bMultiLineSee the method SetMultiLine() for details.

Definition at line 781 of file SimpleIni.h.

◆ CSimpleIniTempl() [2/2]

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::CSimpleIniTempl ( const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > &  o)
inline

Copy.

Definition at line 285 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load(), and mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save().

Here is the call graph for this function:

◆ ~CSimpleIniTempl()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::~CSimpleIniTempl ( )

Destructor.

Definition at line 793 of file SimpleIni.h.

Member Function Documentation

◆ AddEntry()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::AddEntry ( const SI_CHAR *  a_pSection,
const SI_CHAR *  a_pKey,
const SI_CHAR *  a_pValue,
const SI_CHAR *  a_pComment,
bool  a_bCopyStrings 
)
private

Add the section/key/value to our data.

Parameters
a_pSectionSection name. Sections will be created if they don't already exist.
a_pKeyKey name. May be nullptr to create an empty section. Existing entries will be updated. New entries will be created.
a_pValueValue for the key.
a_pCommentComment to be associated with the section or the key. If a_pKey is nullptr then it will be associated with the section, otherwise the key. This must be a string in full comment form already (have a comment character starting every line).
a_bCopyStringsShould copies of the strings be made or not. If false then the pointers will be used as is.

Definition at line 1377 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Entry::pComment, SI_ASSERT, mrpt::config::simpleini::SI_INSERTED, and mrpt::config::simpleini::SI_UPDATED.

Referenced by mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetValue().

Here is the caller graph for this function:

◆ CopyString()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::CopyString ( const SI_CHAR *&  a_pString)
private

Make a copy of the supplied string, replacing the original pointer.

Definition at line 1347 of file SimpleIni.h.

References mrpt::system::os::memcpy(), mrpt::config::simpleini::SI_NOMEM, and mrpt::config::simpleini::SI_OK.

Here is the call graph for this function:

◆ Delete()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Delete ( const SI_CHAR *  a_pSection,
const SI_CHAR *  a_pKey,
bool  a_bRemoveEmpty = false 
)

Delete an entire section, or a key from a section.

Note that the data returned by GetSection is invalid and must not be used after anything has been deleted from that section using this method. Note when multiple keys is enabled, this will delete all keys with that name; there is no way to selectively delete individual key/values in this situation.

Parameters
a_pSectionSection to delete key from, or if a_pKey is nullptr, the section to remove.
a_pKeyKey to remove from the section. Set to nullptr to remove the entire section.
a_bRemoveEmptyIf the section is empty after this key has been deleted, should the empty section be removed?
Returns
true Key or section was deleted.
false Key or section was not found.

Definition at line 1847 of file SimpleIni.h.

◆ DeleteString()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
void mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::DeleteString ( const SI_CHAR *  a_pString)
private

Delete a string from the copied strings buffer if necessary.

Definition at line 1910 of file SimpleIni.h.

◆ FindEntry()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::FindEntry ( SI_CHAR *&  a_pData,
const SI_CHAR *&  a_pSection,
const SI_CHAR *&  a_pKey,
const SI_CHAR *&  a_pVal,
const SI_CHAR *&  a_pComment 
) const
private

Parse the data looking for the next valid entry.

The memory pointed to by a_pData is modified by inserting nullptr characters. The pointer is updated to the current location in the block of text.

Definition at line 1011 of file SimpleIni.h.

◆ FindFileComment()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::FindFileComment ( SI_CHAR *&  a_pData,
bool  a_bCopyStrings 
)
private

Parse the data looking for a file comment and store it if found.

Definition at line 984 of file SimpleIni.h.

References mrpt::config::simpleini::SI_OK.

◆ GetAllKeys()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetAllKeys ( const SI_CHAR *  a_pSection,
TNamesDepend a_names 
) const

Retrieve all unique key names in a section.

The collation order of the returned strings is NOT DEFINED. Only unique key names are returned.

NOTE! This structure contains only pointers to strings. The actual string data is stored in memory owned by CSimpleIni. Ensure that the CSimpleIni object is not destroyed or Reset() while these strings are in use!

Parameters
a_pSectionSection to request data for
a_namesList that will receive all of the key names. See note above!
Returns
true Section was found.
false Matching section was not found.

Definition at line 1609 of file SimpleIni.h.

◆ GetAllSections()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
void mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetAllSections ( TNamesDepend a_names) const

Retrieve all section names.

The list is returned as an STL vector of names and can be iterated or searched as necessary. Note that the collation order of the returned strings is NOT DEFINED.

NOTE! This structure contains only pointers to strings. The actual string data is stored in memory owned by CSimpleIni. Ensure that the CSimpleIni object is not destroyed or Reset() while these pointers are in use!

Parameters
a_namesVector that will receive all of the section names. See note above!

Definition at line 1598 of file SimpleIni.h.

◆ GetAllValues()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetAllValues ( const SI_CHAR *  a_pSection,
const SI_CHAR *  a_pKey,
TNamesDepend a_values 
) const

Retrieve all values for a specific key.

This method can be used when multiple keys are both enabled and disabled.

NOTE! The returned values are pointers to string data stored in memory owned by CSimpleIni. Ensure that the CSimpleIni object is not destroyed or Reset while you are using this pointer!

Parameters
a_pSectionSection to search
a_pKeyKey to search for
a_valuesList to return if the key is not found
Returns
true Key was found.
false Matching section/key was not found.

Definition at line 1508 of file SimpleIni.h.

◆ GetConverter()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
Converter mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetConverter ( ) const
inline

Return a conversion object to convert text to the same encoding as is used by the Save(), SaveFile() and SaveString() functions.

Use this to prepare the strings that you wish to append or prepend to the output INI data.

Definition at line 658 of file SimpleIni.h.

◆ GetSection()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TKeyVal * mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetSection ( const SI_CHAR *  a_pSection) const

Retrieve all key and value pairs for a section.

The data is returned as a pointer to an STL map and can be iterated or searched as desired. Note that multiple entries for the same key may exist when multiple keys have been enabled.

NOTE! This structure contains only pointers to strings. The actual string data is stored in memory owned by CSimpleIni. Ensure that the CSimpleIni object is not destroyed or Reset() while these strings are in use!

Parameters
a_pSectionName of the section to return
Returns
boolean Was a section matching the supplied name found.

Definition at line 1583 of file SimpleIni.h.

◆ GetSectionSize()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
int mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetSectionSize ( const SI_CHAR *  a_pSection) const

Query the number of keys in a specific section.

Note that if multiple keys are enabled, then this value may be different to the number of keys returned by GetAllKeys.

Parameters
a_pSectionSection to request data for
Returns
-1 Section does not exist in the file
>=0 Number of keys in the section

Definition at line 1544 of file SimpleIni.h.

◆ GetValue()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
const SI_CHAR * mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetValue ( const SI_CHAR *  a_pSection,
const SI_CHAR *  a_pKey,
const SI_CHAR *  a_pDefault = nullptr,
bool *  a_pHasMultiple = nullptr 
) const

Retrieve the value for a specific key.

If multiple keys are enabled (see SetMultiKey) then only the first value associated with that key will be returned, see GetAllValues for getting all values with multikey.

NOTE! The returned value is a pointer to string data stored in memory owned by CSimpleIni. Ensure that the CSimpleIni object is not destroyed or Reset while you are using this pointer!

Parameters
a_pSectionSection to search
a_pKeyKey to search for
a_pDefaultValue to return if the key is not found
a_pHasMultipleOptionally receive notification of if there are multiple entries for this key.
Returns
a_pDefault Key was not found in the section
other Value of the key

Definition at line 1468 of file SimpleIni.h.

◆ IsComment()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsComment ( SI_CHAR  ch) const
inlineprivate

Does the supplied character start a comment line?

Definition at line 703 of file SimpleIni.h.

◆ IsLess()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsLess ( const SI_CHAR *  a_pLeft,
const SI_CHAR *  a_pRight 
) const
inlineprivate

Internal use of our string comparison function.

Definition at line 717 of file SimpleIni.h.

◆ IsMultiKey()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiKey ( ) const
inline

Get the storage format of the INI data.

Definition at line 334 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiKey.

◆ IsMultiLine()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiLine ( ) const
inline

Query the status of multi-line data.

Definition at line 348 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiLine.

◆ IsMultiLineData()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiLineData ( const SI_CHAR *  a_pData) const
private

Definition at line 1170 of file SimpleIni.h.

◆ IsMultiLineTag()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiLineTag ( const SI_CHAR *  a_pData) const
private

Definition at line 1159 of file SimpleIni.h.

◆ IsNewLineChar()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsNewLineChar ( SI_CHAR  a_c) const
private

Definition at line 1210 of file SimpleIni.h.

◆ IsSpace()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsSpace ( SI_CHAR  ch) const
inlineprivate

Is the supplied character a whitespace character?

Definition at line 697 of file SimpleIni.h.

◆ Load() [1/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load ( std::istream &  a_istream)

Load INI file data from an istream.

Parameters
a_istreamStream to read from
Returns
SI_Error See error definitions

Definition at line 969 of file SimpleIni.h.

Referenced by mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::CSimpleIniTempl(), mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load(), and mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::operator=().

Here is the caller graph for this function:

◆ Load() [2/3]

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load ( const std::string &  a_strData)
inline

Load INI file data direct from a std::string.

Parameters
a_strDataData to be loaded
Returns
SI_Error See error definitions

Definition at line 397 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load().

Here is the call graph for this function:

◆ Load() [3/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load ( const char *  a_pData,
size_t  a_uDataLen 
)

Load INI file data direct from memory.

Parameters
a_pDataData to be loaded
a_uDataLenLength of the data in bytes
Returns
SI_Error See error definitions

Definition at line 901 of file SimpleIni.h.

References mrpt::containers::empty(), mrpt::config::simpleini::SI_FAIL, mrpt::config::simpleini::SI_NOMEM, and mrpt::config::simpleini::SI_OK.

Here is the call graph for this function:

◆ LoadFile() [1/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadFile ( const char *  a_pszFile)

Load an INI file from disk into memory.

Parameters
a_pszFilePath of the file to be loaded. This will be passed to fopen() and so must be a valid path for the current platform.
Returns
SI_Error See error definitions

Definition at line 824 of file SimpleIni.h.

References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::config::simpleini::SI_FILE.

Here is the call graph for this function:

◆ LoadFile() [2/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadFile ( const SI_WCHAR_T a_pwszFile)

Load an INI file from disk into memory.

Parameters
a_pwszFilePath of the file to be loaded in UTF-16.
Returns
SI_Error See error definitions

Definition at line 844 of file SimpleIni.h.

References mrpt::system::os::fclose(), and mrpt::config::simpleini::SI_FILE.

Here is the call graph for this function:

◆ LoadFile() [3/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadFile ( FILE *  a_fpFile)

Load the file from a file pointer.

Parameters
a_fpFileValid file pointer to read the file data from. The file will be read until end of file.
Returns
SI_Error See error definitions

Definition at line 867 of file SimpleIni.h.

References mrpt::config::simpleini::SI_FILE, and mrpt::config::simpleini::SI_NOMEM.

◆ LoadMultiLineText()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadMultiLineText ( SI_CHAR *&  a_pData,
const SI_CHAR *&  a_pVal,
const SI_CHAR *  a_pTagName,
bool  a_bAllowBlankLinesInComment = false 
) const
private

Definition at line 1217 of file SimpleIni.h.

References SI_ASSERT.

◆ operator=()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
CSimpleIniTempl<SI_CHAR, SI_STRLESS, SI_CONVERTER>& mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::operator= ( const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > &  o)
inline

Definition at line 292 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load(), and mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save().

Here is the call graph for this function:

◆ OutputMultiLineText()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::OutputMultiLineText ( OutputWriter a_oOutput,
Converter a_oConverter,
const SI_CHAR *  a_pText 
) const
private

◆ Reset()

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
void mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Reset ( )

Deallocate all memory stored by this object.

Definition at line 799 of file SimpleIni.h.

◆ Save() [1/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save ( OutputWriter a_oOutput) const

Save the INI data.

The data will be written to the output device in a format appropriate to the current data, selected by:

SI_CHAR FORMAT
char same format as when loaded (MBCS or UTF-8)
wchar_t UTF-8
other UTF-8

Note that comments, etc from the original data are not preserved. Only valid data contents stored in the file are written out. The order of the sections and values from the original file will be preserved.

Any data prepended or appended to the output device must use the the same format (MBCS or UTF-8). You may use the GetConverter() method to convert text to the correct format regardless of the output format being used by SimpleIni.

To add a BOM to UTF-8 data, write it out manually at the very beginning like is done in SaveFile when a_bUseBOM is true.

Parameters
a_oOutputOutput writer to write the data to.
Returns
SI_Error See error definitions

Definition at line 1682 of file SimpleIni.h.

References mrpt::ros1bridge::convert(), mrpt::config::simpleini::SI_FAIL, SI_NEWLINE_A, mrpt::config::simpleini::SI_OK, and mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::OutputWriter::Write().

Referenced by mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::CSimpleIniTempl(), mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::operator=(), and mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Save() [2/3]

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save ( std::ostream &  a_ostream) const
inline

Save the INI data to an ostream.

See Save() for details.

Parameters
a_ostreamString to have the INI data appended to.
Returns
SI_Error See error definitions

Definition at line 478 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save().

Here is the call graph for this function:

◆ Save() [3/3]

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save ( std::string &  a_sBuffer) const
inline

Append the INI data to a string.

See Save() for details.

Parameters
a_sBufferString to have the INI data appended to.
Returns
SI_Error See error definitions

Definition at line 491 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save().

Here is the call graph for this function:

◆ SaveFile() [1/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SaveFile ( const char *  a_pszFile) const

Save an INI file from memory to disk.

Parameters
a_pszFilePath of the file to be saved. This will be passed to fopen() and so must be a valid path for the current platform.
Returns
SI_Error See error definitions

Definition at line 1639 of file SimpleIni.h.

References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::config::simpleini::SI_FILE.

Here is the call graph for this function:

◆ SaveFile() [2/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SaveFile ( const SI_WCHAR_T a_pwszFile) const

Save an INI file from memory to disk.

Parameters
a_pwszFilePath of the file to be saved in UTF-16.
Returns
SI_Error See error definitions

Definition at line 1656 of file SimpleIni.h.

References mrpt::system::os::fclose(), and mrpt::config::simpleini::SI_FILE.

Here is the call graph for this function:

◆ SaveFile() [3/3]

template<class SI_CHAR , class SI_STRLESS , class SI_CONVERTER >
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SaveFile ( FILE *  a_pFile) const

Save the INI data to a file.

See Save() for details.

Parameters
a_pFileHandle to a file. File should be opened for binary output.
Returns
SI_Error See error definitions

Definition at line 1674 of file SimpleIni.h.

◆ SetMultiKey()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
void mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetMultiKey ( bool  a_bAllowMultiKey = true)
inline

Should multiple identical keys be permitted in the file.

If set to false then the last value encountered will be used as the value of the key. If set to true, then all values will be available to be queried. For example, with the following input:

[section]
test=value1
test=value2

Then with SetMultiKey(true), both of the values "value1" and "value2" will be returned for the key test. If SetMultiKey(false) is used, then the value for "test" will only be "value2". This value may be changed at any time.

Parameters
a_bAllowMultiKeyAllow multi-keys in the source?

Definition at line 328 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiKey.

◆ SetMultiLine()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
void mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetMultiLine ( bool  a_bAllowMultiLine = true)
inline

Should data values be permitted to span multiple lines in the file.

If set to false then the multi-line construct <<<TAG as a value will be returned as is instead of loading the data. This value may be changed at any time.

Parameters
a_bAllowMultiLineAllow multi-line values in the source?

Definition at line 342 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiLine.

◆ SetValue()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
SI_Error mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetValue ( const SI_CHAR *  a_pSection,
const SI_CHAR *  a_pKey,
const SI_CHAR *  a_pValue,
const SI_CHAR *  a_pComment = nullptr 
)
inline

Add or update a section or value.

This will always insert when multiple keys are enabled.

Parameters
a_pSectionSection to add or update
a_pKeyKey to add or update. Set to nullptr to create an empty section.
a_pValueValue to set. Set to nullptr to create an empty section.
a_pCommentComment to be associated with the section or the key. If a_pKey is nullptr then it will be associated with the section, otherwise the key. Note that a comment may be set ONLY when the section or key is first created (i.e. when this function returns the value SI_INSERTED). If you wish to create a section with a comment then you need to create the section separately to the key. The comment string must be in full comment form already (have a comment character starting every line).
Returns
SI_Error See error definitions
SI_UPDATED Value was updated
SI_INSERTED Value was inserted

Definition at line 621 of file SimpleIni.h.

References mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::AddEntry().

Here is the call graph for this function:

◆ SkipNewLine()

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
void mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SkipNewLine ( SI_CHAR *&  a_pData) const
inlineprivate

Skip over a newline character (or characters) for either DOS or UNIX.

Definition at line 705 of file SimpleIni.h.

Member Data Documentation

◆ m_bAllowMultiKey

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiKey
private

◆ m_bAllowMultiLine

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
bool mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiLine
private

◆ m_data

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
TSection mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_data
private

Parsed INI data.

Section -> (Key -> Value).

Definition at line 752 of file SimpleIni.h.

◆ m_nOrder

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
int mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_nOrder
private

Next order value, used to ensure sections and keys are output in the same order that they are loaded/added.

Definition at line 769 of file SimpleIni.h.

◆ m_pData

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
SI_CHAR* mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_pData
private

Copy of the INI file data in our character format.

This will be modified when parsed to have nullptr characters added after all interesting string entries. All of the string pointers to sections, keys and values point into this block of memory.

Definition at line 740 of file SimpleIni.h.

◆ m_pFileComment

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
const SI_CHAR* mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_pFileComment
private

File comment for this data, if one exists.

Definition at line 749 of file SimpleIni.h.

◆ m_strings

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
TNamesDepend mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_strings
private

This vector stores allocated memory for copies of strings that have been supplied after the file load.

It will be empty unless SetValue() has been called.

Definition at line 758 of file SimpleIni.h.

◆ m_uDataLen

template<class SI_CHAR, class SI_STRLESS, class SI_CONVERTER>
size_t mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_uDataLen
private

Length of the data that we have stored.

Used when deleting strings to determine if the string is stored here or in the allocated string buffer.

Definition at line 746 of file SimpleIni.h.




Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020