From 5a615ec680190222e25047366f166f9daf89c69f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 4 Apr 2012 02:27:49 -0500 Subject: Make metadata tags case insensitive --- src/item.cc | 12 +++++++++++- src/item.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/item.cc b/src/item.cc index 06b718b0..5262d1db 100644 --- a/src/item.cc +++ b/src/item.cc @@ -103,6 +103,16 @@ optional item_t::get_tag(const mask_t& tag_mask, return none; } +namespace { + struct CaseInsensitiveKeyCompare + : public std::binary_function + { + bool operator()(const string& s1, const string& s2) const { + return boost::algorithm::ilexicographical_compare(s1, s2); + } + }; +} + item_t::string_map::iterator item_t::set_tag(const string& tag, const optional& value, @@ -111,7 +121,7 @@ item_t::set_tag(const string& tag, assert(! tag.empty()); if (! metadata) - metadata = string_map(); + metadata = string_map(CaseInsensitiveKeyCompare()); DEBUG("item.meta", "Setting tag '" << tag << "' to value '" << (value ? *value : string_value("")) << "'"); diff --git a/src/item.h b/src/item.h index 1e8db1e0..c56fba27 100644 --- a/src/item.h +++ b/src/item.h @@ -108,7 +108,8 @@ public: enum state_t { UNCLEARED = 0, CLEARED, PENDING }; typedef std::pair, bool> tag_data_t; - typedef std::map string_map; + typedef std::map > string_map; state_t _state; optional _date; -- cgit v1.2.3