@@ -12,21 +12,21 @@ Profile::Profile(const std::wstring& path)
1212 Init ();
1313}
1414
15- bool Profile::ReadValue (const std::wstring& section, const std::wstring& key, int & retVal) const
15+ bool Profile::ReadValue (const std::wstring& section, const std::wstring& key, int & retVal, int defaultVal ) const
1616{
17- retVal = GetPrivateProfileInt (section.c_str (), key.c_str (), 0 , m_ProfileFilePath.c_str ());
17+ retVal = GetPrivateProfileInt (section.c_str (), key.c_str (), defaultVal , m_ProfileFilePath.c_str ());
1818
1919 return true ;
2020}
2121
22- bool Profile::ReadValue (const std::wstring& section, const std::wstring& key, std::wstring& retVal) const
22+ bool Profile::ReadValue (const std::wstring& section, const std::wstring& key, std::wstring& retVal, const std::wstring& defaultVal ) const
2323{
2424 bool bRetVal = false ;
2525
2626 // Try with MAX_PATH
2727 constexpr DWORD nBufSize = MAX_PATH * 2 ;
2828 auto pData = std::make_unique<TCHAR[]>(nBufSize);
29- GetPrivateProfileString (section.c_str (), key.c_str (), nullptr , pData.get (), nBufSize, m_ProfileFilePath.c_str ());
29+ GetPrivateProfileString (section.c_str (), key.c_str (), defaultVal. c_str () , pData.get (), nBufSize, m_ProfileFilePath.c_str ());
3030
3131 if (pData)
3232 {
@@ -76,27 +76,35 @@ bool ProfileSetting::GetSettings(Setting& info) const
7676 int nVal = 0 ;
7777 bRetVal &= ReadValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_EOL, nVal);
7878 if (bRetVal)
79- info.le = static_cast <LineEnding>(nVal);
79+ info.lineEnding = static_cast <LineEnding>(nVal);
8080
8181 bRetVal &= ReadValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_LINE, nVal);
8282 if (bRetVal)
83- info.lf = static_cast <LineFormat>(nVal);
83+ info.lineFormat = static_cast <LineFormat>(nVal);
8484
8585 bRetVal &= ReadValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_INDENT, nVal);
8686 if (bRetVal)
8787 info.indent .style = static_cast <IndentStyle>(nVal);
8888
89- bRetVal &= ReadValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_INDENTCOUNT, nVal);
89+ bRetVal &= ReadValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_INDENTCOUNT, nVal, info. indent . len );
9090 if (bRetVal)
9191 info.indent .len = nVal;
9292
9393 bRetVal &= ReadValue (STR_INI_OTHER_SEC, STR_INI_OTHER_FOLLOW_TAB, nVal);
9494 if (bRetVal)
95- info.follow_current_tab = static_cast <bool >(nVal);
95+ info.bFollowCurrentTab = static_cast <bool >(nVal);
9696
9797 bRetVal &= ReadValue (STR_INI_OTHER_SEC, STR_INI_OTHER_AUTO_FORMAT, nVal);
9898 if (bRetVal)
99- info.auto_format_on_open = static_cast <bool >(nVal);
99+ info.bAutoFormat = static_cast <bool >(nVal);
100+
101+ bRetVal &= ReadValue (STR_INI_OTHER_SEC, STR_INI_OTHER_IGNORE_COMMENT, nVal, info.parseOptions .bIgnoreComment );
102+ if (bRetVal)
103+ info.parseOptions .bIgnoreComment = static_cast <bool >(nVal);
104+
105+ bRetVal &= ReadValue (STR_INI_OTHER_SEC, STR_INI_OTHER_IGNORE_COMMA, nVal, info.parseOptions .bIgnoreTraillingComma );
106+ if (bRetVal)
107+ info.parseOptions .bIgnoreTraillingComma = static_cast <bool >(nVal);
100108
101109 return bRetVal;
102110}
@@ -105,12 +113,15 @@ bool ProfileSetting::SetSettings(const Setting& info) const
105113{
106114 bool bRetVal = true ;
107115
108- bRetVal &= WriteValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_EOL, static_cast <int >(info.le ));
109- bRetVal &= WriteValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_LINE, static_cast <int >(info.lf ));
116+ bRetVal &= WriteValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_EOL, static_cast <int >(info.lineEnding ));
117+ bRetVal &= WriteValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_LINE, static_cast <int >(info.lineFormat ));
110118 bRetVal &= WriteValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_INDENT, static_cast <int >(info.indent .style ));
111119 bRetVal &= WriteValue (STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_INDENTCOUNT, info.indent .len );
112- bRetVal &= WriteValue (STR_INI_OTHER_SEC, STR_INI_OTHER_FOLLOW_TAB, info.follow_current_tab );
113- bRetVal &= WriteValue (STR_INI_OTHER_SEC, STR_INI_OTHER_AUTO_FORMAT, info.auto_format_on_open );
120+
121+ bRetVal &= WriteValue (STR_INI_OTHER_SEC, STR_INI_OTHER_FOLLOW_TAB, info.bFollowCurrentTab );
122+ bRetVal &= WriteValue (STR_INI_OTHER_SEC, STR_INI_OTHER_AUTO_FORMAT, info.bAutoFormat );
123+ bRetVal &= WriteValue (STR_INI_OTHER_SEC, STR_INI_OTHER_IGNORE_COMMENT, info.parseOptions .bIgnoreComment );
124+ bRetVal &= WriteValue (STR_INI_OTHER_SEC, STR_INI_OTHER_IGNORE_COMMA, info.parseOptions .bIgnoreTraillingComma );
114125
115126 return bRetVal;
116127}
0 commit comments