// Kyler Olsen
// YREA SLS
// Strings Header
// November 2025

#ifndef SLS_STRING_H
#define SLS_STRING_H

#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>

#include "bool.h"

typedef struct {
    size_t len; // Number of useable characters (does not include trailing null character)
    char *str;
    Boolean allocated;
} SlsStr;

#define SLS_STR_CONST(s) {sizeof(s) - 1, (s), FALSE}
#define SLS_STR_NULL_CONST {0, NULL, FALSE}
#define SLS_STR(s) (SlsStr) SLS_STR_CONST(s)
#define SLS_STR_NULL (SlsStr) SLS_STR_NULL_CONST

int sls_isascii(unsigned char c);
size_t sls_str_nlen(const char *s, size_t maxlen);
SlsStr sls_str_malloc(const char *s, size_t maxlen);
SlsStr sls_str_new(size_t length);
SlsStr sls_str_cpy(SlsStr s);
int32_t sls_str_cmp(SlsStr a, SlsStr b);
void sls_str_free(SlsStr *s);
SlsStr sls_format(const SlsStr s, ...);

#endif // SLS_STRING_H
