From d003793402ee5e9c0ee2a5a7c96e03f67f7b84cc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 3 May 2014 12:32:26 +0100 Subject: Add ids_equal(). --- src/util.cc | 12 ++++++++++++ src/util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/util.cc b/src/util.cc index 80c3756b..3d37454f 100644 --- a/src/util.cc +++ b/src/util.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ using std::ostream; using boost::shared_ptr; using boost::optional; using boost::function; +using boost::algorithm::trim; using namespace dcp; /** Create a UUID. @@ -356,3 +358,13 @@ dcp::relative_to_root (boost::filesystem::path root, boost::filesystem::path fil return rel; } + +bool +dcp::ids_equal (string a, string b) +{ + transform (a.begin(), a.end(), a.begin(), ::tolower); + transform (b.begin(), b.end(), b.begin(), ::tolower); + trim (a); + trim (b); + return a == b; +} diff --git a/src/util.h b/src/util.h index d9f69b95..d3f212c7 100644 --- a/src/util.h +++ b/src/util.h @@ -77,6 +77,7 @@ extern std::string content_kind_to_string (ContentKind kind); extern ContentKind content_kind_from_string (std::string kind); extern bool empty_or_white_space (std::string s); extern boost::shared_ptr decompress_j2k (uint8_t* data, int64_t size, int reduce); +extern bool ids_equal (std::string a, std::string b); extern void init (); -- cgit v1.2.3