diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-03 18:15:45 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-03 18:15:45 -0500 |
| commit | 8fab88c56f95c03ffcb4be178f5dbb21b239d95e (patch) | |
| tree | 3c2e721b8ea55d43b94fa9f315659580652573c5 /builtins/text.h | |
| parent | 07f0a18136a7883d1f3edd3e08253bd3020294a8 (diff) | |
Rename Str -> Text
Diffstat (limited to 'builtins/text.h')
| -rw-r--r-- | builtins/text.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/builtins/text.h b/builtins/text.h new file mode 100644 index 00000000..a8782d24 --- /dev/null +++ b/builtins/text.h @@ -0,0 +1,35 @@ +#pragma once +#include <gc/cord.h> +#include <stdbool.h> +#include <stdint.h> + +#include "types.h" + +#define Text_t CORD + +typedef enum { WHERE_ANYWHERE, WHERE_START, WHERE_END } where_e; + +typedef struct { + enum { FIND_FAILURE, FIND_SUCCESS } status; + int32_t index; +} find_result_t; + +CORD Text__as_str(const void *str, bool colorize, const TypeInfo *info); +CORD Text__quoted(CORD str, bool colorize); +int Text__compare(CORD *x, CORD *y); +bool Text__equal(CORD *x, CORD *y); +uint32_t Text__hash(CORD *cord); +CORD Text__upper(CORD str); +CORD Text__lower(CORD str); +CORD Text__title(CORD str); +bool Text__has(CORD str, CORD target, where_e where); +CORD Text__without(CORD str, CORD target, where_e where); +CORD Text__trimmed(CORD str, CORD skip, where_e where); +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); + +extern const TypeInfo Text; + +// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
