Make metadata tags case insensitive

This commit is contained in:
John Wiegley 2012-04-04 02:27:49 -05:00
parent 807cce12ff
commit 5a615ec680
2 changed files with 13 additions and 2 deletions

View file

@ -103,6 +103,16 @@ optional<value_t> item_t::get_tag(const mask_t& tag_mask,
return none;
}
namespace {
struct CaseInsensitiveKeyCompare
: public std::binary_function<string, string, bool>
{
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_t>& 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("<none>")) << "'");

View file

@ -108,7 +108,8 @@ public:
enum state_t { UNCLEARED = 0, CLEARED, PENDING };
typedef std::pair<optional<value_t>, bool> tag_data_t;
typedef std::map<string, tag_data_t> string_map;
typedef std::map<string, tag_data_t,
function<bool(string, string)> > string_map;
state_t _state;
optional<date_t> _date;