summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx/src/ex_import
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:35:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:14 +0300
commit058282527241fe458a1aae28d565a727dcc1a811 (patch)
tree7b5d5a1a5abe8052cd9879af19135df5f58a363d /plugins/UserInfoEx/src/ex_import
parent429c0d0524e7197a593209468fef530344f5ee05 (diff)
UInfoEx: C++'11 iterators
Diffstat (limited to 'plugins/UserInfoEx/src/ex_import')
-rw-r--r--plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp13
-rw-r--r--plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp6
-rw-r--r--plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp86
3 files changed, 33 insertions, 72 deletions
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
index 1dec35ecbf..c6fa31e5ff 100644
--- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
+++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
@@ -150,13 +150,8 @@ int CExImContactXML::ExportContact(DB::CEnumList* pModules)
{
if (_pXmlFile->_wExport & EXPORT_DATA) {
if (pModules) {
- int i;
- LPSTR p;
-
- for (i = 0; i < pModules->getCount(); i++) {
- p = (*pModules)[i];
- ExportModule(p);
- }
+ for (auto &it : *pModules)
+ ExportModule(it);
}
else {
ExportModule(USERINFO);
@@ -270,8 +265,8 @@ int CExImContactXML::ExportModule(LPCSTR pszModule)
return ERROR_MEMORY_ALLOC;
xmod->SetAttribute("key", pszModule);
- for (int i = 0; i < Settings.getCount(); i++)
- ExportSetting(xmod, pszModule, Settings[i]);
+ for (auto &it : Settings)
+ ExportSetting(xmod, pszModule, it);
if (!xmod->NoChildren() && _xmlNode->LinkEndChild(xmod))
return ERROR_OK;
diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp
index 5e72891db6..2be1bf0365 100644
--- a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp
+++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp
@@ -275,12 +275,8 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar
if (!Modules.EnumModules()) // init Modul list
{
- int i;
- LPSTR p;
-
- for (i = 0; i < Modules.getCount(); i++)
+ for (auto &p : Modules)
{
- p = Modules[i];
/*Filter/
if (!DB::Module::IsMeta(p))/end Filter*/
{
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp
index 62b19ea7c7..8c55ff4aae 100644
--- a/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp
+++ b/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp
@@ -47,70 +47,52 @@ static void ExportModule(MCONTACT hContact, LPCSTR pszModule, FILE* file)
LPSTR here;
WORD j;
int i;
- LPSTR pszSetting;
//char tmp[32];
// print the module header..
fprintf(file, "\n[%s]\n", pszModule);
- for (i = 0; i < Settings.getCount(); i++)
- {
- pszSetting = Settings[i];
-
- if (!DB::Setting::GetAsIs(hContact, pszModule, pszSetting, &dbv))
- {
- switch (dbv.type)
- {
+ for (auto &it : Settings) {
+ if (!DB::Setting::GetAsIs(hContact, pszModule, it, &dbv)) {
+ switch (dbv.type) {
case DBVT_BYTE:
- {
- fprintf(file, "%s=b%u\n", pszSetting, dbv.bVal);
- }
+ fprintf(file, "%s=b%u\n", it, dbv.bVal);
break;
case DBVT_WORD:
- {
- fprintf(file, "%s=w%u\n", pszSetting, dbv.wVal);
- }
+ fprintf(file, "%s=w%u\n", it, dbv.wVal);
break;
case DBVT_DWORD:
- {
- fprintf(file, "%s=d%u\n", pszSetting, dbv.dVal);
- }
+ fprintf(file, "%s=d%u\n", it, dbv.dVal);
break;
case DBVT_ASCIIZ:
case DBVT_UTF8:
+ for (here = dbv.pszVal; here && *here; here++)
{
- for (here = dbv.pszVal; here && *here; here++)
- {
- switch (*here) {
- // convert \r to STX
- case '\r':
- *here = 2;
- break;
-
- // convert \n to ETX
- case '\n':
- *here = 3;
- }
+ switch (*here) {
+ // convert \r to STX
+ case '\r':
+ *here = 2;
+ break;
+
+ // convert \n to ETX
+ case '\n':
+ *here = 3;
}
- if (dbv.type == DBVT_UTF8)
- fprintf(file, "%s=u%s\n", pszSetting, dbv.pszVal);
- else
- fprintf(file, "%s=s%s\n", pszSetting, dbv.pszVal);
}
+ if (dbv.type == DBVT_UTF8)
+ fprintf(file, "%s=u%s\n", it, dbv.pszVal);
+ else
+ fprintf(file, "%s=s%s\n", it, dbv.pszVal);
break;
case DBVT_BLOB:
- {
- fprintf(file, "%s=n", pszSetting);
- for (j = 0; j < dbv.cpbVal; j++)
- {
- fprintf(file, "%02X ", (BYTE)dbv.pbVal[j]);
- }
- fputc('\n', file);
- }
+ fprintf(file, "%s=n", it);
+ for (j = 0; j < dbv.cpbVal; j++)
+ fprintf(file, "%02X ", (BYTE)dbv.pbVal[j]);
+ fputc('\n', file);
break;
}
db_free(&dbv);
@@ -130,25 +112,13 @@ static BYTE ExportContact(MCONTACT hContact, DB::CEnumList* pModules, FILE* file
{
CExImContactBase vcc;
- if (pModules)
- {
- if ((vcc = hContact) >= NULL)
- {
- int i;
- LPSTR p;
-
+ if (pModules) {
+ if ((vcc = hContact) >= NULL) {
vcc.toIni(file, pModules->getCount()-1);
- for (i = 0; i < pModules->getCount(); i++)
- {
- p = (*pModules)[i];
+ for (auto &it : *pModules)
+ ExportModule(hContact, it, file);
- /*Filter/
- if (mir_strcmpi(p, "Protocol"))*/
- {
- ExportModule(hContact, p, file);
- }
- }
return TRUE;
}
}