Enhancement
- Modified the closeEnough function to accept a minimum match length. Useful, but initially not used.
This commit is contained in:
@@ -676,12 +676,16 @@ bool compare (
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool closeEnough (const std::string& reference, const std::string& attempt)
|
bool closeEnough (
|
||||||
|
const std::string& reference,
|
||||||
|
const std::string& attempt,
|
||||||
|
unsigned int minLength /* = 0 */)
|
||||||
{
|
{
|
||||||
if (compare (reference, attempt, false))
|
if (compare (reference, attempt, false))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (attempt.length () < reference.length ())
|
if (attempt.length () < reference.length () &&
|
||||||
|
attempt.length () >= minLength)
|
||||||
return compare (reference.substr (0, attempt.length ()), attempt, false);
|
return compare (reference.substr (0, attempt.length ()), attempt, false);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ bool isWordEnd (const std::string&, std::string::size_type);
|
|||||||
bool isTokenEnd (const std::string&, std::string::size_type);
|
bool isTokenEnd (const std::string&, std::string::size_type);
|
||||||
bool isPunctuation (char);
|
bool isPunctuation (char);
|
||||||
bool compare (const std::string&, const std::string&, bool sensitive = true);
|
bool compare (const std::string&, const std::string&, bool sensitive = true);
|
||||||
bool closeEnough (const std::string&, const std::string&);
|
bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0);
|
||||||
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);
|
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);
|
||||||
std::string::size_type find (const std::string&, const std::string&, std::string::size_type, bool sensitive = true);
|
std::string::size_type find (const std::string&, const std::string&, std::string::size_type, bool sensitive = true);
|
||||||
int strippedLength (const std::string&);
|
int strippedLength (const std::string&);
|
||||||
|
|||||||
Reference in New Issue
Block a user