Replace most uses of std::string::compare() by operator==(), for clarity
parent
c0bfc99946
commit
83a94aca57
|
@ -80,7 +80,7 @@ FollowerNode::FollowerNode(string computerName_arg, string port_arg, int minCpuN
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!operatingSystem.empty())
|
if (!operatingSystem.empty())
|
||||||
if (operatingSystem.compare("windows") != 0 && operatingSystem.compare("unix") != 0)
|
if (operatingSystem != "windows" && operatingSystem != "unix")
|
||||||
{
|
{
|
||||||
cerr << "ERROR: The OperatingSystem must be either 'unix' or 'windows' (Case Sensitive)." << endl;
|
cerr << "ERROR: The OperatingSystem must be either 'unix' or 'windows' (Case Sensitive)." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -190,10 +190,10 @@ ConfigFile::getConfigFileInfo(const string &config_file)
|
||||||
if (line.empty() || !line.compare(0, 1, "#"))
|
if (line.empty() || !line.compare(0, 1, "#"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!line.compare("[node]")
|
if (line == "[node]"
|
||||||
|| !line.compare("[cluster]")
|
|| line == "[cluster]"
|
||||||
|| !line.compare("[hooks]")
|
|| line == "[hooks]"
|
||||||
|| !line.compare("[paths]"))
|
|| line == "[paths]")
|
||||||
{
|
{
|
||||||
if (!global_init_file.empty())
|
if (!global_init_file.empty())
|
||||||
// we were just in [hooks]
|
// we were just in [hooks]
|
||||||
|
@ -210,21 +210,21 @@ ConfigFile::getConfigFileInfo(const string &config_file)
|
||||||
numberOfThreadsPerJob, operatingSystem);
|
numberOfThreadsPerJob, operatingSystem);
|
||||||
|
|
||||||
//! Reset communication vars / option defaults
|
//! Reset communication vars / option defaults
|
||||||
if (!line.compare("[hooks]"))
|
if (line == "[hooks]")
|
||||||
{
|
{
|
||||||
inHooks = true;
|
inHooks = true;
|
||||||
inNode = false;
|
inNode = false;
|
||||||
inCluster = false;
|
inCluster = false;
|
||||||
inPaths = false;
|
inPaths = false;
|
||||||
}
|
}
|
||||||
else if (!line.compare("[node]"))
|
else if (line == "[node]")
|
||||||
{
|
{
|
||||||
inHooks = false;
|
inHooks = false;
|
||||||
inNode = true;
|
inNode = true;
|
||||||
inCluster = false;
|
inCluster = false;
|
||||||
inPaths = false;
|
inPaths = false;
|
||||||
}
|
}
|
||||||
else if (!line.compare("[paths]"))
|
else if (line == "[paths]")
|
||||||
{
|
{
|
||||||
inHooks = false;
|
inHooks = false;
|
||||||
inNode = false;
|
inNode = false;
|
||||||
|
@ -261,7 +261,7 @@ ConfigFile::getConfigFileInfo(const string &config_file)
|
||||||
trim(tokenizedLine.back());
|
trim(tokenizedLine.back());
|
||||||
|
|
||||||
if (inHooks)
|
if (inHooks)
|
||||||
if (!tokenizedLine.front().compare("GlobalInitFile"))
|
if (tokenizedLine.front() == "GlobalInitFile")
|
||||||
if (global_init_file.empty())
|
if (global_init_file.empty())
|
||||||
global_init_file = tokenizedLine.back();
|
global_init_file = tokenizedLine.back();
|
||||||
else
|
else
|
||||||
|
@ -275,7 +275,7 @@ ConfigFile::getConfigFileInfo(const string &config_file)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
else if (inPaths)
|
else if (inPaths)
|
||||||
if (!tokenizedLine.front().compare("Include"))
|
if (tokenizedLine.front() == "Include")
|
||||||
if (includepath.empty())
|
if (includepath.empty())
|
||||||
{
|
{
|
||||||
vector<string> tokenizedPath;
|
vector<string> tokenizedPath;
|
||||||
|
@ -298,9 +298,9 @@ ConfigFile::getConfigFileInfo(const string &config_file)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (!tokenizedLine.front().compare("Name"))
|
if (tokenizedLine.front() == "Name")
|
||||||
name = tokenizedLine.back();
|
name = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("CPUnbr"))
|
else if (tokenizedLine.front() == "CPUnbr")
|
||||||
{
|
{
|
||||||
vector<string> tokenizedCpuNbr;
|
vector<string> tokenizedCpuNbr;
|
||||||
split(tokenizedCpuNbr, tokenizedLine.back(), is_any_of(":"));
|
split(tokenizedCpuNbr, tokenizedLine.back(), is_any_of(":"));
|
||||||
|
@ -345,40 +345,40 @@ ConfigFile::getConfigFileInfo(const string &config_file)
|
||||||
minCpuNbr = tmp;
|
minCpuNbr = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!tokenizedLine.front().compare("Port"))
|
else if (tokenizedLine.front() == "Port")
|
||||||
port = tokenizedLine.back();
|
port = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("ComputerName"))
|
else if (tokenizedLine.front() == "ComputerName")
|
||||||
computerName = tokenizedLine.back();
|
computerName = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("UserName"))
|
else if (tokenizedLine.front() == "UserName")
|
||||||
userName = tokenizedLine.back();
|
userName = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("Password"))
|
else if (tokenizedLine.front() == "Password")
|
||||||
password = tokenizedLine.back();
|
password = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("RemoteDrive"))
|
else if (tokenizedLine.front() == "RemoteDrive")
|
||||||
remoteDrive = tokenizedLine.back();
|
remoteDrive = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("RemoteDirectory"))
|
else if (tokenizedLine.front() == "RemoteDirectory")
|
||||||
remoteDirectory = tokenizedLine.back();
|
remoteDirectory = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("DynarePath")
|
else if (tokenizedLine.front() == "DynarePath"
|
||||||
|| !tokenizedLine.front().compare("ProgramPath"))
|
|| tokenizedLine.front() == "ProgramPath")
|
||||||
programPath = tokenizedLine.back();
|
programPath = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("ProgramConfig"))
|
else if (tokenizedLine.front() == "ProgramConfig")
|
||||||
programConfig = tokenizedLine.back();
|
programConfig = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("MatlabOctavePath"))
|
else if (tokenizedLine.front() == "MatlabOctavePath")
|
||||||
matlabOctavePath = tokenizedLine.back();
|
matlabOctavePath = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("NumberOfThreadsPerJob"))
|
else if (tokenizedLine.front() == "NumberOfThreadsPerJob")
|
||||||
numberOfThreadsPerJob = stoi(tokenizedLine.back());
|
numberOfThreadsPerJob = stoi(tokenizedLine.back());
|
||||||
else if (!tokenizedLine.front().compare("SingleCompThread"))
|
else if (tokenizedLine.front() == "SingleCompThread")
|
||||||
if (tokenizedLine.back().compare("true") == 0)
|
if (tokenizedLine.back() == "true")
|
||||||
singleCompThread = true;
|
singleCompThread = true;
|
||||||
else if (tokenizedLine.back().compare("false") == 0)
|
else if (tokenizedLine.back() == "false")
|
||||||
singleCompThread = false;
|
singleCompThread = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "ERROR (in config file): The value passed to SingleCompThread may only be 'true' or 'false'." << endl;
|
cerr << "ERROR (in config file): The value passed to SingleCompThread may only be 'true' or 'false'." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
else if (!tokenizedLine.front().compare("OperatingSystem"))
|
else if (tokenizedLine.front() == "OperatingSystem")
|
||||||
operatingSystem = tokenizedLine.back();
|
operatingSystem = tokenizedLine.back();
|
||||||
else if (!tokenizedLine.front().compare("Members"))
|
else if (tokenizedLine.front() == "Members")
|
||||||
{
|
{
|
||||||
char_separator sep(" ,;", "()", drop_empty_tokens);
|
char_separator sep(" ,;", "()", drop_empty_tokens);
|
||||||
tokenizer tokens(tokenizedLine.back(), sep);
|
tokenizer tokens(tokenizedLine.back(), sep);
|
||||||
|
@ -386,12 +386,12 @@ ConfigFile::getConfigFileInfo(const string &config_file)
|
||||||
for (bool begin_weight{false};
|
for (bool begin_weight{false};
|
||||||
const auto &token : tokens)
|
const auto &token : tokens)
|
||||||
{
|
{
|
||||||
if (token.compare("(") == 0)
|
if (token == "(")
|
||||||
{
|
{
|
||||||
begin_weight = true;
|
begin_weight = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (token.compare(")") == 0)
|
else if (token == ")")
|
||||||
{
|
{
|
||||||
node_name.clear();
|
node_name.clear();
|
||||||
begin_weight = false;
|
begin_weight = false;
|
||||||
|
@ -538,7 +538,7 @@ ConfigFile::checkPass(WarningConsolidation &warnings) const
|
||||||
for (bool global_init_file_declared{false};
|
for (bool global_init_file_declared{false};
|
||||||
const auto &hook : hooks)
|
const auto &hook : hooks)
|
||||||
for (const auto &mapit : hook.get_hooks())
|
for (const auto &mapit : hook.get_hooks())
|
||||||
if (mapit.first.compare("global_init_file") == 0)
|
if (mapit.first == "global_init_file")
|
||||||
if (exchange(global_init_file_declared, true))
|
if (exchange(global_init_file_declared, true))
|
||||||
{
|
{
|
||||||
cerr << "ERROR: Only one global initialization file may be provided." << endl;
|
cerr << "ERROR: Only one global initialization file may be provided." << endl;
|
||||||
|
@ -574,7 +574,7 @@ ConfigFile::checkPass(WarningConsolidation &warnings) const
|
||||||
cerr << "ERROR (node " << follower_node.first << "): the port must be an integer." << endl;
|
cerr << "ERROR (node " << follower_node.first << "): the port must be an integer." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (!follower_node.second.computerName.compare("localhost")) // We are working locally
|
if (follower_node.second.computerName == "localhost") // We are working locally
|
||||||
{
|
{
|
||||||
if (!follower_node.second.remoteDrive.empty())
|
if (!follower_node.second.remoteDrive.empty())
|
||||||
{
|
{
|
||||||
|
@ -594,7 +594,7 @@ ConfigFile::checkPass(WarningConsolidation &warnings) const
|
||||||
cerr << "ERROR (node " << follower_node.first << "): the UserName option must be passed for every remote node." << endl;
|
cerr << "ERROR (node " << follower_node.first << "): the UserName option must be passed for every remote node." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (follower_node.second.operatingSystem.compare("windows") == 0)
|
if (follower_node.second.operatingSystem == "windows")
|
||||||
{
|
{
|
||||||
if (follower_node.second.password.empty())
|
if (follower_node.second.password.empty())
|
||||||
{
|
{
|
||||||
|
@ -710,7 +710,7 @@ ConfigFile::writeCluster(ostream &output) const
|
||||||
{
|
{
|
||||||
bool follower_node_in_member_nodes = false;
|
bool follower_node_in_member_nodes = false;
|
||||||
for (const auto &itmn : cluster_it->second.member_nodes)
|
for (const auto &itmn : cluster_it->second.member_nodes)
|
||||||
if (!follower_node.first.compare(itmn.first))
|
if (follower_node.first == itmn.first)
|
||||||
follower_node_in_member_nodes = true;
|
follower_node_in_member_nodes = true;
|
||||||
|
|
||||||
if (!follower_node_in_member_nodes)
|
if (!follower_node_in_member_nodes)
|
||||||
|
@ -721,10 +721,10 @@ ConfigFile::writeCluster(ostream &output) const
|
||||||
output << "(" << i << ")";
|
output << "(" << i << ")";
|
||||||
i++;
|
i++;
|
||||||
output << " = struct('Local', ";
|
output << " = struct('Local', ";
|
||||||
if (follower_node.second.computerName.compare("localhost"))
|
if (follower_node.second.computerName == "localhost")
|
||||||
output << "0, ";
|
|
||||||
else
|
|
||||||
output << "1, ";
|
output << "1, ";
|
||||||
|
else
|
||||||
|
output << "0, ";
|
||||||
|
|
||||||
output << "'ComputerName', '" << follower_node.second.computerName << "', "
|
output << "'ComputerName', '" << follower_node.second.computerName << "', "
|
||||||
<< "'Port', '" << follower_node.second.port << "', "
|
<< "'Port', '" << follower_node.second.port << "', "
|
||||||
|
|
|
@ -311,7 +311,7 @@ ParsingDriver::add_equation_tags(string key, string value)
|
||||||
eq_tags[key] = value;
|
eq_tags[key] = value;
|
||||||
|
|
||||||
transform(key.begin(), key.end(), key.begin(), ::tolower);
|
transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||||
if (key.compare("endogenous") == 0)
|
if (key == "endogenous")
|
||||||
declare_or_change_type(SymbolType::endogenous, value);
|
declare_or_change_type(SymbolType::endogenous, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1404,7 +1404,7 @@ ParsingDriver::option_symbol_list(string name_option, vector<string> symbol_list
|
||||||
if (options_list.symbol_list_options.contains(name_option))
|
if (options_list.symbol_list_options.contains(name_option))
|
||||||
error("option " + name_option + " declared twice");
|
error("option " + name_option + " declared twice");
|
||||||
|
|
||||||
if (name_option.compare("irf_shocks") == 0)
|
if (name_option == "irf_shocks")
|
||||||
for (auto &shock : symbol_list)
|
for (auto &shock : symbol_list)
|
||||||
{
|
{
|
||||||
if (!mod_file->symbol_table.exists(shock))
|
if (!mod_file->symbol_table.exists(shock))
|
||||||
|
@ -1413,7 +1413,7 @@ ParsingDriver::option_symbol_list(string name_option, vector<string> symbol_list
|
||||||
error("Variables passed to irf_shocks must be exogenous. Caused by: " + shock);
|
error("Variables passed to irf_shocks must be exogenous. Caused by: " + shock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name_option.compare("ms.parameters") == 0)
|
if (name_option == "ms.parameters")
|
||||||
for (auto &it : symbol_list)
|
for (auto &it : symbol_list)
|
||||||
if (mod_file->symbol_table.getType(it) != SymbolType::parameter)
|
if (mod_file->symbol_table.getType(it) != SymbolType::parameter)
|
||||||
error("Variables passed to the parameters option of the markov_switching statement must be parameters. Caused by: " + it);
|
error("Variables passed to the parameters option of the markov_switching statement must be parameters. Caused by: " + it);
|
||||||
|
|
Loading…
Reference in New Issue