summaryrefslogtreecommitdiffhomepage
path: root/docs
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
parentc25b6d39f4ebbc1785108fd248b67fe9e8c95e92 (diff)
downloadSTC-modified-d7a19420e0aec71a2a840f68a54549c8a951f929.tar.gz
STC-modified-d7a19420e0aec71a2a840f68a54549c8a951f929.zip
Update docs regarding i_implement for cstr, cview, cbits, ...
Diffstat (limited to 'docs')
-rw-r--r--docs/carc_api.md3
-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/csmap_api.md4
-rw-r--r--docs/csset_api.md1
-rw-r--r--docs/cstr_api.md2
-rw-r--r--docs/csview_api.md10
-rw-r--r--docs/cvec_api.md2
9 files changed, 27 insertions, 1 deletions
diff --git a/docs/carc_api.md b/docs/carc_api.md
index d0d90300..aef3d867 100644
--- a/docs/carc_api.md
+++ b/docs/carc_api.md
@@ -67,6 +67,9 @@ bool carc_X_value_eq(const i_val* x, const i_val* y); // carc_X_value_c
```c
// Create a stack and a list of shared pointers to maps,
// and demonstrate sharing and cloning of maps.
+#define i_implement
+#include <stc/cstr.h>
+
#define i_type Map
#define i_key_str // strings
#define i_val int
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 9d2baea6..ff44cf12 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -60,6 +60,7 @@ c_autodefer (cstr_drop(&s1), cstr_drop(&s2))
**Example**: 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 58d33534..b30353ef 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -113,6 +113,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_key int
@@ -265,6 +267,7 @@ Output:
### Example 5
Advanced 1: Key type is struct.
```c
+#define i_implement
#include <stc/cstr.h>
typedef struct {
@@ -341,6 +344,7 @@ Advanced 2: In example 5 we needed to construct a lookup key which allocated str
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 3e6ae8f0..3047d116 100644
--- a/docs/crandom_api.md
+++ b/docs/crandom_api.md
@@ -72,6 +72,7 @@ double stc64_normalf(stc64_t* rng, stc64_normalf_t* dist);
```c
#include <time.h>
#include <stc/crandom.h>
+#define i_implement
#include <stc/cstr.h>
// Declare int -> int sorted map. Uses typetag 'i' for ints.
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index e19d0637..8e790eff 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -101,6 +101,9 @@ csmap_X_raw csmap_X_value_toraw(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>
@@ -143,6 +146,7 @@ The HEX of color BLACK is:[#000000]
### Example 2
This example uses a csmap with cstr as mapped value.
```c
+#define i_implement
#include <stc/cstr.h>
#define i_key int
diff --git a/docs/csset_api.md b/docs/csset_api.md
index a87bb6a2..83b7e11b 100644
--- a/docs/csset_api.md
+++ b/docs/csset_api.md
@@ -73,6 +73,7 @@ csset_X_value csset_X_value_clone(csset_X_value val);
## Example
```c
+#define i_implement
#include <stc/cstr.h>
#define i_key_str
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index 24f51d32..cd827dc6 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -10,6 +10,7 @@ See the c++ class [std::basic_string](https://en.cppreference.com/w/cpp/string/b
All cstr definitions and prototypes are available by including a single header file.
```c
+#define i_implement // define this (or use global STC_IMPLEMENT) in one source file only!
#include <stc/cstr.h>
```
## Methods
@@ -131,6 +132,7 @@ int c_strncasecmp(const char* str1, const char* str2, size_t n);
## Example
```c
+#define i_implement
#include <stc/cstr.h>
int main() {
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)
{
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index 2ea52e56..f1225d72 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -147,6 +147,7 @@ sorted: 5 7 8 13 16 25
```
### Example 2
```c
+#define i_implement
#include <stc/cstr.h>
#define i_val_str
@@ -181,6 +182,7 @@ item: 2 elements so far
Container with elements of structs:
```c
+#define i_implement
#include <stc/cstr.h>
typedef struct {