improved query - added search in specific modlist in LocalModList and QueryAction

master
Phitherek 2013-04-12 10:30:44 +02:00
parent bdf849156c
commit 5c4820ef8c
17 changed files with 35 additions and 2 deletions

View File

@ -224,6 +224,16 @@ LocalModDescription LocalModList::getModDescriptionByName(std::string name) {
return emptylmd;
}
LocalModDescription LocalModList::getModDescriptionByNameFrom(std::string name, std::string remoteModlist) {
for(unsigned int i = 0; i < _modlist.size(); i++) {
if(_modlist[i].getName() == name && _modlist[i].getRemoteModlistName() == remoteModlist) {
return _modlist[i];
}
}
LocalModDescription emptylmd;
return emptylmd;
}
void LocalModList::resetModDescriptionIterator() {
if(_modlistAtEnd) {
_modlistAtEnd = false;

View File

@ -34,6 +34,10 @@ public:
LocalModDescription getModDescriptionByName(std::string name); ///< \brief A function, that searches a mod name and returns its description.
///< \param name A mod name.
///< \return Description of the mod.
LocalModDescription getModDescriptionByNameFrom(std::string name, std::string remoteModlist); ///< \brief A function, that searches a mod name in given remote modlist and returns its description.
///< \param name A mod name.
///< \param remoteModlist A name of remote modlist to search in.
///< \return Description of the mod.
void resetModDescriptionIterator(); ///< A function that resets iterator of the modlist.
bool modDescriptionsAtEnd(); ///< \brief A function that returns if the modlist iterator has reached its end.
///< \return True if modlist iterator is at end, false otherwise.

View File

@ -89,7 +89,22 @@ void QueryAction::run() {
}
} else {
for(unsigned int i = 0; i < parameters.size(); i++) {
mmm::LocalModDescription lmd = lml.getModDescriptionByName(parameters[i]);
mmm::LocalModDescription lmd;
std::string modname = "";
std::string modlistname = "";
for(unsigned int j = 0; j < parameters[i].length(); j++) {
if(parameters[i][j] == '/') {
modlistname = modname;
modname = "";
} else {
modname += parameters[i][j];
}
}
if(modlistname == "") {
lmd = lml.getModDescriptionByName(modname);
} else {
lmd = lml.getModDescriptionByNameFrom(modname, modlistname);
}
if(lmd.getName() != "" && lmd.getReleaseNr() > 0 && lmd.getDescription() != "" && lmd.getRemoteModlistName() != "") {
std::cout << lmd.getRemoteModlistName() << "/" << lmd.getName() << " (release: " << lmd.getReleaseNr() << ")";
if(repoinfook) {
@ -115,7 +130,11 @@ void QueryAction::run() {
}
}
} else {
std::cout << parameters[i] << " not found!" << std::endl;
if(modlistname == "") {
std::cout << modname << " not found!" << std::endl;
} else {
std::cout << modname << " not found in " << modlistname << "!" << std::endl;
}
}
}
}

BIN
filetesters/configparser Executable file

Binary file not shown.

BIN
filetesters/modinfoparser Executable file

Binary file not shown.

BIN
filetesters/modlistparser Executable file

Binary file not shown.

BIN
tests/ConfigFileTest Executable file

Binary file not shown.

BIN
tests/LocalModDescriptionTest Executable file

Binary file not shown.

BIN
tests/LocalModListTest Executable file

Binary file not shown.

BIN
tests/LocalQueryActionTest Executable file

Binary file not shown.

BIN
tests/ModDescriptionTest Executable file

Binary file not shown.

BIN
tests/ModInfoTest Executable file

Binary file not shown.

BIN
tests/ModListListTest Executable file

Binary file not shown.

BIN
tests/ModListTest Executable file

Binary file not shown.

BIN
tests/QueryActionTest Executable file

Binary file not shown.

BIN
tests/RepositoryInfoTest Executable file

Binary file not shown.

BIN
tests/SyncActionTest Executable file

Binary file not shown.