summaryrefslogtreecommitdiffhomepage
path: root/docs/csview_api.md
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-08-17 05:34:38 +0200
committerTyge Lovset <[email protected]>2023-08-17 05:34:38 +0200
commitbe0e64a9a19d3ca459284c61c497d141a78df1d7 (patch)
treee2005e0a29d9e7386647ad9d92411635d01574c6 /docs/csview_api.md
parent2ba238e66efec7b6d895425c4f1160b3b72d242b (diff)
downloadSTC-modified-be0e64a9a19d3ca459284c61c497d141a78df1d7.tar.gz
STC-modified-be0e64a9a19d3ca459284c61c497d141a78df1d7.zip
Renamed "internal" csview member .str => .buf, as it is not null terminated like crawstr .str member.
Diffstat (limited to 'docs/csview_api.md')
-rw-r--r--docs/csview_api.md20
1 files changed, 10 insertions, 10 deletions
diff --git a/docs/csview_api.md b/docs/csview_api.md
index eafc6854..5202d6f5 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -1,14 +1,14 @@
# STC [csview](../include/stc/csview.h): Sub-string View
![String](pics/string.jpg)
-The type **csview** is a non-null terminated string view and can refer to a constant contiguous sequence of
-char-elements with the first element of the sequence at position zero. The implementation holds two members:
-a pointer to constant char and a size.
+The type **csview** is a non-null terminated string view and can refer to a constant contiguous
+sequence of char-elements with the first element of the sequence at position zero. The implementation
+holds two members: a pointer to constant char and a size.
-Because **csview** is non-null terminated, it is not an ideal replacent view for `const char*` - see [crawstr](crawstr_api.md)
-for that. **csview** never allocates memory, and therefore need not be destructed. Its lifetime is limited by
-the source string storage. It keeps the length of the string, and does not need to call *strlen()* to acquire
-the length.
+Because **csview** is non-null terminated, it cannot be a replacent view for `const char*` -
+see [crawstr](crawstr_api.md) for that. **csview** never allocates memory, and therefore need not be
+destructed. Its lifetime is limited by the source string storage. It keeps the length of the string,
+and does not need to call *strlen()* to acquire the length.
- **csview** iterators works on UTF8 codepoints - like **cstr** and **crawstr** (see Example 2).
- Because it is null-terminated, it must be printed the following way:
@@ -16,8 +16,8 @@ the length.
printf("%.*s", c_SV(sstr));
```
-See the c++ class [std::basic_string_view](https://en.cppreference.com/w/cpp/string/basic_string_view) for a functional
-description.
+See the c++ class [std::basic_string_view](https://en.cppreference.com/w/cpp/string/basic_string_view)
+for a functional description.
## Header file
@@ -95,7 +95,7 @@ uint64_t csview_hash(const csview* x);
| Type name | Type definition | Used to represent... |
|:----------------|:-------------------------------------------|:-------------------------|
-| `csview` | `struct { const char *str; intptr_t size; }` | The string view type |
+| `csview` | `struct { const char *buf; intptr_t size; }` | The string view type |
| `csview_value` | `char` | The string element type |
| `csview_iter` | `struct { csview_value *ref; }` | UTF8 iterator |