1
0
Fork 0

Update YSFReflectors.cpp

Revised search method for searching the whole YSF reflector name, not just the start.
ycs232-kbc
Andy Taylor 6 years ago committed by GitHub
parent 9495bb203b
commit 38b9cc3f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -305,16 +305,28 @@ std::vector<CYSFReflector*>& CYSFReflectors::search(const std::string& name)
trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), trimmed.end());
std::transform(trimmed.begin(), trimmed.end(), trimmed.begin(), ::toupper);
size_t len = trimmed.size();
// Removed now un-used variable
// size_t len = trimmed.size();
for (std::vector<CYSFReflector*>::iterator it = m_currReflectors.begin(); it != m_currReflectors.end(); ++it) {
std::string reflector = (*it)->m_name;
reflector.erase(std::find_if(reflector.rbegin(), reflector.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), reflector.end());
std::transform(reflector.begin(), reflector.end(), reflector.begin(), ::toupper);
if (trimmed == reflector.substr(0U, len))
// Origional match function - only matches start of string.
// if (trimmed == reflector.substr(0U, len))
// m_search.push_back(*it);
// New match function searches the whole string
unsigned int refSrcPos;
for (refSrcPos=0;refSrcPos<reflector.length(); refSrcPos++)
{
if (reflector.substr(refSrcPos,trimmed.length()) == trimmed)
{
m_search.push_back(*it);
}
}
}
std::sort(m_search.begin(), m_search.end(), refComparison);

Loading…
Cancel
Save