summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-05-23 14:33:24 +0200
committerTyge Lovset <[email protected]>2023-05-23 14:33:24 +0200
commitf80a78239f545d7d73c8358056dd5d5825ccfe0b (patch)
tree83b3e266555f1d4bd42412ea5a711a49e3002396 /docs
parent0b34cadda2bc4da1cb0904989c8a5f2fe0236358 (diff)
downloadSTC-modified-f80a78239f545d7d73c8358056dd5d5825ccfe0b.tar.gz
STC-modified-f80a78239f545d7d73c8358056dd5d5825ccfe0b.zip
Updated docs to reflect changes in cstr linking shared.
Diffstat (limited to 'docs')
-rw-r--r--docs/carc_api.md1
-rw-r--r--docs/ccommon_api.md1
-rw-r--r--docs/cmap_api.md4
-rw-r--r--docs/crandom_api.md1
-rw-r--r--docs/cset_api.md1
-rw-r--r--docs/csmap_api.md4
-rw-r--r--docs/csset_api.md1
-rw-r--r--docs/cstr_api.md1
-rw-r--r--docs/csview_api.md26
-rw-r--r--docs/cvec_api.md2
10 files changed, 29 insertions, 13 deletions
diff --git a/docs/carc_api.md b/docs/carc_api.md
index 48b64ff0..9f3d8cb9 100644
--- a/docs/carc_api.md
+++ b/docs/carc_api.md
@@ -78,6 +78,7 @@ bool carc_X_value_eq(const i_val* x, const i_val* y);
// Create two stacks with carcs to maps.
// Demonstrate sharing and cloning of maps.
// Show elements dropped.
+#define i_implement
#include <stc/cstr.h>
#define i_type Map
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 56424989..cdd4ec87 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -470,6 +470,7 @@ return ok;
**Example 2**: Load each line of a text file into a vector of strings:
```c
#include <errno.h>
+#define i_implement
#include <stc/cstr.h>
#define i_val_str
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 2c9ac8ed..69e547a0 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -114,6 +114,7 @@ bool c_memcmp_eq(const i_keyraw* a, const i_keyraw* b); // !
## Examples
```c
+#define i_implement
#include <stc/cstr.h>
#define i_key_str
@@ -157,6 +158,7 @@ The HEX of color BLACK is:[#000000]
### Example 2
This example uses a cmap with cstr as mapped value.
```c
+#define i_implement
#include <stc/cstr.h>
#define i_type IDMap
#define i_key int
@@ -267,6 +269,7 @@ Output:
### Example 5: Advanced
Key type is struct.
```c
+#define i_implement
#include <stc/cstr.h>
typedef struct {
@@ -335,6 +338,7 @@ In example 5 we needed to construct a lookup key which allocated strings, and th
In this example we use rawtype feature to make it even simpler to use. Note that we must use the emplace() methods
to add "raw" type entries (otherwise compile error):
```c
+#define i_implement
#include <stc/cstr.h>
typedef struct Viking {
diff --git a/docs/crandom_api.md b/docs/crandom_api.md
index 7281b2d7..74e23a6a 100644
--- a/docs/crandom_api.md
+++ b/docs/crandom_api.md
@@ -67,6 +67,7 @@ double crand_norm(crand_t* rng, crand_norm_t* dist);
```c
#include <time.h>
#include <stc/crand.h>
+#define i_implement
#include <stc/cstr.h>
// Declare int -> int sorted map. Uses typetag 'i' for ints.
diff --git a/docs/cset_api.md b/docs/cset_api.md
index 7243beb3..ecf87e5b 100644
--- a/docs/cset_api.md
+++ b/docs/cset_api.md
@@ -77,6 +77,7 @@ cset_X_value cset_X_value_clone(cset_X_value val);
## Example
```c
+#define i_implement
#include <stc/cstr.h>
#define i_type Strset
#define i_key_str
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index b1bb07c6..2fd9f6a5 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -102,8 +102,8 @@ void csmap_X_value_drop(csmap_X_value* pval);
## Examples
```c
+#define i_implement
#include <stc/cstr.h>
-
#define i_key_str // special macro for i_key = cstr, i_tag = str
#define i_val_str // ditto
#include <stc/csmap.h>
@@ -150,6 +150,7 @@ Translate a
[ [Run this code](https://godbolt.org/z/9d1PP77Pa) ]
```c
+#define i_implement
#include <stc/cstr.h>
#define i_type strmap
#define i_key_str
@@ -182,6 +183,7 @@ int main()
### Example 3
This example uses a csmap with cstr as mapped value.
```c
+#define i_implement
#include <stc/cstr.h>
#define i_type IDSMap
diff --git a/docs/csset_api.md b/docs/csset_api.md
index dafe6670..5695ecf6 100644
--- a/docs/csset_api.md
+++ b/docs/csset_api.md
@@ -76,6 +76,7 @@ csset_X_value csset_X_value_clone(csset_X_value val);
## Example
```c
+#define i_implement
#include <stc/cstr.h>
#define i_type SSet
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index 64ad002c..438dbf27 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -157,6 +157,7 @@ char* cstrnstrn(const char* str, const char* search, intptr_t slen, intpt
## Example
```c
+#define i_implement
#include <stc/cstr.h>
int main() {
diff --git a/docs/csview_api.md b/docs/csview_api.md
index ec3bf121..b697b7d6 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -20,8 +20,9 @@ description.
All csview definitions and prototypes are available by including a single header file.
```c
-#include <stc/cstr.h> // optional, include cstr+csview functionality
-#include <stc/csview.h>
+#define i_implement
+#include <stc/cstr.h>
+#include <stc/csview.h> // after cstr.h: include extra cstr-csview functions
```
## Methods
@@ -116,23 +117,24 @@ uint64_t csview_hash(const csview* x);
## Example
```c
+#define i_implement
#include <stc/cstr.h>
#include <stc/csview.h>
int main ()
{
cstr str1 = cstr_lit("We think in generalities, but we live in details.");
- // (quoting Alfred N. Whitehead)
+ // (quoting Alfred N. Whitehead)
- csview sv1 = cstr_substr(&str1, 3, 5); // "think"
- 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"
+ csview sv1 = cstr_substr_ex(&str1, 3, 5); // "think"
+ intptr_t pos = cstr_find(&str1, "live"); // position of "live" in str1
+ csview sv2 = cstr_substr_ex(&str1, pos, 4); // get "live"
+ csview sv3 = cstr_slice_ex(&str1, -8, -1); // get "details"
printf("%.*s %.*s %.*s\n",
c_SV(sv1), c_SV(sv2), c_SV(sv3));
cstr s1 = cstr_lit("Apples are red");
- cstr s2 = cstr_from_sv(cstr_substr(&s1, -3, 3)); // "red"
- cstr s3 = cstr_from_sv(cstr_substr(&s1, 0, 6)); // "Apples"
+ cstr s2 = cstr_from_sv(cstr_substr_ex(&s1, -3, 3)); // "red"
+ cstr s3 = cstr_from_sv(cstr_substr_ex(&s1, 0, 6)); // "Apples"
printf("%s %s\n", cstr_str(&s2), cstr_str(&s3));
c_drop(cstr, &str1, &s1, &s2, &s3);
@@ -146,8 +148,8 @@ red Apples
### Example 2: UTF8 handling
```c
-#include <stc/cstr.h>
-#include <stc/csview.h>
+#define i_extern
+#include <stc/cstr.h> // i_extern: implement cstr + dependencies (utf8)
int main()
{
@@ -181,7 +183,7 @@ void print_split(csview input, const char* sep)
printf("[%.*s]\n", c_SV(i.token));
puts("");
}
-
+#define i_implement
#include <stc/cstr.h>
#define i_val_str
#include <stc/cstack.h>
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index 841321b2..fa7bf8ca 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -148,6 +148,7 @@ sorted: 5 7 8 13 16 25
```
### Example 2
```c
+#define i_implement
#include <stc/cstr.h>
#define i_val_str
@@ -184,6 +185,7 @@ item: 2 elements so far
Container with elements of structs:
```c
+#define i_implement
#include <stc/cstr.h>
typedef struct {