#include <SimpleIni.h>
Classes | |
class | Converter |
struct | Entry |
class | FileWriter |
class | OutputWriter |
class | StringWriter |
Public Types | |
typedef std::multimap< Entry, const SI_CHAR *, typename Entry::KeyOrder > | TKeyVal |
typedef std::list< Entry > | TNamesDepend |
typedef std::map< Entry, TKeyVal, typename Entry::KeyOrder > | TSection |
Public Member Functions | |
CSimpleIniTempl (bool a_bIsUtf8=false, bool a_bMultiKey=false, bool a_bMultiLine=false) | |
bool | Delete (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, bool a_bRemoveEmpty=false) |
bool | GetAllKeys (const SI_CHAR *a_pSection, TNamesDepend &a_names) const |
void | GetAllSections (TNamesDepend &a_names) const |
bool | GetAllValues (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, TNamesDepend &a_values) const |
bool | GetBoolValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, bool a_bDefault=false, bool *a_pHasMultiple=NULL) const |
Converter | GetConverter () const |
double | GetDoubleValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, double a_nDefault=0, bool *a_pHasMultiple=NULL) const |
long | GetLongValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, long a_nDefault=0, bool *a_pHasMultiple=NULL) const |
const TKeyVal * | GetSection (const SI_CHAR *a_pSection) const |
int | GetSectionSize (const SI_CHAR *a_pSection) const |
const SI_CHAR * | GetValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, const SI_CHAR *a_pDefault=NULL, bool *a_pHasMultiple=NULL) const |
bool | IsEmpty () const |
SI_Error | LoadData (const std::string &a_strData) |
SI_Error | LoadData (const char *a_pData, size_t a_uDataLen) |
SI_Error | LoadFile (const char *a_pszFile) |
SI_Error | LoadFile (FILE *a_fpFile) |
void | Reset () |
SI_Error | Save (OutputWriter &a_oOutput, bool a_bAddSignature=false) const |
SI_Error | Save (std::string &a_sBuffer, bool a_bAddSignature=false) const |
SI_Error | SaveFile (const char *a_pszFile, bool a_bAddSignature=true) const |
SI_Error | SaveFile (FILE *a_pFile, bool a_bAddSignature=false) const |
SI_Error | SetBoolValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, bool a_bValue, const SI_CHAR *a_pComment=NULL, bool a_bForceReplace=false) |
SI_Error | SetDoubleValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, double a_nValue, const SI_CHAR *a_pComment=NULL, bool a_bForceReplace=false) |
SI_Error | SetLongValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, long a_nValue, const SI_CHAR *a_pComment=NULL, bool a_bUseHex=false, bool a_bForceReplace=false) |
SI_Error | SetValue (const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, const SI_CHAR *a_pValue, const SI_CHAR *a_pComment=NULL, bool a_bForceReplace=false) |
~CSimpleIniTempl () | |
Settings | |
void | SetUnicode (bool a_bIsUtf8=true) |
bool | IsUnicode () const |
void | SetMultiKey (bool a_bAllowMultiKey=true) |
bool | IsMultiKey () const |
void | SetMultiLine (bool a_bAllowMultiLine=true) |
bool | IsMultiLine () const |
void | SetSpaces (bool a_bSpaces=true) |
bool | UsingSpaces () const |
Private Member Functions | |
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_bForceReplace, bool a_bCopyStrings) |
SI_Error | CopyString (const SI_CHAR *&a_pString) |
CSimpleIniTempl (const CSimpleIniTempl &) | |
void | DeleteString (const SI_CHAR *a_pString) |
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 |
SI_Error | FindFileComment (SI_CHAR *&a_pData, bool a_bCopyStrings) |
bool | IsComment (SI_CHAR ch) const |
bool | IsLess (const SI_CHAR *a_pLeft, const SI_CHAR *a_pRight) const |
bool | IsMultiLineData (const SI_CHAR *a_pData) const |
bool | IsMultiLineTag (const SI_CHAR *a_pData) const |
bool | IsNewLineChar (SI_CHAR a_c) const |
bool | IsSpace (SI_CHAR ch) const |
bool | LoadMultiLineText (SI_CHAR *&a_pData, const SI_CHAR *&a_pVal, const SI_CHAR *a_pTagName, bool a_bAllowBlankLinesInComment=false) const |
CSimpleIniTempl & | operator= (const CSimpleIniTempl &) |
bool | OutputMultiLineText (OutputWriter &a_oOutput, Converter &a_oConverter, const SI_CHAR *a_pText) const |
void | SkipNewLine (SI_CHAR *&a_pData) const |
Private Attributes | |
bool | m_bAllowMultiKey |
bool | m_bAllowMultiLine |
bool | m_bSpaces |
bool | m_bStoreIsUtf8 |
TSection | m_data |
int | m_nOrder |
SI_CHAR * | m_pData |
const SI_CHAR * | m_pFileComment |
TNamesDepend | m_strings |
size_t | m_uDataLen |
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 293 of file SimpleIni.h.
typedef std::multimap<Entry,const SI_CHAR *,typename Entry::KeyOrder> CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TKeyVal |
map keys to values
Definition at line 346 of file SimpleIni.h.
typedef std::list<Entry> CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TNamesDepend |
set of dependent string pointers. Note that these pointers are dependent on memory owned by CSimpleIni.
Definition at line 354 of file SimpleIni.h.
typedef std::map<Entry,TKeyVal,typename Entry::KeyOrder> CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TSection |
map sections to key/value map
Definition at line 349 of file SimpleIni.h.
CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::CSimpleIniTempl | ( | bool | a_bIsUtf8 = false , |
bool | a_bMultiKey = false , |
||
bool | a_bMultiLine = false |
||
) |
Default constructor.
a_bIsUtf8 | See the method SetUnicode() for details. |
a_bMultiKey | See the method SetMultiKey() for details. |
a_bMultiLine | See the method SetMultiLine() for details. |
Definition at line 1249 of file SimpleIni.h.
CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::~CSimpleIniTempl | ( | ) |
Destructor
Definition at line 1265 of file SimpleIni.h.
CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::CSimpleIniTempl | ( | const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > & | ) | [private] |
SI_Error 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_bForceReplace, | ||
bool | a_bCopyStrings | ||
) | [private] |
Add the section/key/value to our data.
a_pSection | Section name. Sections will be created if they don't already exist. |
a_pKey | Key name. May be NULL to create an empty section. Existing entries will be updated. New entries will be created. |
a_pValue | Value for the key. |
a_pComment | Comment to be associated with the section or the key. If a_pKey is NULL 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_bForceReplace | Should all existing values in a multi-key INI file be replaced with this entry. This option has no effect if not using multi-key files. The difference between Delete/AddEntry and AddEntry with a_bForceReplace = true, is that the load order and comment will be preserved this way. |
a_bCopyStrings | Should copies of the strings be made or not. If false then the pointers will be used as is. |
Definition at line 1840 of file SimpleIni.h.
SI_Error 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 1813 of file SimpleIni.h.
bool 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.
a_pSection | Section to delete key from, or if a_pKey is NULL, the section to remove. |
a_pKey | Key to remove from the section. Set to NULL to remove the entire section. |
a_bRemoveEmpty | If the section is empty after this key has been deleted, should the empty section be removed? |
Definition at line 2518 of file SimpleIni.h.
void 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 2578 of file SimpleIni.h.
bool 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 NULL characters. The pointer is updated to the current location in the block of text.
Definition at line 1497 of file SimpleIni.h.
SI_Error 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 1470 of file SimpleIni.h.
bool 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 sort order of the returned strings is NOT DEFINED. You can sort the names into the load order if desired. Search this file for ".sort" for an example. 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!
a_pSection | Section to request data for |
a_names | List that will receive all of the key names. See note above! |
Definition at line 2274 of file SimpleIni.h.
void 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 sort order of the returned strings is NOT DEFINED. You can sort the names into the load order if desired. Search this file for ".sort" for an example.
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!
a_names | Vector that will receive all of the section names. See note above! |
Definition at line 2261 of file SimpleIni.h.
bool 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 that the sort order of the returned strings is NOT DEFINED. You can sort the names into the load order if desired. Search this file for ".sort" for an example.
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!
a_pSection | Section to search |
a_pKey | Key to search for |
a_values | List to return if the key is not found |
Definition at line 2176 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetBoolValue | ( | const SI_CHAR * | a_pSection, |
const SI_CHAR * | a_pKey, | ||
bool | a_bDefault = false , |
||
bool * | a_pHasMultiple = NULL |
||
) | const |
Retrieve a boolean 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.
Strings starting with "t", "y", "on" or "1" are returned as logically true. Strings starting with "f", "n", "of" or "0" are returned as logically false. For all other values the default is returned. Character comparisons are case-insensitive.
a_pSection | Section to search |
a_pKey | Key to search for |
a_bDefault | Value to return if the key is not found |
a_pHasMultiple | Optionally receive notification of if there are multiple entries for this key. |
Definition at line 2115 of file SimpleIni.h.
Converter 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 1090 of file SimpleIni.h.
double CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetDoubleValue | ( | const SI_CHAR * | a_pSection, |
const SI_CHAR * | a_pKey, | ||
double | a_nDefault = 0 , |
||
bool * | a_pHasMultiple = NULL |
||
) | const |
Retrieve a numeric 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.
a_pSection | Section to search |
a_pKey | Key to search for |
a_nDefault | Value to return if the key is not found |
a_pHasMultiple | Optionally receive notification of if there are multiple entries for this key. |
Definition at line 2053 of file SimpleIni.h.
long CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetLongValue | ( | const SI_CHAR * | a_pSection, |
const SI_CHAR * | a_pKey, | ||
long | a_nDefault = 0 , |
||
bool * | a_pHasMultiple = NULL |
||
) | const |
Retrieve a numeric 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.
a_pSection | Section to search |
a_pKey | Key to search for |
a_nDefault | Value to return if the key is not found |
a_pHasMultiple | Optionally receive notification of if there are multiple entries for this key. |
Definition at line 1982 of file SimpleIni.h.
const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::TKeyVal * 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!
a_pSection | Name of the section to return |
Definition at line 2246 of file SimpleIni.h.
int 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.
a_pSection | Section to request data for |
Definition at line 2211 of file SimpleIni.h.
const SI_CHAR * CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::GetValue | ( | const SI_CHAR * | a_pSection, |
const SI_CHAR * | a_pKey, | ||
const SI_CHAR * | a_pDefault = NULL , |
||
bool * | a_pHasMultiple = NULL |
||
) | 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!
a_pSection | Section to search |
a_pKey | Key to search for |
a_pDefault | Value to return if the key is not found |
a_pHasMultiple | Optionally receive notification of if there are multiple entries for this key. |
Definition at line 1945 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsComment | ( | SI_CHAR | ch | ) | const [inline, private] |
Does the supplied character start a comment line?
Definition at line 1158 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsEmpty | ( | ) | const [inline] |
Has any data been loaded
Definition at line 463 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsLess | ( | const SI_CHAR * | a_pLeft, |
const SI_CHAR * | a_pRight | ||
) | const [inline, private] |
Internal use of our string comparison function
Definition at line 1175 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiKey | ( | ) | const [inline] |
Get the storage format of the INI data.
Definition at line 512 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiLine | ( | ) | const [inline] |
Query the status of multi-line data
Definition at line 526 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiLineData | ( | const SI_CHAR * | a_pData | ) | const [private] |
Definition at line 1643 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsMultiLineTag | ( | const SI_CHAR * | a_pData | ) | const [private] |
Definition at line 1630 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsNewLineChar | ( | SI_CHAR | a_c | ) | const [private] |
Definition at line 1680 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsSpace | ( | SI_CHAR | ch | ) | const [inline, private] |
Is the supplied character a whitespace character?
Definition at line 1153 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::IsUnicode | ( | ) | const [inline] |
Get the storage format of the INI data.
Definition at line 487 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadData | ( | const std::string & | a_strData | ) | [inline] |
Load INI file data direct from a std::string
a_strData | Data to be loaded |
Definition at line 597 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadData | ( | const char * | a_pData, |
size_t | a_uDataLen | ||
) |
Load INI file data direct from memory
a_pData | Data to be loaded |
a_uDataLen | Length of the data in bytes |
Definition at line 1376 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadFile | ( | const char * | a_pszFile | ) |
Load an INI file from disk into memory
a_pszFile | Path of the file to be loaded. This will be passed to fopen() and so must be a valid path for the current platform. |
Definition at line 1295 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::LoadFile | ( | FILE * | a_fpFile | ) |
Load the file from a file pointer.
a_fpFile | Valid file pointer to read the file data from. The file will be read until end of file. |
Definition at line 1341 of file SimpleIni.h.
bool 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 1689 of file SimpleIni.h.
CSimpleIniTempl& CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::operator= | ( | const CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER > & | ) | [private] |
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::OutputMultiLineText | ( | OutputWriter & | a_oOutput, |
Converter & | a_oConverter, | ||
const SI_CHAR * | a_pText | ||
) | const [private] |
Definition at line 2489 of file SimpleIni.h.
void CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Reset | ( | ) |
Deallocate all memory stored by this object
Definition at line 1272 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save | ( | OutputWriter & | a_oOutput, |
bool | a_bAddSignature = false |
||
) | 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 from the original data is preserved as per the documentation on comments. 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.
a_oOutput | Output writer to write the data to. |
a_bAddSignature | Prepend the UTF-8 BOM if the output data is in UTF-8 format. If it is not UTF-8 then this value is ignored. Do not set this to true if anything has already been written to the OutputWriter. |
Definition at line 2362 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Save | ( | std::string & | a_sBuffer, |
bool | a_bAddSignature = false |
||
) | const [inline] |
Append the INI data to a string. See Save() for details.
a_sBuffer | String to have the INI data appended to. |
a_bAddSignature | Prepend the UTF-8 BOM if the output data is in UTF-8 format. If it is not UTF-8 then this value is ignored. Do not set this to true if anything has already been written to the string. |
Definition at line 736 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SaveFile | ( | const char * | a_pszFile, |
bool | a_bAddSignature = true |
||
) | const |
Save an INI file from memory to disk
a_pszFile | Path of the file to be saved. This will be passed to fopen() and so must be a valid path for the current platform. |
a_bAddSignature | Prepend the UTF-8 BOM if the output data is in UTF-8 format. If it is not UTF-8 then this parameter is ignored. |
Definition at line 2305 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SaveFile | ( | FILE * | a_pFile, |
bool | a_bAddSignature = false |
||
) | const |
Save the INI data to a file. See Save() for details.
a_pFile | Handle to a file. File should be opened for binary output. |
a_bAddSignature | Prepend the UTF-8 BOM if the output data is in UTF-8 format. If it is not UTF-8 then this value is ignored. Do not set this to true if anything has already been written to the file. |
Definition at line 2351 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetBoolValue | ( | const SI_CHAR * | a_pSection, |
const SI_CHAR * | a_pKey, | ||
bool | a_bValue, | ||
const SI_CHAR * | a_pComment = NULL , |
||
bool | a_bForceReplace = false |
||
) |
Add or update a boolean value. This will always insert when multiple keys are enabled.
a_pSection | Section to add or update |
a_pKey | Key to add or update. |
a_bValue | Value to set. |
a_pComment | Comment to be associated with the key. See the notes on SetValue() for comments. |
a_bForceReplace | Should all existing values in a multi-key INI file be replaced with this entry. This option has no effect if not using multi-key files. The difference between Delete/SetBoolValue and SetBoolValue with a_bForceReplace = true, is that the load order and comment will be preserved this way. |
Definition at line 2150 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetDoubleValue | ( | const SI_CHAR * | a_pSection, |
const SI_CHAR * | a_pKey, | ||
double | a_nValue, | ||
const SI_CHAR * | a_pComment = NULL , |
||
bool | a_bForceReplace = false |
||
) |
Add or update a double value. This will always insert when multiple keys are enabled.
a_pSection | Section to add or update |
a_pKey | Key to add or update. |
a_nValue | Value to set. |
a_pComment | Comment to be associated with the key. See the notes on SetValue() for comments. |
a_bForceReplace | Should all existing values in a multi-key INI file be replaced with this entry. This option has no effect if not using multi-key files. The difference between Delete/SetDoubleValue and SetDoubleValue with a_bForceReplace = true, is that the load order and comment will be preserved this way. |
Definition at line 2084 of file SimpleIni.h.
SI_Error CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetLongValue | ( | const SI_CHAR * | a_pSection, |
const SI_CHAR * | a_pKey, | ||
long | a_nValue, | ||
const SI_CHAR * | a_pComment = NULL , |
||
bool | a_bUseHex = false , |
||
bool | a_bForceReplace = false |
||
) |
Add or update a numeric value. This will always insert when multiple keys are enabled.
a_pSection | Section to add or update |
a_pKey | Key to add or update. |
a_nValue | Value to set. |
a_pComment | Comment to be associated with the key. See the notes on SetValue() for comments. |
a_bUseHex | By default the value will be written to the file in decimal format. Set this to true to write it as hexadecimal. |
a_bForceReplace | Should all existing values in a multi-key INI file be replaced with this entry. This option has no effect if not using multi-key files. The difference between Delete/SetLongValue and SetLongValue with a_bForceReplace = true, is that the load order and comment will be preserved this way. |
Definition at line 2021 of file SimpleIni.h.
void 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.
a_bAllowMultiKey | Allow multi-keys in the source? |
Definition at line 507 of file SimpleIni.h.
void 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.
a_bAllowMultiLine | Allow multi-line values in the source? |
Definition at line 521 of file SimpleIni.h.
void CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetSpaces | ( | bool | a_bSpaces = true | ) | [inline] |
Should spaces be added around the equals sign when writing key/value pairs out. When true, the result will be "key = value". When false, the result will be "key=value". This value may be changed at any time.
a_bSpaces | Add spaces around the equals sign? |
Definition at line 534 of file SimpleIni.h.
void CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SetUnicode | ( | bool | a_bIsUtf8 = true | ) | [inline] |
Set the storage format of the INI data. This affects both the loading and saving of the INI data using all of the Load/Save API functions. This value cannot be changed after any INI data has been loaded.
If the file is not set to Unicode (UTF-8), then the data encoding is assumed to be the OS native encoding. This encoding is the system locale on Linux/Unix and the legacy MBCS encoding on Windows NT/2K/XP. If the storage format is set to Unicode then the file will be loaded as UTF-8 encoded data regardless of the native file encoding. If SI_CHAR == char then all of the char* parameters take and return UTF-8 encoded data regardless of the system locale.
a_bIsUtf8 | Assume UTF-8 encoding for the source? |
Definition at line 482 of file SimpleIni.h.
SI_Error 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 = NULL , |
||
bool | a_bForceReplace = false |
||
) | [inline] |
Add or update a section or value. This will always insert when multiple keys are enabled.
a_pSection | Section to add or update |
a_pKey | Key to add or update. Set to NULL to create an empty section. |
a_pValue | Value to set. Set to NULL to create an empty section. |
a_pComment | Comment to be associated with the section or the key. If a_pKey is NULL 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). |
a_bForceReplace | Should all existing values in a multi-key INI file be replaced with this entry. This option has no effect if not using multi-key files. The difference between Delete/SetValue and SetValue with a_bForceReplace = true, is that the load order and comment will be preserved this way. |
Definition at line 959 of file SimpleIni.h.
void CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::SkipNewLine | ( | SI_CHAR *& | a_pData | ) | const [inline, private] |
Skip over a newline character (or characters) for either DOS or UNIX
Definition at line 1164 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::UsingSpaces | ( | ) | const [inline] |
Query the status of spaces output
Definition at line 539 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiKey [private] |
Are multiple values permitted for the same key?
Definition at line 1226 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bAllowMultiLine [private] |
Are data values permitted to span multiple lines?
Definition at line 1229 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bSpaces [private] |
Should spaces be written out surrounding the equals sign?
Definition at line 1232 of file SimpleIni.h.
bool CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_bStoreIsUtf8 [private] |
Is the format of our datafile UTF-8 or MBCS?
Definition at line 1223 of file SimpleIni.h.
TSection CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_data [private] |
Parsed INI data. Section -> (Key -> Value).
Definition at line 1214 of file SimpleIni.h.
int 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 1237 of file SimpleIni.h.
SI_CHAR* 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 NULL 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 1202 of file SimpleIni.h.
const SI_CHAR* CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::m_pFileComment [private] |
File comment for this data, if one exists.
Definition at line 1211 of file SimpleIni.h.
TNamesDepend 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 1220 of file SimpleIni.h.
size_t 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 1208 of file SimpleIni.h.