]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
LookupTable must be case-insensitive
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 30 Jul 2015 12:35:58 +0000 (14:35 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 30 Jul 2015 12:35:58 +0000 (14:35 +0200)
src/base/LookupTable.h

index 795f499800175dcace1d0b379512d71813dc6213..265d44e0d057a6558ce908738cfac4ee87900e30 100644 (file)
@@ -14,7 +14,7 @@
 #include <map>
 
 /**
- * a record in he initializer list for a LookupTable
+ * a record in the initializer list for a LookupTable
  *
  * In case it is wished to extend the structure of a LookupTable's initializer
  * list, it can be done by using a custom struct which must match
@@ -30,7 +30,7 @@ struct LookupTableRecord
 };
 
 /**
- * SBuf -> enum lookup table
+ * SBuf -> case-insensitive enum lookup table
  *
  * How to use:
  * enum enum_type { ... };
@@ -45,6 +45,12 @@ struct LookupTableRecord
  * if (item != ENUM_INVALID_VALUE) { // do stuff }
  *
  */
+
+struct SBufCaseInsensitiveLess : public std::binary_function<SBuf, SBuf, bool> {
+    bool operator() (const SBuf &x, const SBuf &y) const {
+        return x.caseCmp(y) < 0;
+    }
+};
 template<typename EnumType, typename RecordType = LookupTableRecord<EnumType> >
 class LookupTable
 {
@@ -68,7 +74,7 @@ public:
     }
 
 private:
-    typedef std::map<const SBuf, EnumType> lookupTable_t;
+    typedef std::map<const SBuf, EnumType, SBufCaseInsensitiveLess> lookupTable_t;
     lookupTable_t lookupTable;
     EnumType invalidValue;
 };