Replace the two vector<string,string> with one vector<struct{string,string}>

Before this patch there were two separate vectors, and the code made sure
they always had the same size.
With this patch the code doesn't have to ensure this anymore, there is only
one vector now.

Alex
This commit is contained in:
Alex Neundorf 2010-08-29 17:51:44 +02:00
parent 130b0e2195
commit 0367245f0c
2 changed files with 17 additions and 15 deletions

View File

@ -726,8 +726,7 @@ bool cmFindPackageCommand::FindModule(bool& found)
//----------------------------------------------------------------------------
bool cmFindPackageCommand::HandlePackageMode()
{
this->ConsideredConfigFiles.clear();
this->ConsideredVersions.clear();
this->ConsideredConfigs.clear();
// Support old capitalization behavior.
std::string upperDir = cmSystemTools::UpperCase(this->Name);
@ -819,17 +818,17 @@ bool cmFindPackageCommand::HandlePackageMode()
cmOStringStream e;
// If there are files in ConsideredConfigs, it means that FooConfig.cmake
// have been found, but they didn't have appropriate versions.
if (this->ConsideredConfigFiles.size() > 0)
if (this->ConsideredConfigs.size() > 0)
{
e << "Could not find configuration file for package " << this->Name
<< " with " << (this->VersionExact ? "exact " : "at least ")
<< "version " << this->Version << " .\n"
<< "Found the following files:\n";
for(std::vector<std::string>::size_type i=0;
i<this->ConsideredConfigFiles.size(); i++)
for(std::vector<ConfigFileInfo>::size_type i=0;
i<this->ConsideredConfigs.size(); i++)
{
e << " " << this->ConsideredConfigFiles[i]
<< ", version: " << this->ConsideredVersions[i] << "\n";
e << " " << this->ConsideredConfigs[i].filename
<< ", version: " << this->ConsideredConfigs[i].version << "\n";
}
}
else
@ -933,12 +932,12 @@ bool cmFindPackageCommand::HandlePackageMode()
std::string consideredConfigFiles;
std::string consideredVersions;
for(std::vector<std::string>::size_type i=0;
i<this->ConsideredConfigFiles.size(); i++)
for(std::vector<ConfigFileInfo>::size_type i=0;
i<this->ConsideredConfigs.size(); i++)
{
consideredConfigFiles += this->ConsideredConfigFiles[i];
consideredConfigFiles += this->ConsideredConfigs[i].filename;
consideredConfigFiles += ";";
consideredVersions += this->ConsideredVersions[i];
consideredVersions += this->ConsideredConfigs[i].version;
consideredVersions += ";";
}
@ -1554,8 +1553,10 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
haveResult = true;
}
this->ConsideredConfigFiles.push_back(config_file);
this->ConsideredVersions.push_back(version);
ConfigFileInfo configFileInfo;
configFileInfo.filename = config_file;
configFileInfo.version = version;
this->ConsideredConfigs.push_back(configFileInfo);
return result;
}

View File

@ -138,8 +138,9 @@ private:
std::vector<std::string> Names;
std::vector<std::string> Configs;
std::set<std::string> IgnoredPaths;
std::vector<std::string> ConsideredConfigFiles;
std::vector<std::string> ConsideredVersions;
struct ConfigFileInfo { std::string filename; std::string version; };
std::vector<ConfigFileInfo> ConsideredConfigs;
};
#endif