2024-03-03 15:15:45 -08:00
|
|
|
#pragma once
|
2024-03-18 09:57:49 -07:00
|
|
|
|
|
|
|
// Type info and methods for Text datatype, which uses the Boehm "cord" library
|
|
|
|
// and libunistr
|
|
|
|
|
2024-03-03 15:15:45 -08:00
|
|
|
#include <gc/cord.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "types.h"
|
2024-05-20 12:19:31 -07:00
|
|
|
#include "where.h"
|
2024-03-03 15:15:45 -08:00
|
|
|
|
|
|
|
#define Text_t CORD
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
enum { FIND_FAILURE, FIND_SUCCESS } status;
|
|
|
|
int32_t index;
|
|
|
|
} find_result_t;
|
|
|
|
|
2024-03-29 09:54:31 -07:00
|
|
|
CORD Text$as_text(const void *str, bool colorize, const TypeInfo *info);
|
|
|
|
CORD Text$quoted(CORD str, bool colorize);
|
|
|
|
int Text$compare(const CORD *x, const CORD *y);
|
|
|
|
bool Text$equal(const CORD *x, const CORD *y);
|
|
|
|
uint32_t Text$hash(const CORD *cord);
|
|
|
|
CORD Text$upper(CORD str);
|
|
|
|
CORD Text$lower(CORD str);
|
|
|
|
CORD Text$title(CORD str);
|
2024-05-20 12:19:31 -07:00
|
|
|
bool Text$has(CORD str, CORD target, Where_t where);
|
|
|
|
CORD Text$without(CORD str, CORD target, Where_t where);
|
|
|
|
CORD Text$trimmed(CORD str, CORD skip, Where_t where);
|
2024-03-29 09:54:31 -07:00
|
|
|
find_result_t Text$find(CORD str, CORD pat);
|
|
|
|
CORD Text$replace(CORD text, CORD pat, CORD replacement, int64_t limit);
|
|
|
|
array_t Text$split(CORD str, CORD split);
|
|
|
|
CORD Text$join(CORD glue, array_t pieces);
|
|
|
|
array_t Text$clusters(CORD text);
|
|
|
|
array_t Text$codepoints(CORD text);
|
|
|
|
array_t Text$bytes(CORD text);
|
|
|
|
int64_t Text$num_clusters(CORD text);
|
|
|
|
int64_t Text$num_codepoints(CORD text);
|
|
|
|
int64_t Text$num_bytes(CORD text);
|
|
|
|
array_t Text$character_names(CORD text);
|
|
|
|
|
|
|
|
extern const TypeInfo $Text;
|
2024-03-03 15:15:45 -08:00
|
|
|
|
|
|
|
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0
|