#ifndef UCX_STRING_H
#define UCX_STRING_H
#include "ucx.h"
#include "allocator.h"
#include <stddef.h>
#define ST(s) { (
char*)s,
sizeof(s)-
1 }
#define S(s) sstrn((
char*)s,
sizeof(s)-
1)
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char *ptr;
size_t length;
}
sstr_t;
sstr_t sstr(
char *cstring);
sstr_t sstrn(
char *cstring,
size_t length);
size_t sstrnlen(
size_t count,
sstr_t string, ...);
sstr_t sstrcat(
size_t count,
sstr_t s1,
sstr_t s2, ...);
sstr_t sstrcat_a(UcxAllocator *a,
size_t count,
sstr_t s1,
sstr_t s2, ...);
sstr_t sstrsubs(
sstr_t string,
size_t start);
sstr_t sstrsubsl(
sstr_t string,
size_t start,
size_t length);
sstr_t sstrchr(
sstr_t string,
int chr);
sstr_t sstrrchr(
sstr_t string,
int chr);
sstr_t sstrstr(
sstr_t string,
sstr_t match);
sstr_t* sstrsplit(
sstr_t string,
sstr_t delim,
ssize_t *count);
sstr_t* sstrsplit_a(UcxAllocator *allocator,
sstr_t string,
sstr_t delim,
ssize_t *count);
int sstrcmp(
sstr_t s1,
sstr_t s2);
int sstrcasecmp(
sstr_t s1,
sstr_t s2);
sstr_t sstrdup(
sstr_t string);
sstr_t sstrdup_a(UcxAllocator *allocator,
sstr_t string);
sstr_t sstrtrim(
sstr_t string);
int sstrprefix(
sstr_t string,
sstr_t prefix);
int sstrsuffix(
sstr_t string,
sstr_t suffix);
sstr_t sstrlower(
sstr_t string);
sstr_t sstrlower_a(UcxAllocator *allocator,
sstr_t string);
sstr_t sstrupper(
sstr_t string);
sstr_t sstrupper_a(UcxAllocator *allocator,
sstr_t string);
#ifdef __cplusplus
}
#endif
#endif