summaryrefslogtreecommitdiffhomepage
path: root/docs/csview_api.md
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-06-01 10:33:00 +0200
committerTyge Løvset <[email protected]>2022-06-01 10:33:00 +0200
commitd7a19420e0aec71a2a840f68a54549c8a951f929 (patch)
treed804c815661c4e5ae9c2a67eeed85cfe0b819b55 /docs/csview_api.md
parentc25b6d39f4ebbc1785108fd248b67fe9e8c95e92 (diff)
downloadSTC-modified-d7a19420e0aec71a2a840f68a54549c8a951f929.tar.gz
STC-modified-d7a19420e0aec71a2a840f68a54549c8a951f929.zip
Update docs regarding i_implement for cstr, cview, cbits, ...
Diffstat (limited to 'docs/csview_api.md')
-rw-r--r--docs/csview_api.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/csview_api.md b/docs/csview_api.md
index 8e665558..c60bec19 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -21,6 +21,8 @@ All csview definitions and prototypes are available by including a single header
```c
#include <stc/cstr.h> // optional, include cstr+csview functionality
+
+#define i_implement // define in one file only if needed
#include <stc/csview.h>
```
## Methods
@@ -40,6 +42,7 @@ char csview_back(csview sv);
void csview_clear(csview* self);
+// requires i_implement defined before one include of csview.h
csview csview_substr_ex(csview sv, intptr_t pos, size_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, csview sep, size_t* start); // see split example below.
@@ -122,6 +125,7 @@ uint64_t csview_hash(const csview* x);
## Example
```c
+#define i_implement
#include <stc/cstr.h>
#include <stc/csview.h>
@@ -152,6 +156,7 @@ red Apples
### Example 2: UTF8 handling
```c
+#define i_implement
#include <stc/cstr.h>
#include <stc/csview.h>
@@ -177,6 +182,7 @@ h,e,l,l,😀, ,w,x,r,l,d,
Splits strings into tokens. *print_split()* makes **no** memory allocations or *strlen()* calls,
and does not depend on null-terminated strings. *string_split()* function returns a vector of cstr.
```c
+#define i_implement // implement csview_token() function, define once.
#include <stc/csview.h>
void print_split(csview str, csview sep)
@@ -189,9 +195,11 @@ void print_split(csview str, csview sep)
}
}
+#define i_implement
+#include <stc/cstr.h>
+
#define i_val_str
#include <stc/cvec.h>
-#include <stc/csview.h>
cvec_str string_split(csview str, csview sep)
{