add PBD::downcase() functions to libpbd

This commit is contained in:
Paul Davis
2014-03-10 17:26:06 -04:00
parent 5ccf1e7346
commit b6a9bf5d04
2 changed files with 23 additions and 0 deletions

View File

@@ -18,6 +18,9 @@
*/
#include <cmath>
#include <algorithm>
#include <string>
#include <stdint.h>
#include <stdlib.h>
#include <cstdio>
@@ -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)
{

View File

@@ -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);