29 #ifndef __STDC_FORMAT_MACROS
30 #define __STDC_FORMAT_MACROS
52 ret[0] = toupper (str[0]);
61 std::transform (copy.begin(), copy.end(), copy.begin(), ::tolower);
68 char *copy = strdup (str);
69 for (
char* p = copy; *p; ++p) {
87 string::size_type pos;
91 while (orig.length() > target_length) {
92 if ((pos = orig.find_last_of (
_(
"\"\n\t ,<.>/?:;'[{}]~`!@#$%^&*()_-+="))) == string::npos) {
95 orig.replace (pos, 1,
"");
100 while (orig.length() > target_length) {
101 if ((pos = orig.find_last_of (
_(
"aeiou"))) == string::npos) {
104 orig.replace (pos, 1,
"");
109 while (orig.length() > target_length) {
110 if ((pos = orig.find_last_of (
_(
"AEIOU"))) == string::npos) {
113 orig.replace (pos, 1,
"");
118 while (orig.length() > target_length) {
119 if ((pos = orig.find_last_of (
_(
"bcdfghjklmnpqrtvwxyz"))) == string::npos) {
122 orig.replace (pos, 1,
"");
127 while (orig.length() > target_length) {
128 if ((pos = orig.find_last_of (
_(
"BCDFGHJKLMNPQRTVWXYZ"))) == string::npos) {
131 orig.replace (pos, 1,
"");
148 return (int32_t)
::atol (s.c_str());
154 return (int64_t)
::atoll (s.c_str());
168 for (uint32_t i = 0; array[i]; ++i) {
169 v.push_back (
dgettext(package_name, array[i]));
183 if( (
'0'<=hi) && (hi<=
'9') ) {
185 }
else if( (
'a'<= hi) && (hi<=
'f') ) {
187 }
else if( (
'A'<=hi) && (hi<=
'F') ) {
193 if( (
'0'<=lo) && (lo<=
'9') ) {
195 }
else if( (
'a'<=lo) && (lo<=
'f') ) {
197 }
else if( (
'A'<=lo) && (lo<=
'F') ) {
201 return lo + (16 * hi);
209 for (string::size_type i = 0; i < url.length(); ++i) {
212 }
else if (url[i] ==
'%' && i <= url.length() - 3) {
213 decoded += char (
int_from_hex (url[i + 1], url[i + 2]));
225 length2string (
const int32_t frames,
const float sample_rate)
227 int32_t secs = (int32_t) (frames / sample_rate);
228 int32_t hrs = secs / 3600;
229 secs -= (hrs * 3600);
230 int32_t mins = secs / 60;
233 int32_t total_secs = (hrs * 3600) + (mins * 60) + secs;
234 int32_t frames_remaining = (int) floor (frames - (total_secs * sample_rate));
235 float fractional_secs = (float) frames_remaining / sample_rate;
237 char duration_str[32];
238 sprintf (duration_str,
"%02" PRIi32
":%02" PRIi32
":%05.2f", hrs, mins, (
float) secs + fractional_secs);
247 int64_t secs = (int64_t) floor (frames / sample_rate);
248 int64_t hrs = secs / 3600LL;
249 secs -= (hrs * 3600LL);
250 int64_t mins = secs / 60LL;
251 secs -= (mins * 60LL);
253 int64_t total_secs = (hrs * 3600LL) + (mins * 60LL) + secs;
254 int64_t frames_remaining = (int64_t) floor (frames - (total_secs * sample_rate));
255 float fractional_secs = (float) frames_remaining / sample_rate;
257 char duration_str[64];
258 sprintf (duration_str,
"%02" PRIi64
":%02" PRIi64
":%05.2f", hrs, mins, (
float) secs + fractional_secs);
269 return toupper (x) == toupper (y);
275 if (a.length() == b.length()) {
297 return str ==
"1" || str ==
"y" || str ==
"Y" || (!g_ascii_strncasecmp(str.c_str(),
"yes", str.length())) ||
298 (!g_ascii_strncasecmp(str.c_str(),
"true", str.length()));
307 sgettext (
const char* domain_name,
const char* msgid)
309 const char * msgval =
dgettext (domain_name, msgid);
310 if (msgval == msgid) {
311 const char * p = strrchr (msgid,
'|');
int atoi(const string &s)
string capitalize(const string &str)
bool strings_equal_ignore_case(const string &a, const string &b)
int64_t atoll(const string &s)
const char * sgettext(const char *domain_name, const char *msgid)
static bool chars_equal_ignore_case(char x, char y)
static int32_t int_from_hex(char hic, char loc)
string downcase(const string &str)
int32_t atol(const string &s)
vector< string > internationalize(const char *package_name, const char **array)
bool string_is_affirmative(const std::string &str)
string url_decode(string const &url)
string length2string(const int64_t frames, const double sample_rate)
#define dgettext(Domainname, Msgid)
string short_version(string orig, string::size_type target_length)
double atof(const string &s)