5#ifndef SPA_UTILS_STRING_H 
    6#define SPA_UTILS_STRING_H 
   22  #define SPA_API_STRING SPA_API_IMPL 
   24  #define SPA_API_STRING static inline 
   46        return SPA_LIKELY(s1 && s2) ? strcmp(s1, s2) == 0 : s1 == s2;
 
   56        return SPA_LIKELY(s1 && s2) ? strncmp(s1, s2, len) == 0 : s1 == s2;
 
   72        return strncmp(s, prefix, strlen(prefix)) == 0;
 
 
   92        return l1 >= l2 && 
spa_streq(s + l1 - l2, suffix);
 
 
  108        if (!str || *str ==
'\0')
 
  112        v = strtol(str, &endptr, base);
 
  113        if (errno != 0 || *endptr != 
'\0')
 
 
  134        unsigned long long v;
 
  136        if (!str || *str ==
'\0')
 
  140        v = strtoull(str, &endptr, base);
 
  141        if (errno != 0 || *endptr != 
'\0')
 
  144        if (v != (uint32_t)v)
 
 
  164        if (!str || *str ==
'\0')
 
  168        v = strtoll(str, &endptr, base);
 
  169        if (errno != 0 || *endptr != 
'\0')
 
 
  187        unsigned long long v;
 
  189        if (!str || *str ==
'\0')
 
  193        v = strtoull(str, &endptr, base);
 
  194        if (errno != 0 || *endptr != 
'\0')
 
 
  266#ifndef __LOCALE_C_ONLY 
  267        static locale_t locale = NULL;
 
  271#ifndef __LOCALE_C_ONLY 
  273                locale = newlocale(LC_ALL_MASK, 
"C", NULL);
 
  274        prev = uselocale(locale);
 
  276        v = strtof(str, endptr);
 
  277#ifndef __LOCALE_C_ONLY 
 
  295        if (!str || *str ==
'\0')
 
  299        if (errno != 0 || *endptr != 
'\0')
 
 
  316#ifndef __LOCALE_C_ONLY 
  317        static locale_t locale = NULL;
 
  321#ifndef __LOCALE_C_ONLY 
  323                locale = newlocale(LC_ALL_MASK, 
"C", NULL);
 
  324        prev = uselocale(locale);
 
  326        v = strtod(str, endptr);
 
  327#ifndef __LOCALE_C_ONLY 
 
  345        if (!str || *str ==
'\0')
 
  350        if (errno != 0 || *endptr != 
'\0')
 
  361        for (i = 0; i < l; i++)
 
 
  385        size_t remain = buf->maxsize - buf->pos;
 
 
  389        written = 
vsnprintf(&buf->buffer[buf->pos], remain, fmt, 
args);
 
  392                buf->pos += 
SPA_MIN(remain, (
size_t)written);
 
 
uint32_t int int const char va_list args
Definition core.h:434
vsnprintf(buffer, sizeof(buffer), message, args)
uint32_t int int const char int r
Definition core.h:447
SPA_API_STRING char * spa_dtoa(char *str, size_t size, double val)
Definition string.h:364
SPA_API_STRING int spa_strbuf_append(struct spa_strbuf *buf, const char *fmt,...)
Definition string.h:390
SPA_API_STRING 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:191
SPA_API_STRING bool spa_atof(const char *str, float *val)
Convert str to a float and store the result in val.
Definition string.h:297
SPA_API_STRING void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize)
Definition string.h:380
SPA_API_STRING bool spa_strendswith(const char *s, const char *suffix)
Definition string.h:88
SPA_API_STRING bool spa_strstartswith(const char *s, const char *prefix)
Definition string.h:72
SPA_API_STRING bool spa_strneq(const char *s1, const char *s2, size_t len)
Definition string.h:61
SPA_API_STRING bool spa_atob(const char *str)
Convert str to a boolean.
Definition string.h:214
SPA_API_STRING 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:166
SPA_API_STRING 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:110
SPA_API_STRING int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args)
Definition string.h:228
SPA_API_STRING double spa_strtod(const char *str, char **endptr)
Convert str to a double in the C locale.
Definition string.h:321
SPA_API_STRING float spa_strtof(const char *str, char **endptr)
Convert str to a float in the C locale.
Definition string.h:271
SPA_API_STRING int spa_scnprintf(char *buffer, size_t size, const char *format,...)
Definition string.h:251
SPA_API_STRING bool spa_atod(const char *str, double *val)
Convert str to a double and store the result in val.
Definition string.h:347
SPA_API_STRING 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:138
SPA_API_STRING bool spa_streq(const char *s1, const char *s2)
Definition string.h:51
#define SPA_MIN(a, b)
Definition defs.h:165
#define spa_assert_se(expr)
Definition defs.h:468
#define SPA_LIKELY(x)
Definition defs.h:392
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:295
#define SPA_UNLIKELY(x)
Definition defs.h:394
#define SPA_API_STRING
Definition string.h:31
size_t pos
Definition string.h:377
size_t maxsize
Definition string.h:376
char * buffer
Definition string.h:375