diff options
| author | tylov <[email protected]> | 2023-08-13 23:15:45 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-08-13 23:15:45 +0200 |
| commit | 25dc58db206714dc02c1ae0548f6ba7dd3519d29 (patch) | |
| tree | dcf65b08300d82c4d6752284d5c0a5a00507f07f /include/stc/forward.h | |
| parent | 8bb2f5618e4cefe668a663936354cf53191f2129 (diff) | |
| download | STC-modified-25dc58db206714dc02c1ae0548f6ba7dd3519d29.tar.gz STC-modified-25dc58db206714dc02c1ae0548f6ba7dd3519d29.zip | |
API CHANGES:
Changed csview: becomes a null-terminated string view.
Added csubview: a null-terminated string view/span, like previous csview.
Note that csview works like a csubview, so not much compability issues should arise.
However, some functions have changed from _sv suffix to _ss.
Diffstat (limited to 'include/stc/forward.h')
| -rw-r--r-- | include/stc/forward.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/include/stc/forward.h b/include/stc/forward.h index 572a319f..5c9c4f4d 100644 --- a/include/stc/forward.h +++ b/include/stc/forward.h @@ -39,8 +39,21 @@ #define forward_cqueue(CX, VAL) _c_cdeq_types(CX, VAL) #define forward_cvec(CX, VAL) _c_cvec_types(CX, VAL) -// csview -typedef const char csview_value; +// csubstr : non-null terminated string view +typedef const char csubstr_value; +typedef struct csubstr { + csubstr_value* str; + intptr_t size; +} csubstr; + +typedef union { + csubstr_value* ref; + struct { csubstr chr; csubstr_value* end; } u8; +} csubstr_iter; + + +// csview : null-terminated string view +typedef csubstr_value csview_value; typedef struct csview { csview_value* str; intptr_t size; @@ -48,10 +61,11 @@ typedef struct csview { typedef union { csview_value* ref; - struct { csview chr; csview_value* end; } u8; + struct { csubstr chr; } u8; } csview_iter; -// cstr + +// cstr : null-terminated string (short string optimized - sso) typedef char cstr_value; typedef struct { cstr_value* data; intptr_t size, cap; } cstr_buf; typedef union cstr { @@ -61,9 +75,10 @@ typedef union cstr { typedef union { cstr_value* ref; - struct { csview chr; } u8; + struct { csubstr chr; } u8; } cstr_iter; + #define c_true(...) __VA_ARGS__ #define c_false(...) |
