25 #ifndef SPA_UTILS_STRING_H 
   26 #define SPA_UTILS_STRING_H 
   56 static inline bool spa_streq(
const char *s1, 
const char *s2)
 
   58         return SPA_LIKELY(s1 && s2) ? strcmp(s1, s2) == 0 : s1 == s2;
 
   66 static inline bool spa_strneq(
const char *s1, 
const char *s2, 
size_t len)
 
   68         return SPA_LIKELY(s1 && s2) ? strncmp(s1, s2, len) == 0 : s1 == s2;
 
   84         return strncmp(s, prefix, strlen(prefix)) == 0;
 
  104         return l1 >= l2 && 
spa_streq(s + l1 - l2, suffix);
 
  115 static inline bool spa_atoi32(
const char *str, int32_t *val, 
int base)
 
  120         if (!str || *str ==
'\0')
 
  124         v = strtol(str, &endptr, base);
 
  125         if (errno != 0 || *endptr != 
'\0')
 
  143 static inline bool spa_atou32(
const char *str, uint32_t *val, 
int base)
 
  146         unsigned long long v;
 
  148         if (!str || *str ==
'\0')
 
  152         v = strtoull(str, &endptr, base);
 
  153         if (errno != 0 || *endptr != 
'\0')
 
  156         if (v != (uint32_t)v)
 
  171 static inline bool spa_atoi64(
const char *str, int64_t *val, 
int base)
 
  176         if (!str || *str ==
'\0')
 
  180         v = strtoll(str, &endptr, base);
 
  181         if (errno != 0 || *endptr != 
'\0')
 
  196 static inline bool spa_atou64(
const char *str, uint64_t *val, 
int base)
 
  199         unsigned long long v;
 
  201         if (!str || *str ==
'\0')
 
  205         v = strtoull(str, &endptr, base);
 
  206         if (errno != 0 || *endptr != 
'\0')
 
  219 static inline bool spa_atob(
const char *str)
 
  233 static inline 
int spa_vscnprintf(
char *buffer, 
size_t size, const 
char *format, va_list args)
 
  239         r = vsnprintf(buffer, size, format, args);
 
  256 static inline 
int spa_scnprintf(
char *buffer, 
size_t size, const 
char *format, ...)
 
  261         va_start(args, format);
 
  276 static inline float spa_strtof(
const char *str, 
char **endptr)
 
  278 #ifndef __LOCALE_C_ONLY 
  279         static locale_t locale = NULL;
 
  283 #ifndef __LOCALE_C_ONLY 
  285                 locale = newlocale(LC_ALL_MASK, 
"C", NULL);
 
  286         prev = uselocale(locale);
 
  288         v = strtof(str, endptr);
 
  289 #ifndef __LOCALE_C_ONLY 
  302 static inline bool spa_atof(
const char *str, 
float *val)
 
  307         if (!str || *str ==
'\0')
 
  311         if (errno != 0 || *endptr != 
'\0')
 
  326 static inline double spa_strtod(
const char *str, 
char **endptr)
 
  328 #ifndef __LOCALE_C_ONLY 
  329         static locale_t locale = NULL;
 
  333 #ifndef __LOCALE_C_ONLY 
  335                 locale = newlocale(LC_ALL_MASK, 
"C", NULL);
 
  336         prev = uselocale(locale);
 
  338         v = strtod(str, endptr);
 
  339 #ifndef __LOCALE_C_ONLY 
  352 static inline bool spa_atod(
const char *str, 
double *val)
 
  357         if (!str || *str ==
'\0')
 
  362         if (errno != 0 || *endptr != 
'\0')
 
  369 static inline char *
spa_dtoa(
char *str, 
size_t size, 
double val)
 
  373         for (i = 0; i < l; i++)
 
static bool spa_atod(const char *str, double *val)
Convert str to a double and store the result in val.
Definition: string.h:357
 
static bool spa_atou64(const char *str, uint64_t *val, int base)
Convert str to an uint64_t with the given base and store the result in val.
Definition: string.h:201
 
static bool spa_strstartswith(const char *s, const char *prefix)
Definition: string.h:82
 
static double spa_strtod(const char *str, char **endptr)
Convert str to a double in the C locale.
Definition: string.h:331
 
static bool spa_atob(const char *str)
Convert str to a boolean.
Definition: string.h:224
 
static bool spa_atoi64(const char *str, int64_t *val, int base)
Convert str to an int64_t with the given base and store the result in val.
Definition: string.h:176
 
static bool spa_atou32(const char *str, uint32_t *val, int base)
Convert str to an uint32_t with the given base and store the result in val.
Definition: string.h:148
 
static bool spa_atoi32(const char *str, int32_t *val, int base)
Convert str to an int32_t with the given base and store the result in val.
Definition: string.h:120
 
static bool spa_strendswith(const char *s, const char *suffix)
Definition: string.h:98
 
static bool spa_strneq(const char *s1, const char *s2, size_t len)
Definition: string.h:71
 
static float spa_strtof(const char *str, char **endptr)
Convert str to a float in the C locale.
Definition: string.h:281
 
static int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args)
Definition: string.h:238
 
static bool spa_streq(const char *s1, const char *s2)
Definition: string.h:61
 
static bool spa_atof(const char *str, float *val)
Convert str to a float and store the result in val.
Definition: string.h:307
 
static int spa_scnprintf(char *buffer, size_t size, const char *format,...)
Definition: string.h:261
 
static char * spa_dtoa(char *str, size_t size, double val)
Definition: string.h:374
 
#define spa_assert_se(expr)
Definition: defs.h:385
 
#define SPA_LIKELY(x)
Definition: defs.h:353
 
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:289
 
#define SPA_UNLIKELY(x)
Definition: defs.h:355