summaryrefslogtreecommitdiffhomepage
path: root/docs/csview_api.md
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-02-01 08:38:45 +0100
committerTyge Lovset <[email protected]>2023-02-01 08:38:45 +0100
commit6ce6ef3307e52db5813d3c8d6a2cba52df06daf8 (patch)
tree25af4be9fcd5e72778715b83ff312e157ca63b59 /docs/csview_api.md
parentb677a0c3950b8294ba6458e682a885351273ac08 (diff)
downloadSTC-modified-6ce6ef3307e52db5813d3c8d6a2cba52df06daf8.tar.gz
STC-modified-6ce6ef3307e52db5813d3c8d6a2cba52df06daf8.zip
Massive update from unsigned sizes and indices to signed.
Diffstat (limited to 'docs/csview_api.md')
-rw-r--r--docs/csview_api.md40
1 files changed, 20 insertions, 20 deletions
diff --git a/docs/csview_api.md b/docs/csview_api.md
index 4085a708..8064e4fd 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -27,31 +27,31 @@ All csview definitions and prototypes are available by including a single header
```c
csview c_SV(const char literal_only[]); // construct from literal, no strlen()
-csview c_SV(const char* str, size_t n); // construct from str and length n
+csview c_SV(const char* str, intptr_t n); // construct from str and length n
csview csview_lit(const char literal_only[]); // alias for c_SV(lit)
csview csview_from(const char* str); // construct from const char*
-csview csview_from_n(const char* str, size_t n); // alias for c_SV(str, n)
+csview csview_from_n(const char* str, intptr_t n); // alias for c_SV(str, n)
-size_t csview_size(csview sv);
+intptr_t csview_size(csview sv);
bool csview_empty(csview sv);
void csview_clear(csview* self);
bool csview_equals(csview sv, csview sv2);
-size_t csview_find(csview sv, const char* str);
-size_t csview_find_sv(csview sv, csview find);
+intptr_t csview_find(csview sv, const char* str);
+intptr_t csview_find_sv(csview sv, csview find);
bool csview_contains(csview sv, const char* str);
bool csview_starts_with(csview sv, const char* str);
bool csview_ends_with(csview sv, const char* str);
-csview csview_substr_ex(csview sv, intptr_t pos, size_t n); // negative pos count from end
+csview csview_substr_ex(csview sv, intptr_t pos, intptr_t n); // negative pos count from end
csview csview_slice_ex(csview sv, intptr_t p1, intptr_t p2); // negative p1, p2 count from end
-csview csview_token(csview sv, const char* sep, size_t* start); // *start > sv.size after last token
+csview csview_token(csview sv, const char* sep, intptr_t* start); // *start > sv.size after last token
```
#### UTF8 methods
```c
-size_t csview_u8_size(csview sv);
-csview csview_u8_substr(csview sv, size_t bytepos, size_t u8len);
+intptr_t csview_u8_size(csview sv);
+csview csview_u8_substr(csview sv, intptr_t bytepos, intptr_t u8len);
bool csview_valid_utf8(csview sv); // requires linking with src/utf8code.c
csview_iter csview_begin(const csview* self);
@@ -60,14 +60,14 @@ void csview_next(csview_iter* it); // utf8
csview_iter csview_advance(csview_iter it, intptr_t n);
// from utf8.h
-size_t utf8_size(const char *s);
-size_t utf8_size_n(const char *s, size_t nbytes); // number of UTF8 codepoints within n bytes
-const char* utf8_at(const char *s, size_t index); // from UTF8 index to char* position
-size_t utf8_pos(const char* s, size_t index); // from UTF8 index to byte index position
+intptr_t utf8_size(const char *s);
+intptr_t utf8_size_n(const char *s, intptr_t nbytes); // number of UTF8 codepoints within n bytes
+const char* utf8_at(const char *s, intptr_t index); // from UTF8 index to char* position
+intptr_t utf8_pos(const char* s, intptr_t index); // from UTF8 index to byte index position
unsigned utf8_chr_size(const char* s); // UTF8 character size: 1-4
// implemented in src/utf8code.c:
bool utf8_valid(const char* s);
-bool utf8_valid_n(const char* s, size_t nbytes);
+bool utf8_valid_n(const char* s, intptr_t nbytes);
uint32_t utf8_decode(utf8_decode_t *d, uint8_t byte); // decode next byte to utf8, return state.
unsigned utf8_encode(char *out, uint32_t codepoint); // encode unicode cp into out buffer
uint32_t utf8_peek(const char* s); // codepoint value of character at s
@@ -76,11 +76,11 @@ uint32_t utf8_peek_off(const char* s, int offset); // code
#### Extended cstr methods
```c
-csview cstr_substr(const cstr* self, size_t pos, size_t n);
-csview cstr_substr_ex(const cstr* s, intptr_t pos, size_t n); // negative pos count from end
-csview cstr_u8_substr(const cstr* self, size_t bytepos, size_t u8len);
+csview cstr_substr(const cstr* self, intptr_t pos, intptr_t n);
+csview cstr_substr_ex(const cstr* s, intptr_t pos, intptr_t n); // negative pos count from end
+csview cstr_u8_substr(const cstr* self, intptr_t bytepos, intptr_t u8len);
-csview cstr_slice(const cstr* self, size_t p1, size_t p2);
+csview cstr_slice(const cstr* self, intptr_t p1, intptr_t p2);
csview cstr_slice_ex(const cstr* s, intptr_t p, intptr_t q); // negative p or q count from end
```
#### Iterate tokens with *c_FORTOKEN*, *c_FORTOKEN_SV*
@@ -103,7 +103,7 @@ uint64_t csview_hash(const csview* x);
| Type name | Type definition | Used to represent... |
|:----------------|:-------------------------------------------|:-------------------------|
-| `csview` | `struct { const char *str; size_t size; }` | The string view type |
+| `csview` | `struct { const char *str; intptr_t size; }` | The string view type |
| `csview_value` | `char` | The string element type |
| `csview_iter` | `struct { csview_value *ref; }` | UTF8 iterator |
@@ -125,7 +125,7 @@ int main ()
// (quoting Alfred N. Whitehead)
csview sv1 = cstr_substr(&str1, 3, 5); // "think"
- size_t pos = cstr_find(&str1, "live"); // position of "live" in str1
+ intptr_t pos = cstr_find(&str1, "live"); // position of "live" in str1
csview sv2 = cstr_substr(&str1, pos, 4); // get "live"
csview sv3 = cstr_slice(&str1, -8, -1); // get "details"
printf("%.*s %.*s %.*s\n",