diff options
| author | Tyge Løvset <[email protected]> | 2021-02-23 23:50:05 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-02-23 23:50:05 +0100 |
| commit | 96d78ec2623b89089d3512f619fb252d1afc24a0 (patch) | |
| tree | a8eac592c03deb36a20154aef7dcb90f7334e35b /docs | |
| parent | 85cdc67585e5bd0d081ec7bf86cafa7244f53369 (diff) | |
| download | STC-modified-96d78ec2623b89089d3512f619fb252d1afc24a0.tar.gz STC-modified-96d78ec2623b89089d3512f619fb252d1afc24a0.zip | |
Updated cstr doc.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cstr_api.md | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/docs/cstr_api.md b/docs/cstr_api.md index dc4bb721..ae443087 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -1,7 +1,7 @@ # STC [cstr](../stc/cstr.h): String  -A **cstr* is an object that represent sequences of characters. It supports an interface similar to that of a standard container of bytes, but adding features specifically designed to operate with strings of single-byte characters. +A **cstr* object represent sequences of characters. It supports an interface similar to that of a standard container of bytes, but adding features specifically designed to operate with strings of single-byte characters, terminated by the null character. See the c++ class [std::basic_string](https://en.cppreference.com/w/cpp/string/basic_string) for a functional description. @@ -15,29 +15,31 @@ All cstr definitions and prototypes may be included in your C source file by inc ## Methods ```c -cstr cstr_init(void); // constructor +cstr cstr_init(void); // constructor cstr cstr_with_capacity(size_t cap); -cstr cstr_with_size(size_t len, char fill); // repeat fill len times +cstr cstr_with_size(size_t len, char fill); // repeat fill len times cstr cstr_from(const char* str); cstr cstr_from_n(const char* str, size_t len); -cstr cstr_from_fmt(const char* fmt, ...); // printf() formatting +cstr cstr_from_fmt(const char* fmt, ...); // printf() formatting + cstr cstr_clone(cstr s); -void cstr_del(cstr *self); // destructor +void cstr_del(cstr *self); // destructor + size_t cstr_size(cstr s); size_t cstr_length(cstr s); size_t cstr_capacity(cstr s); bool cstr_empty(cstr s); -char* cstr_front(cstr* self); -char* cstr_back(cstr* self); + size_t cstr_reserve(cstr* self, size_t capacity); void cstr_resize(cstr* self, size_t len, char fill); void cstr_clear(cstr* self); cstr* cstr_assign(cstr* self, const char* str); cstr* cstr_assign_n(cstr* self, const char* str, size_t len); -cstr* cstr_take(cstr* self, cstr s); // take the constructed or moved string -cstr cstr_move(cstr* self); // move string to caller, leave empty string +cstr* cstr_take(cstr* self, cstr s); // take the constructed or moved string +cstr cstr_move(cstr* self); // move string to caller, leave empty string + cstr* cstr_append(cstr* self, const char* str); -cstr* cstr_append_n(cstr* self, const char* str, size_t len); +cstr* cstr_append_n(cstr* self, const char* str, size_t len); // appends max len characters void cstr_push_back(cstr* self, char ch); void cstr_pop_back(cstr* self); void cstr_insert(cstr* self, size_t pos, const char* str); @@ -50,7 +52,7 @@ void cstr_replace_n(cstr* self, size_t pos, size_t len, const char* str, int cstr_compare(const cstr *s1, const cstr *s2); bool cstr_equals(cstr s, const char* str); bool cstr_equals_s(cstr s, cstr s2); -bool cstr_iequals(cstr s, const char* str); // prefix i = case-insensitive +bool cstr_iequals(cstr s, const char* str); // prefix i = case-insensitive size_t cstr_find(cstr s, const char* substr); size_t cstr_find_n(cstr s, const char* substr, size_t pos, size_t nlen); size_t cstr_ifind_n(cstr s, const char* substr, size_t pos, size_t nlen); @@ -61,12 +63,15 @@ bool cstr_ibegins_with(cstr s, const char* substr); bool cstr_ends_with(cstr s, const char* substr); bool cstr_iends_with(cstr s, const char* substr); +char* cstr_front(cstr* self); +char* cstr_back(cstr* self); + cstr_iter_t cstr_begin(cstr* self); cstr_iter_t cstr_end(cstr* self); void cstr_next(cstr_iter_t* it); char* cstr_itval(cstr_iter_t it); -bool cstr_getline(cstr *self, FILE *stream); // cstr_getdelim(self, '\n', stream) +bool cstr_getline(cstr *self, FILE *stream); // cstr_getdelim(self, '\n', stream) bool cstr_getdelim(cstr *self, int delim, FILE *stream); ``` ```c |
