From 3c9817f94592907c8c19a8b8f97af87dad3dceaf Mon Sep 17 00:00:00 2001 From: John Denker Date: Thu, 22 Nov 2012 16:01:04 -0800 Subject: move case-insensitive string stuff to utils.h --- tools/utils.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tools/utils.h') diff --git a/tools/utils.h b/tools/utils.h index 4f5418f..77cff5e 100644 --- a/tools/utils.h +++ b/tools/utils.h @@ -1,6 +1,35 @@ #include #include +std::string noCR(const std::string bar); +int cmp_casefold(const std::string& a, const std::string& b); + +///////////////////////////////////////////////////////// +// Case insensitive comparison of strings + +class lessthan_foldcase{ +public: + bool operator() (const std::string& a, const std::string& b) const { + size_t a_len = a.length(); + size_t b_len = b.length(); + + size_t lim = a_len < b_len ? a_len : b_len; + + for (size_t i=0; i chb) return false; + } + // here if one is an extension of the other + if ( a_len < b_len ) return true; + return false; + } +}; + + std::string basename(const std::string path); int prefix(const std::string shorter, const std::string longer); std::string time_out(const int _ttt); -- cgit v1.2.3