COMMON: Add case-insensitive comparator and hash for Common::Path
This commit is contained in:
parent
43d7259ff9
commit
ab517cc577
2 changed files with 26 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include "common/path.h"
|
#include "common/path.h"
|
||||||
#include "common/tokenizer.h"
|
#include "common/tokenizer.h"
|
||||||
#include "common/punycode.h"
|
#include "common/punycode.h"
|
||||||
|
#include "common/hash-str.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
|
@ -232,4 +233,12 @@ bool Path::matchPattern(const Path& pattern) const {
|
||||||
return punycodeDecode()._str.matchString(pattern.punycodeDecode()._str, true, wildcardExclusions);
|
return punycodeDecode()._str.matchString(pattern.punycodeDecode()._str, true, wildcardExclusions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Path::IgnoreCaseAndMac_EqualsTo::operator()(const Path& x, const Path& y) const {
|
||||||
|
return x.punycodeDecode()._str.equalsIgnoreCase(y.punycodeDecode()._str);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint Path::IgnoreCaseAndMac_Hash::operator()(const Path& x) const {
|
||||||
|
return hashit_lower(x.punycodeDecode()._str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
|
@ -52,6 +52,23 @@ private:
|
||||||
String _str;
|
String _str;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Hash and comparator for Path with following changes:
|
||||||
|
* * case-insensitive
|
||||||
|
* * decoding of punycode
|
||||||
|
* * Matching ':' and '/' inside path components to
|
||||||
|
* This allows a path "Sound Manager 3.1 / SoundLib<separator>Sound"
|
||||||
|
* to match both "xn--Sound Manager 3.1 SoundLib-lba84k/Sound"
|
||||||
|
* and "Sound Manager 3.1 : SoundLib/Sound"
|
||||||
|
*/
|
||||||
|
struct IgnoreCaseAndMac_EqualsTo {
|
||||||
|
bool operator()(const Path& x, const Path& y) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IgnoreCaseAndMac_Hash {
|
||||||
|
uint operator()(const Path& x) const;
|
||||||
|
};
|
||||||
|
|
||||||
/** Construct a new empty path. */
|
/** Construct a new empty path. */
|
||||||
Path() {}
|
Path() {}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue