Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/simpleini.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrodie Thiesfield <brofield@gmail.com>2009-06-09 06:40:32 +0400
committerBrodie Thiesfield <brofield@gmail.com>2009-06-09 06:40:32 +0400
commitf645a20f975db9d9e6a225c10d921658e3d94b33 (patch)
treecc4dacd5a3b53d773ac6b6402937b06788f6ab61
parentdac08620aeb28c49149f0ec063136b5bc0e8dba4 (diff)
* clear the list when calling "GetAll*" functions so that the returned items are only for that call and are not added to
* ensure that GetAllValues returns the comment and load order for that value * when saving the file, ensure that keys with multiple values save each individual comment for each value
-rw-r--r--SimpleIni.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/SimpleIni.h b/SimpleIni.h
index eedb485..6f6ae25 100644
--- a/SimpleIni.h
+++ b/SimpleIni.h
@@ -303,6 +303,11 @@ public:
, pComment(NULL)
, nOrder(a_nOrder)
{ }
+ Entry(const SI_CHAR * a_pszItem, const SI_CHAR * a_pszComment, int a_nOrder)
+ : pItem(a_pszItem)
+ , pComment(a_pszComment)
+ , nOrder(a_nOrder)
+ { }
Entry(const Entry & rhs) { operator=(rhs); }
Entry & operator=(const Entry & rhs) {
pItem = rhs.pItem;
@@ -1982,6 +1987,8 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::GetAllValues(
TNamesDepend & a_values
) const
{
+ a_values.clear();
+
if (!a_pSection || !a_pKey) {
return false;
}
@@ -1995,11 +2002,11 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::GetAllValues(
}
// insert all values for this key
- a_values.push_back(iKeyVal->second);
+ a_values.push_back(Entry(iKeyVal->second, iKeyVal->first.pComment, iKeyVal->first.nOrder));
if (m_bAllowMultiKey) {
++iKeyVal;
while (iKeyVal != iSection->second.end() && !IsLess(a_pKey, iKeyVal->first.pItem)) {
- a_values.push_back(Entry(iKeyVal->second, iKeyVal->first.nOrder));
+ a_values.push_back(Entry(iKeyVal->second, iKeyVal->first.pComment, iKeyVal->first.nOrder));
++iKeyVal;
}
}
@@ -2063,6 +2070,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::GetAllSections(
TNamesDepend & a_names
) const
{
+ a_names.clear();
typename TSection::const_iterator i = m_data.begin();
for (int n = 0; i != m_data.end(); ++i, ++n ) {
a_names.push_back(i->first);
@@ -2076,6 +2084,8 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::GetAllKeys(
TNamesDepend & a_names
) const
{
+ a_names.clear();
+
if (!a_pSection) {
return false;
}
@@ -2232,16 +2242,16 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::Save(
TNamesDepend oValues;
GetAllValues(iSection->pItem, iKey->pItem, oValues);
- // write out the comment if there is one
- if (iKey->pComment) {
- a_oOutput.Write(SI_NEWLINE_A);
- if (!OutputMultiLineText(a_oOutput, convert, iKey->pComment)) {
- return SI_FAIL;
- }
- }
-
typename TNamesDepend::const_iterator iValue = oValues.begin();
for ( ; iValue != oValues.end(); ++iValue) {
+ // write out the comment if there is one
+ if (iValue->pComment) {
+ a_oOutput.Write(SI_NEWLINE_A);
+ if (!OutputMultiLineText(a_oOutput, convert, iValue->pComment)) {
+ return SI_FAIL;
+ }
+ }
+
// write the key
if (!convert.ConvertToStore(iKey->pItem)) {
return SI_FAIL;