|
|
|
@ -419,123 +419,59 @@ void SearchEngine::Search() |
|
|
|
|
|
|
|
|
|
|
|
bool any_found = 1; |
|
|
|
bool any_found = 1; |
|
|
|
bool found = 1; |
|
|
|
bool found = 1; |
|
|
|
|
|
|
|
boost::regex rx[11]; |
|
|
|
LocaleStringComparison cmp(std::locale(), Config.ignore_leading_the); |
|
|
|
if (SearchMode != &SearchModes[2]) // match to pattern
|
|
|
|
for (auto it = list.begin(); it != list.end(); ++it) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (SearchMode != &SearchModes[2]) // match to pattern
|
|
|
|
for (int i = 0; i < 11; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::regex rx; |
|
|
|
if (!itsConstraints[i].empty()) |
|
|
|
if (!itsConstraints[0].empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
rx.assign(itsConstraints[0], Config.regex_type); |
|
|
|
rx[i].assign(itsConstraints[i], Config.regex_type); |
|
|
|
any_found = |
|
|
|
|
|
|
|
boost::regex_search(it->getArtist(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getAlbumArtist(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getTitle(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getAlbum(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getName(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getComposer(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getPerformer(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getGenre(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getDate(), rx) |
|
|
|
|
|
|
|
|| boost::regex_search(it->getComment(), rx); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (found && !itsConstraints[1].empty()) |
|
|
|
LocaleStringComparison cmp(std::locale(), Config.ignore_leading_the); |
|
|
|
{ |
|
|
|
for (auto it = list.begin(); it != list.end(); ++it) |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (SearchMode != &SearchModes[2]) // match to pattern
|
|
|
|
rx.assign(itsConstraints[1], Config.regex_type); |
|
|
|
{ |
|
|
|
found = boost::regex_search(it->getArtist(), rx); |
|
|
|
if (!rx[0].empty()) |
|
|
|
} |
|
|
|
any_found = |
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
boost::regex_search(it->getArtist(), rx[0]) |
|
|
|
} |
|
|
|
|| boost::regex_search(it->getAlbumArtist(), rx[0]) |
|
|
|
if (found && !itsConstraints[2].empty()) |
|
|
|
|| boost::regex_search(it->getTitle(), rx[0]) |
|
|
|
{ |
|
|
|
|| boost::regex_search(it->getAlbum(), rx[0]) |
|
|
|
try |
|
|
|
|| boost::regex_search(it->getName(), rx[0]) |
|
|
|
{ |
|
|
|
|| boost::regex_search(it->getComposer(), rx[0]) |
|
|
|
rx.assign(itsConstraints[2], Config.regex_type); |
|
|
|
|| boost::regex_search(it->getPerformer(), rx[0]) |
|
|
|
found = boost::regex_search(it->getAlbumArtist(), rx); |
|
|
|
|| boost::regex_search(it->getGenre(), rx[0]) |
|
|
|
} |
|
|
|
|| boost::regex_search(it->getDate(), rx[0]) |
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
|| boost::regex_search(it->getComment(), rx[0]); |
|
|
|
} |
|
|
|
if (found && !rx[1].empty()) |
|
|
|
if (found && !itsConstraints[3].empty()) |
|
|
|
found = boost::regex_search(it->getArtist(), rx[1]); |
|
|
|
{ |
|
|
|
if (found && !rx[2].empty()) |
|
|
|
try |
|
|
|
found = boost::regex_search(it->getAlbumArtist(), rx[2]); |
|
|
|
{ |
|
|
|
if (found && !rx[3].empty()) |
|
|
|
rx.assign(itsConstraints[3], Config.regex_type); |
|
|
|
found = boost::regex_search(it->getTitle(), rx[3]); |
|
|
|
found = boost::regex_search(it->getTitle(), rx); |
|
|
|
if (found && !rx[4].empty()) |
|
|
|
} |
|
|
|
found = boost::regex_search(it->getAlbum(), rx[4]); |
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
if (found && !rx[5].empty()) |
|
|
|
} |
|
|
|
found = boost::regex_search(it->getName(), rx[5]); |
|
|
|
if (found && !itsConstraints[4].empty()) |
|
|
|
if (found && !rx[6].empty()) |
|
|
|
{ |
|
|
|
found = boost::regex_search(it->getComposer(), rx[6]); |
|
|
|
try |
|
|
|
if (found && !rx[7].empty()) |
|
|
|
{ |
|
|
|
found = boost::regex_search(it->getPerformer(), rx[7]); |
|
|
|
rx.assign(itsConstraints[4], Config.regex_type); |
|
|
|
if (found && !rx[8].empty()) |
|
|
|
found = boost::regex_search(it->getAlbum(), rx); |
|
|
|
found = boost::regex_search(it->getGenre(), rx[8]); |
|
|
|
} |
|
|
|
if (found && !rx[9].empty()) |
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
found = boost::regex_search(it->getDate(), rx[9]); |
|
|
|
} |
|
|
|
if (found && !rx[10].empty()) |
|
|
|
if (found && !itsConstraints[5].empty()) |
|
|
|
found = boost::regex_search(it->getComment(), rx[10]); |
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rx.assign(itsConstraints[5], Config.regex_type); |
|
|
|
|
|
|
|
found = boost::regex_search(it->getName(), rx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (found && !itsConstraints[6].empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rx.assign(itsConstraints[6], Config.regex_type); |
|
|
|
|
|
|
|
found = boost::regex_search(it->getComposer(), rx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (found && !itsConstraints[7].empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rx.assign(itsConstraints[7], Config.regex_type); |
|
|
|
|
|
|
|
found = boost::regex_search(it->getPerformer(), rx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (found && itsConstraints[8].empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rx.assign(itsConstraints[8], Config.regex_type); |
|
|
|
|
|
|
|
found = boost::regex_search(it->getGenre(), rx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (found && !itsConstraints[9].empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rx.assign(itsConstraints[9], Config.regex_type); |
|
|
|
|
|
|
|
found = boost::regex_search(it->getDate(), rx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (found && !itsConstraints[10].empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rx.assign(itsConstraints[10], Config.regex_type); |
|
|
|
|
|
|
|
found = boost::regex_search(it->getComment(), rx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (boost::bad_expression &) { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else // match only if values are equal
|
|
|
|
else // match only if values are equal
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|