summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-12-13 13:53:22 +0100
committerTyge Løvset <[email protected]>2021-12-13 13:53:22 +0100
commit17280f8177736c35b34e41556a307ca51e68d1e2 (patch)
tree96b0b7dfeede1dc0a6c6f36ec60f18e2ff3bd68a /docs
parentc7a26eb5b5fef1c2706d5875a0603d352926487e (diff)
downloadSTC-modified-17280f8177736c35b34e41556a307ca51e68d1e2.tar.gz
STC-modified-17280f8177736c35b34e41556a307ca51e68d1e2.zip
Renamed constructor *cstr_lit()* to `cstr_new(lit)`.
Renamed *cstr_assign_fmt()* to `cstr_printf()`. Renamed cbits_from_str() to cbits_from().
Diffstat (limited to 'docs')
-rw-r--r--docs/cbits_api.md3
-rw-r--r--docs/ccommon_api.md6
-rw-r--r--docs/cmap_api.md14
-rw-r--r--docs/cstr_api.md8
-rw-r--r--docs/csview_api.md11
-rw-r--r--docs/cvec_api.md4
6 files changed, 23 insertions, 23 deletions
diff --git a/docs/cbits_api.md b/docs/cbits_api.md
index f13c5e8c..b369b5d1 100644
--- a/docs/cbits_api.md
+++ b/docs/cbits_api.md
@@ -18,9 +18,10 @@ All cbits definitions and prototypes are available by including a single header
```c
cbits cbits_init(void);
+cbits cbits_new(c_strlit literal);
+cbits cbits_from(const char* str);
cbits cbits_with_size(size_t size, bool value);
cbits cbits_with_values(size_t size, uint64_t pattern);
-cbits cbits_from_str(const char* str);
cbits cbits_clone(cbits other);
void cbits_clear(cbits* self);
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 8c749e8e..4dc099fb 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -22,7 +22,7 @@ macros, as one must always make sure to unwind temporary allocated resources bef
For multiple variables, use either multiple **c_autovar** in sequence, or declare variable outside
scope and use **c_autoscope**. Also, **c_auto** support up to 3 variables.
```c
-c_autovar (cstr s = cstr_lit("Hello"), cstr_del(&s))
+c_autovar (cstr s = cstr_new("Hello"), cstr_del(&s))
{
cstr_append(&s, " world");
printf("%s\n", s.str);
@@ -45,7 +45,7 @@ c_autoscope (mydata_init(&data), mydata_destroy(&data))
printf("%s\n", mydata.name.str);
}
-cstr s1 = cstr_lit("Hello"), s2 = cstr_lit("world");
+cstr s1 = cstr_new("Hello"), s2 = cstr_new("world");
c_autodefer (cstr_del(&s1), cstr_del(&s2))
{
printf("%s %s\n", s1.str, s2.str);
@@ -158,7 +158,7 @@ c_free(pnt);
int* array = c_alloc_n (int, 100);
c_free(array);
-cstr a = cstr_from("Hello"), b = cstr_from("World");
+cstr a = cstr_new("Hello"), b = cstr_new("World");
c_del(cstr, &a, &b);
```
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 51bcdcce..0fec365c 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -295,12 +295,12 @@ int main()
// Use a HashMap to store the vikings' health points.
cmap_vk vikings = cmap_vk_init();
- cmap_vk_insert(&vikings, (Viking){cstr_from("Einar"), cstr_from("Norway")}, 25);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Olaf"), cstr_from("Denmark")}, 24);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Harald"), cstr_from("Iceland")}, 12);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Einar"), cstr_from("Denmark")}, 21);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Norway")}, 25);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Olaf"), cstr_new("Denmark")}, 24);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Harald"), cstr_new("Iceland")}, 12);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Denmark")}, 21);
- Viking lookup = (Viking){cstr_from("Einar"), cstr_from("Norway")};
+ Viking lookup = (Viking){cstr_new("Einar"), cstr_new("Norway")};
printf("Lookup: Einar of Norway has %d hp\n\n", *cmap_vk_at(&vikings, lookup));
Viking_del(&lookup);
@@ -371,8 +371,8 @@ int main()
c_auto (cmap_vk, vikings) // RAII
{
// Insert works as before, takes a constructed Viking object
- cmap_vk_insert(&vikings, (Viking){cstr_from("Einar"), cstr_from("Norway")}, 25);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Olaf"), cstr_from("Denmark")}, 24);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Norway")}, 25);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Olaf"), cstr_new("Denmark")}, 24);
// Emplace is simpler to use now - takes rawkey argument
cmap_vk_emplace(&vikings, (RViking){"Harald", "Iceland"}, 12);
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index acea7b6f..0004eeae 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -16,7 +16,7 @@ All cstr definitions and prototypes are available by including a single header f
```c
cstr cstr_init(void); // constructor; same as cstr_null.
-cstr cstr_lit(const char literal_only[]); // cstr from literal; no strlen().
+cstr cstr_new(const char literal_only[]); // cstr from literal; no strlen() call.
cstr cstr_from(const char* str); // constructor using strlen()
cstr cstr_from_n(const char* str, size_t n); // constructor with specified length
cstr cstr_with_capacity(size_t cap);
@@ -41,7 +41,7 @@ void cstr_clear(cstr* self);
cstr* cstr_assign(cstr* self, const char* str);
cstr* cstr_assign_n(cstr* self, const char* str, size_t n); // assign n first chars of str
-cstr* cstr_assign_fmt(cstr* self, const char* fmt, ...); // printf() formatting
+cstr* cstr_printf(cstr* self, const char* fmt, ...); // printf() formatting
cstr* cstr_copy(cstr* self, cstr s); // cstr_take(self, cstr_clone(s))
cstr* cstr_append(cstr* self, const char* str);
@@ -118,10 +118,10 @@ int c_strncasecmp(const char* str1, const char* str2, size_t n);
#include <stc/cstr.h>
int main() {
- cstr s0 = cstr_lit("Initialization without using strlen().");
+ cstr s0 = cstr_new("Initialization without using strlen().");
printf("%s\nLength: %zu\n\n", s0.str, cstr_size(s0));
- cstr s1 = cstr_from("one-nine-three-seven-five.");
+ cstr s1 = cstr_new("one-nine-three-seven-five.");
printf("%s\n", s1.str);
cstr_insert(&s1, 3, "-two");
diff --git a/docs/csview_api.md b/docs/csview_api.md
index 1376b768..2653dafa 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -25,12 +25,11 @@ All csview definitions and prototypes are available by including a single header
## Methods
```c
+csview csview_new(const char literal_only[]); // make csview from literal, no strlen()
+csview csview_from_s(cstr s); // same as cstr_sv()
csview csview_from(const char* str); // make csview from const char*
csview csview_from_n(const char* str, size_t n); // construct
-csview csview_from_s(cstr s); // same as cstr_sv()
-
-csview csview_lit(const char literal_only[]); // make csview from literal, no strlen()
-csview c_sv(const char literal_only[]); // same as csview_lit()
+csview c_sv(const char literal_only[]); // same as csview_new()
size_t csview_size(csview sv);
size_t csview_length(csview sv);
@@ -104,7 +103,7 @@ uint64_t csview_hash(const csview* x, size_t dummy);
int main ()
{
- cstr str1 = cstr_lit("We think in generalities, but we live in details.");
+ cstr str1 = cstr_new("We think in generalities, but we live in details.");
// (quoting Alfred N. Whitehead)
csview sv1 = cstr_substr(str1, 3, 5); // "think"
@@ -113,7 +112,7 @@ int main ()
csview sv3 = cstr_slice(str1, -8, -1); // get "details"
printf("%.*s %.*s %.*s\n", csview_ARG(sv1), csview_ARG(sv2), csview_ARG(sv3));
- cstr s1 = cstr_lit("Apples are red");
+ cstr s1 = cstr_new("Apples are red");
cstr s2 = cstr_from_v(cstr_substr(s1, -3, 3)); // "red"
cstr s3 = cstr_from_v(cstr_substr(s1, 0, 6)); // "Apples"
printf("%s %s\n", s2, s3.str);
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index b3bc0f1b..8053b108 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -202,8 +202,8 @@ User User_clone(User user) {
int main(void) {
cvec_u vec = cvec_u_init();
- cvec_u_push_back(&vec, (User) {cstr_from("admin"), 0});
- cvec_u_push_back(&vec, (User) {cstr_from("joe"), 1});
+ cvec_u_push_back(&vec, (User) {cstr_new("admin"), 0});
+ cvec_u_push_back(&vec, (User) {cstr_new("joe"), 1});
cvec_u vec2 = cvec_u_clone(vec);
c_foreach (i, cvec_u, vec2)