From 015b23cc8eb304cb6cbcc7eb935d3f7c8169b279 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Fri, 3 Oct 2014 12:16:14 +0300 Subject: [PATCH] Removed "using namespace std;" from stargazer. --- projects/stargazer/admins_impl.cpp | 22 ++++----- .../store/firebird/firebird_store_admins.cpp | 12 ++--- projects/stargazer/settings_impl.cpp | 46 +++++++++---------- projects/stargazer/tariffs_impl.cpp | 28 ++++++----- 4 files changed, 50 insertions(+), 58 deletions(-) diff --git a/projects/stargazer/admins_impl.cpp b/projects/stargazer/admins_impl.cpp index 08656a49..fb28b6e6 100644 --- a/projects/stargazer/admins_impl.cpp +++ b/projects/stargazer/admins_impl.cpp @@ -36,8 +36,6 @@ #include "admins_impl.h" #include "admin_impl.h" -using namespace std; - //----------------------------------------------------------------------------- ADMINS_IMPL::ADMINS_IMPL(STORE * st) : ADMINS(), @@ -55,14 +53,14 @@ pthread_mutex_init(&mutex, NULL); Read(); } //----------------------------------------------------------------------------- -int ADMINS_IMPL::Add(const string & login, const ADMIN * admin) +int ADMINS_IMPL::Add(const std::string & login, const ADMIN * admin) { STG_LOCKER lock(&mutex); const PRIV * priv = admin->GetPriv(); if (!priv->adminChg) { - string s = admin->GetLogStr() + " Add administrator \'" + login + "\'. Access denied."; + std::string s = admin->GetLogStr() + " Add administrator \'" + login + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -94,7 +92,7 @@ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); return -1; } //----------------------------------------------------------------------------- -int ADMINS_IMPL::Del(const string & login, const ADMIN * admin) +int ADMINS_IMPL::Del(const std::string & login, const ADMIN * admin) { STG_LOCKER lock(&mutex); ADMIN_IMPL adm(0, login, ""); @@ -102,7 +100,7 @@ const PRIV * priv = admin->GetPriv(); if (!priv->adminChg) { - string s = admin->GetLogStr() + " Delete administrator \'" + login + "\'. Access denied."; + std::string s = admin->GetLogStr() + " Delete administrator \'" + login + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -117,7 +115,7 @@ if (ai == data.end()) return -1; } -map::iterator si; +std::map::iterator si; si = searchDescriptors.begin(); while (si != searchDescriptors.end()) { @@ -146,7 +144,7 @@ const PRIV * priv = admin->GetPriv(); if (!priv->adminChg) { - string s = admin->GetLogStr() + " Change administrator \'" + ac.login + "\'. Access denied."; + std::string s = admin->GetLogStr() + " Change administrator \'" + ac.login + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -179,7 +177,7 @@ return 0; int ADMINS_IMPL::Read() { STG_LOCKER lock(&mutex); -vector adminsList; +std::vector adminsList; if (store->GetAdminsList(&adminsList) < 0) { WriteServLog(store->GetStrError().c_str()); @@ -201,7 +199,7 @@ for (unsigned int i = 0; i < adminsList.size(); i++) return 0; } //----------------------------------------------------------------------------- -bool ADMINS_IMPL::Find(const string & l, ADMIN ** admin) +bool ADMINS_IMPL::Find(const std::string & l, ADMIN ** admin) { assert(admin != NULL && "Pointer to admin is not null"); @@ -225,7 +223,7 @@ if (ai != data.end()) return true; } //----------------------------------------------------------------------------- -bool ADMINS_IMPL::Exists(const string & login) const +bool ADMINS_IMPL::Exists(const std::string & login) const { STG_LOCKER lock(&mutex); if (data.empty()) @@ -243,7 +241,7 @@ if (ai != data.end()) return false; } //----------------------------------------------------------------------------- -bool ADMINS_IMPL::Correct(const string & login, const std::string & password, ADMIN ** admin) +bool ADMINS_IMPL::Correct(const std::string & login, const std::string & password, ADMIN ** admin) { STG_LOCKER lock(&mutex); if (data.empty()) diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp index fa949281..e794d206 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp @@ -29,8 +29,6 @@ #include #include -using namespace std; - #include "firebird_store.h" #include "stg/ibpp.h" #include "stg/blowfish.h" @@ -38,14 +36,14 @@ using namespace std; #define adm_enc_passwd "cjeifY8m3" //----------------------------------------------------------------------------- -int FIREBIRD_STORE::GetAdminsList(vector * adminsList) const +int FIREBIRD_STORE::GetAdminsList(std::vector * adminsList) const { STG_LOCKER lock(&mutex); IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr); IBPP::Statement st = IBPP::StatementFactory(db, tr); -string login; +std::string login; try { @@ -128,7 +126,7 @@ catch (IBPP::Exception & ex) return 0; } //----------------------------------------------------------------------------- -int FIREBIRD_STORE::RestoreAdmin(ADMIN_CONF * ac, const string & login) const +int FIREBIRD_STORE::RestoreAdmin(ADMIN_CONF * ac, const std::string & login) const { STG_LOCKER lock(&mutex); @@ -191,7 +189,7 @@ ac->password = adminPass; return 0; } //----------------------------------------------------------------------------- -int FIREBIRD_STORE::AddAdmin(const string & login) const +int FIREBIRD_STORE::AddAdmin(const std::string & login) const { STG_LOCKER lock(&mutex); @@ -229,7 +227,7 @@ catch (IBPP::Exception & ex) return 0; } //----------------------------------------------------------------------------- -int FIREBIRD_STORE::DelAdmin(const string & login) const +int FIREBIRD_STORE::DelAdmin(const std::string & login) const { STG_LOCKER lock(&mutex); diff --git a/projects/stargazer/settings_impl.cpp b/projects/stargazer/settings_impl.cpp index 92670cb5..f6a40db3 100644 --- a/projects/stargazer/settings_impl.cpp +++ b/projects/stargazer/settings_impl.cpp @@ -36,8 +36,6 @@ $Author: faust $ #include "stg/dotconfpp.h" #include "settings_impl.h" -using namespace std; - //----------------------------------------------------------------------------- SETTINGS_IMPL::SETTINGS_IMPL() : SETTINGS(), @@ -138,7 +136,7 @@ SETTINGS_IMPL::SETTINGS_IMPL(const SETTINGS_IMPL & rval) { } //----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseModuleSettings(const DOTCONFDocumentNode * node, vector * params) +int SETTINGS_IMPL::ParseModuleSettings(const DOTCONFDocumentNode * node, std::vector * params) { const DOTCONFDocumentNode * childNode; PARAM_VALUE pv; @@ -148,7 +146,7 @@ pv.param = node->getName(); if (node->getValue(1)) { - strError = "Unexpected value \'" + string(node->getValue(1)) + "\'."; + strError = "Unexpected value \'" + std::string(node->getValue(1)) + "\'."; return -1; } @@ -207,7 +205,7 @@ modulesSettings.clear(); DOTCONFDocument conf(DOTCONFDocument::CASEINSENSITIVE); conf.setErrorCallback(SETTINGS_IMPL::ErrorCallback, this); conf.setRequiredOptionNames(requiredOptions); -string confFile = confDir + "/stargazer.conf"; +std::string confFile = confDir + "/stargazer.conf"; if(conf.setContent(confFile.c_str()) != 0) { @@ -248,7 +246,7 @@ while (node) { if (ParseDetailStatWritePeriod(node->getValue(0)) != 0) { - strError = "Incorrect DetailStatWritePeriod value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect DetailStatWritePeriod value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -257,7 +255,7 @@ while (node) { if (ParseUnsignedInRange(node->getValue(0), 1, 1440, &statWritePeriod) != 0) { - strError = "Incorrect StatWritePeriod value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect StatWritePeriod value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -266,7 +264,7 @@ while (node) { if (ParseInt(node->getValue(0), &stgExecMsgKey) != 0) { - strError = "Incorrect ExecMsgKey value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect ExecMsgKey value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -275,7 +273,7 @@ while (node) { if (ParseUnsignedInRange(node->getValue(0), 1, 1024, &executersNum) != 0) { - strError = "Incorrect ExecutersNum value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect ExecutersNum value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -284,7 +282,7 @@ while (node) { if (ParseUnsignedInRange(node->getValue(0), 0, 31, &dayFee) != 0) { - strError = "Incorrect DayFee value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect DayFee value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -293,7 +291,7 @@ while (node) { if (ParseYesNo(node->getValue(0), &fullFee) != 0) { - strError = "Incorrect FullFee value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect FullFee value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -302,7 +300,7 @@ while (node) { if (ParseUnsignedInRange(node->getValue(0), 0, 31, &dayResetTraff) != 0) { - strError = "Incorrect DayResetTraff value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect DayResetTraff value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -311,7 +309,7 @@ while (node) { if (ParseYesNo(node->getValue(0), &spreadFee) != 0) { - strError = "Incorrect SpreadFee value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect SpreadFee value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -320,7 +318,7 @@ while (node) { if (ParseYesNo(node->getValue(0), &freeMbAllowInet) != 0) { - strError = "Incorrect FreeMbAllowInet value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect FreeMbAllowInet value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -329,7 +327,7 @@ while (node) { if (ParseYesNo(node->getValue(0), &dayFeeIsLastDay) != 0) { - strError = "Incorrect DayFeeIsLastDay value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect DayFeeIsLastDay value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -338,7 +336,7 @@ while (node) { if (ParseYesNo(node->getValue(0), &writeFreeMbTraffCost) != 0) { - strError = "Incorrect WriteFreeMbTraffCost value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect WriteFreeMbTraffCost value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -347,7 +345,7 @@ while (node) { if (ParseYesNo(node->getValue(0), &showFeeInCash) != 0) { - strError = "Incorrect ShowFeeInCash value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect ShowFeeInCash value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -368,7 +366,7 @@ while (node) { if (ParseUnsigned(node->getValue(0), &messageTimeout) != 0) { - strError = "Incorrect MessageTimeout value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect MessageTimeout value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -377,7 +375,7 @@ while (node) { if (ParseUnsignedInRange(node->getValue(0), 0, 3, &feeChargeType) != 0) { - strError = "Incorrect FeeChargeType value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect FeeChargeType value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -386,7 +384,7 @@ while (node) { if (ParseYesNo(node->getValue(0), &reconnectOnTariffChange) != 0) { - strError = "Incorrect ReconnectOnTariffChange value: \'" + string(node->getValue(0)) + "\'"; + strError = "Incorrect ReconnectOnTariffChange value: \'" + std::string(node->getValue(0)) + "\'"; return -1; } } @@ -415,7 +413,7 @@ while (node) { if (node->getValue(1)) { - strError = "Unexpected \'" + string(node->getValue(1)) + "\'."; + strError = "Unexpected \'" + std::string(node->getValue(1)) + "\'."; return -1; } @@ -434,7 +432,7 @@ while (node) { if (node->getValue(0)) { - strError = "Unexpected \'" + string(node->getValue(0)) + "\'."; + strError = "Unexpected \'" + std::string(node->getValue(0)) + "\'."; return -1; } const DOTCONFDocumentNode * child = node->getChildNode(); @@ -470,7 +468,7 @@ while (node) return 0; } //----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseDetailStatWritePeriod(const string & detailStatPeriodStr) +int SETTINGS_IMPL::ParseDetailStatWritePeriod(const std::string & detailStatPeriodStr) { if (detailStatPeriodStr == "1") { @@ -495,4 +493,4 @@ else if (detailStatPeriodStr == "1/6") return -1; } -//----------------------------------------------------------------------------- \ No newline at end of file +//----------------------------------------------------------------------------- diff --git a/projects/stargazer/tariffs_impl.cpp b/projects/stargazer/tariffs_impl.cpp index 1a8ea359..d47ecf8f 100644 --- a/projects/stargazer/tariffs_impl.cpp +++ b/projects/stargazer/tariffs_impl.cpp @@ -38,8 +38,6 @@ #include "stg/admin.h" #include "tariffs_impl.h" -using namespace std; - //----------------------------------------------------------------------------- TARIFFS_IMPL::TARIFFS_IMPL(STORE * st) : TARIFFS(), @@ -65,7 +63,7 @@ int TARIFFS_IMPL::ReadTariffs() { STG_LOCKER lock(&mutex); -vector tariffsList; +std::vector tariffsList; if (store->GetTariffsList(&tariffsList)) { WriteServLog("Cannot get tariffs list."); @@ -95,13 +93,13 @@ STG_LOCKER lock(&mutex); return tariffs.size(); } //----------------------------------------------------------------------------- -const TARIFF * TARIFFS_IMPL::FindByName(const string & name) const +const TARIFF * TARIFFS_IMPL::FindByName(const std::string & name) const { if (name == NO_TARIFF_NAME) return &noTariff; STG_LOCKER lock(&mutex); -list::const_iterator ti; +std::list::const_iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); if (ti != tariffs.end()) @@ -116,7 +114,7 @@ const PRIV * priv = admin->GetPriv(); if (!priv->tariffChg) { - string s = admin->GetLogStr() + " Change tariff \'" + std::string s = admin->GetLogStr() + " Change tariff \'" + td.tariffConf.name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); @@ -125,7 +123,7 @@ if (!priv->tariffChg) STG_LOCKER lock(&mutex); -list::iterator ti; +std::list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(td.tariffConf.name)); if (ti == tariffs.end()) @@ -139,7 +137,7 @@ if (ti == tariffs.end()) if (store->SaveTariff(td, td.tariffConf.name)) { - string error = "Tariff " + td.tariffConf.name + " writing error. " + store->GetStrError(); + std::string error = "Tariff " + td.tariffConf.name + " writing error. " + store->GetStrError(); WriteServLog(error.c_str()); return -1; } @@ -150,13 +148,13 @@ WriteServLog("%s Tariff \'%s\' changed.", return 0; } //----------------------------------------------------------------------------- -int TARIFFS_IMPL::Del(const string & name, const ADMIN * admin) +int TARIFFS_IMPL::Del(const std::string & name, const ADMIN * admin) { const PRIV * priv = admin->GetPriv(); if (!priv->tariffChg) { - string s = admin->GetLogStr() + " Delete tariff \'" + std::string s = admin->GetLogStr() + " Delete tariff \'" + name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); @@ -168,7 +166,7 @@ TARIFF_DATA td; { STG_LOCKER lock(&mutex); - list::iterator ti; + std::list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); if (ti == tariffs.end()) @@ -184,7 +182,7 @@ TARIFF_DATA td; WriteServLog("%s", store->GetStrError().c_str()); return -1; } - + td = ti->GetTariffData(); tariffs.erase(ti); @@ -203,13 +201,13 @@ WriteServLog("%s Tariff \'%s\' deleted.", return 0; } //----------------------------------------------------------------------------- -int TARIFFS_IMPL::Add(const string & name, const ADMIN * admin) +int TARIFFS_IMPL::Add(const std::string & name, const ADMIN * admin) { const PRIV * priv = admin->GetPriv(); if (!priv->tariffChg) { - string s = admin->GetLogStr() + " Add tariff \'" + std::string s = admin->GetLogStr() + " Add tariff \'" + name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); @@ -219,7 +217,7 @@ if (!priv->tariffChg) { STG_LOCKER lock(&mutex); - list::iterator ti; + std::list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); if (ti != tariffs.end()) -- 2.43.2