diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cdeq_api.md | 2 | ||||
| -rw-r--r-- | docs/clist_api.md | 2 | ||||
| -rw-r--r-- | docs/cmap_api.md | 18 | ||||
| -rw-r--r-- | docs/cptr_api.md | 14 | ||||
| -rw-r--r-- | docs/cset_api.md | 6 | ||||
| -rw-r--r-- | docs/cvec_api.md | 2 |
6 files changed, 25 insertions, 19 deletions
diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md index e30967f1..12fd3958 100644 --- a/docs/cdeq_api.md +++ b/docs/cdeq_api.md @@ -9,7 +9,7 @@ See [std::deque](https://en.cppreference.com/w/cpp/container/deque) for correspo ```c #define using_cdeq(X, Value, valueCompareRaw=c_default_compare, valueDestroy=c_default_del, - valueFromRaw=c_default_from_raw, + valueFromRaw=c_default_clone, valueToRaw=c_default_to_raw, RawValue=Value) #define using_cdeq_str() diff --git a/docs/clist_api.md b/docs/clist_api.md index 10956903..4f5325e7 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -11,7 +11,7 @@ is only one pointer, and length of the list is not stored. The method *clist_X_s ```c #define using_clist(X, Value, valueCompareRaw=c_default_compare, valueDestroy=c_default_del, - valueFromRaw=c_default_from_raw, + valueFromRaw=c_default_clone, valueToRaw=c_default_to_raw, RawValue=Value) #define using_clist_str() diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 69c975af..4a696ab7 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -9,23 +9,27 @@ See [std::unordered_map](https://en.cppreference.com/w/cpp/container/unordered_m ```c #define using_cmap(X, Key, Mapped, mappedDestroy=c_default_del, + mappedClone=c_default_clone, keyEqualsRaw=c_default_equals, keyHashRaw=c_default_hash, keyDestroy=c_default_del, - RawKey=Key, - keyFromRaw=c_default_from_raw, + keyFromRaw=c_default_clone, keyToRaw=c_default_to_raw, - RawMapped=Mapped, - mappedFromRaw=c_default_from_raw) + RawKey=Key) +// or: +#define using_cmap(X, Key, Mapped, mappedDestroy, + mappedFromRaw, keyFromRaw, RawMapped, + keyEqualsRaw, keyHashRaw, keyDestroy, + keyFromRaw, keyToRaw, RawKey) #define using_cmap_strkey(X, Mapped, mappedDestroy=c_default_del) #define using_cmap_strval(X, Key, keyEquals=c_default_equals, keyHash=c_default_hash, keyDestroy=c_default_del, - RawKey=Key, - keyFromRaw=c_default_from_raw, - keyToRaw=c_default_to_raw) + keyFromRaw=c_default_clone, + keyToRaw=c_default_to_raw, + RawKey=Key) #define using_cmap_str() ``` The macro `using_cmap()` can be instantiated with 3, 4, 6, 10, or 12 arguments in the global scope. diff --git a/docs/cptr_api.md b/docs/cptr_api.md index fe79d042..0d6a37ba 100644 --- a/docs/cptr_api.md +++ b/docs/cptr_api.md @@ -3,16 +3,18 @@ This module simplifies management of pointers in containers. The **csptr** type is similar to a c++ [std::shared_ptr](https://en.cppreference.com/w/cpp/memory/shared_ptr). -Raw pointers and shared pointers (**csptr**) may be used as items of containers. The pointed-to elements are automatically destructed and deleted when the container is destructed. **csptr** elements are only deleted if there are no other shared references to the element. **csptr** uses thread-safe atomic use-count, through the *csptr_X_share(sp)* and *csptr_X_del(&sp)* methods. +Raw pointers and shared pointers (**csptr**) may be used as items of containers. The pointed-to elements are automatically destructed and deleted when the container is destructed. **csptr** elements are only deleted if there are no other shared references to the element. **csptr** uses thread-safe atomic use-count, through the *csptr_X_clone(sp)* and *csptr_X_del(&sp)* methods. ## Declaration ```c #define using_cptr(X, Value, valueCompare=c_default_compare, - valueDestroy=c_default_del) + valueDestroy=c_default_del, + valueClone=c_default_clone) #define using_csptr(X, Value, valueCompare=c_default_compare, - valueDestroy=c_default_del) + valueDestroy=c_default_del, + valueClone=c_default_clone) ``` The macro `using_cptr()` must be instantiated in the global scope. `X` is a type tag name and will affect the names of all cptr types and methods. E.g. declaring `using_cptr(my, cvec_my);`, @@ -43,7 +45,7 @@ All cptr definitions and prototypes may be included in your C source file by inc ## Methods -The *\*_del()* and *\*_compare()* methods are defined based on the methods passed to the *using_\*ptr()* macro. For *csptr* use *csptr_X_share(p)* when sharing ownership of the pointed-to object to others. See example below. +The *\*_del()* and *\*_compare()* methods are defined based on the methods passed to the *using_\*ptr()* macro. For *csptr* use *csptr_X_clone(p)* when sharing ownership of the pointed-to object to others. See example below. ```c cptr_X cptr_X_init(void); void cptr_X_reset(cptr_X* self, cptr_X_value_t* ptr); @@ -53,7 +55,7 @@ int cptr_X_compare(cptr_X* x, cptr_X* y); ```c csptr_X csptr_X_from(csptr_X_value_t* ptr); csptr_X csptr_X_make(csptr_X_value_t ref); -csptr_X csptr_X_share(csptr_X ptr); +csptr_X csptr_X_clone(csptr_X ptr); void csptr_X_reset(csptr_X* self, csptr_X_value_t* p); void csptr_X_del(csptr_X* self); int csptr_X_compare(csptr_X* x, csptr_X* y); @@ -126,7 +128,7 @@ int main() { printf(" %s %s\n", i.ref->get->name.str, i.ref->get->last.str); // share ownership of vec3.data[1] with elem: - csptr_ps elem = csptr_ps_share(vec3.data[1]); + csptr_ps elem = csptr_ps_clone(vec3.data[1]); puts("\nDestroy vec3:"); cvec_ps_del(&vec3); // destroys all elements, but elem! diff --git a/docs/cset_api.md b/docs/cset_api.md index 99940b03..412ff572 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -11,9 +11,9 @@ A **cset** is an associative container that contains a set of unique objects of #define using_cset(X, Key, keyEqualsRaw=c_default_equals,
keyHashRaw=c_default_hash,
keyDestroy=c_default_del,
- RawKey=Key,
- keyToRaw=c_default_to_raw,
- keyFromRaw=c_default_from_raw)
+ keyFromRaw=c_default_clone,
+ keyToRaw=c_default_to_raw,
+ RawKey=Key)
```
The macro `using_cset()` can be instantiated with 2, 4, 5, or 8 arguments in the global scope.
Default values are given above for args not specified. `X` is a type tag name and
diff --git a/docs/cvec_api.md b/docs/cvec_api.md index de437853..afdeef46 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -9,7 +9,7 @@ See [std::vector](https://en.cppreference.com/w/cpp/container/vector) for a simi ```c #define using_cvec(X, Value, valueCompareRaw=c_default_compare, valueDestroy=c_default_del, - valueFromRaw=c_default_from_raw, + valueFromRaw=c_default_clone, valueToRaw=c_default_to_raw, RawValue=Value) #define using_cvec_str() |
