From b6a9bf5d043bf74cdb5aebc11b54e0c187e225ad Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 10 Mar 2014 17:26:06 -0400 Subject: [PATCH] add PBD::downcase() functions to libpbd --- libs/pbd/convert.cc | 21 +++++++++++++++++++++ libs/pbd/pbd/convert.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/libs/pbd/convert.cc b/libs/pbd/convert.cc index 1787d3b70d..940aa87189 100644 --- a/libs/pbd/convert.cc +++ b/libs/pbd/convert.cc @@ -18,6 +18,9 @@ */ #include +#include +#include + #include #include #include @@ -51,6 +54,24 @@ capitalize (const string& str) return ret; } +string +downcase (const string& str) +{ + string copy (str); + std::transform (copy.begin(), copy.end(), copy.begin(), ::tolower); + return copy; +} + +const char* +downcase (const char* str) +{ + char *copy = strdup (str); + for (char* p = copy; *p; ++p) { + *p = tolower (*p); + } + return copy; +} + string short_version (string orig, string::size_type target_length) { diff --git a/libs/pbd/pbd/convert.h b/libs/pbd/pbd/convert.h index 6580a6e8e7..b5c7e10f5d 100644 --- a/libs/pbd/pbd/convert.h +++ b/libs/pbd/pbd/convert.h @@ -40,6 +40,8 @@ LIBPBD_API double atof (const std::string&); LIBPBD_API std::string url_decode (std::string const &); LIBPBD_API std::string capitalize (const std::string&); +LIBPBD_API std::string downcase (const std::string&); +LIBPBD_API const char* downcase (const char*); // std::string length2string (const int32_t frames, const float sample_rate); LIBPBD_API std::string length2string (const int64_t frames, const double sample_rate);