Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mickjc750 committed Oct 11, 2023
1 parent dad7ed4 commit ed572cb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ C String handling library inspired by Luca Sas. https://www.youtube.com/watch?v=
* Supports custom allocators, for applications which use temporary allocators for speed. Or can default to malloc/free for simplicity.
* A rich set of of string splitting/trim/search functions.
* A number parser which checks for errors, including range errors, or invalid input.
* A test suite which uses https://github.com/silentbicycle/greatest, currently passing all 42 tests, 486 assertions.

STR is not currently MISRA compliant, but as it doesn't depend on dynamic memory allocation, it has the potential to be so. I don't possess a MISRA linter, and I'm unable to find a free one. If a contributor wishes to provide information regarding the violations, I'm willing to make it comply.
* A test suite which uses https://github.com/silentbicycle/greatest, currently passing all 43 tests, 528 assertions.

For an example of how useful this approach to string handling is, see the URI parser in [/examples/parse_uri/parse-uri.c](/examples/parse-uri/parse-uri.c)

Expand Down Expand Up @@ -120,6 +118,8 @@ To understand this approach to string handling, and the purpose of each, it help
title_set(cstr("Main menu"));
title_set(cstr_SL("Main menu"));

* Note that many of the library functions which take a strview_t are generic macros which can also accept a C string.

 
# Comparison with SDS https://github.com/antirez/sds

Expand All @@ -142,7 +142,7 @@ SDS functions are of the form:

As __sdscat()__ may relocate the buffer, you have to remember to assign the returned value back to the variable. If the variable passed to __sdscat()__ was of any use after the call, then this signature might make sense. But as that isn't the case, it makes more sense to pass the buffer by reference. So __strbuf.h__ functions are of the form:

strbuf_append(&s, cstr("Hello"));
strbuf_append(&s, "Hello");

 
## Disagreement on what is an advantage, and what is a hazard.
Expand Down
50 changes: 25 additions & 25 deletions docs/strbuf-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@
 
# Contents
1. [About](#about)
2. [Providing an allocator](#providing-an-allocator-for-strbufcreate)
2. [Providing an allocator](#providing-an-allocator-for-strbuf_create)
3. [Allocator example](#allocator-example)
4. [Buffer re-sizing](#buffer-re-sizing)
5. [Using static or stack allocated buffers](#using-static-or-stack-allocated-buffers)

# Function reference
* [strbuf_t* strbuf_create(size_t initial_capacity, strbuf_allocator_t* allocator)](#strbuft-strbufcreatesizet-initialcapacity-strbufallocatort-allocator)
* [strbuf_t* strbuf_create_fixed(void* addr, size_t addr_size)](#strbuft-strbufcreatefixedvoid-addr-sizet-addrsize)
* [void strbuf_destroy(strbuf_t** buf_ptr)](#void-strbufdestroystrbuft-bufptr)
* [strview_t strbuf_view(strbuf_t** buf_ptr)](#strviewt-strbufviewstrbuft-bufptr)
* [strview_t strbuf_shrink(strbuf_t** buf_ptr)](#strviewt-strbufshrinkstrbuft-bufptr)
* [strview_t strbuf_grow(strbuf_t** buf_ptr, int min_size)](#strviewt-strbufgrowstrbuft-bufptr-int-minsize)
* [strview_t strbuf_assign(strbuf_t** buf_ptr, strview_t str)](#strviewt-strbufassignstrbuft-bufptr-strviewt-str)
* [strview_t strbuf_cat(strbuf_t** buf_ptr, ...)](#strviewt-strbufcatstrbuft-bufptr)
* [strview_t strbuf_vcat(strbuf_t** buf_ptr, int n_args, va_list va)](#strviewt-strbufvcatstrbuft-bufptr-int-nargs-valist-va)
* [strview_t strbuf_append(strbuf_t** buf_ptr, strview_t str)](#strviewt-strbufappendstrbuft-bufptr-strviewt-str)
* [strview_t strbuf_append_char(strbuf_t** buf_ptr, char c)](#strviewt-strbufappendcharstrbuft-bufptr-char-c)
* [strview_t strbuf_prepend(strbuf_t** buf_ptr, strview_t str)](#strviewt-strbufprependstrbuft-bufptr-strviewt-str)
* [strview_t strbuf_strip(strbuf_t** buf_ptr, strview_t stripchars)](#strviewt-strbufstripstrbuft-bufptr-strviewt-stripchars)
* [strview_t strbuf_insert_at_index(strbuf_t** buf_ptr, int index, strview_t str)](#strviewt-strbufinsertatindexstrbuft-bufptr-int-index-strviewt-str)
* [strview_t strbuf_insert_before(strbuf_t** buf_ptr, strview_t dst, strview_t src)](#strviewt-strbufinsertbeforestrbuft-bufptr-strviewt-dst-strviewt-src)
* [strview_t strbuf_insert_after(strbuf_t** buf_ptr, strview_t dst, strview_t src)](#strviewt-strbufinsertafterstrbuft-bufptr-strviewt-dst-strviewt-src)
* [strview_t strbuf_printf(strbuf_t** buf_ptr, const char* format, ...)](#strviewt-strbufprintfstrbuft-bufptr-const-char-format)
* [strview_t strbuf_vprintf(strbuf_t** buf_ptr, const char* format, va_list va)](#strviewt-strbufvprintfstrbuft-bufptr-const-char-format-valist-va)
* [strview_t strbuf_prnf(strbuf_t** buf_ptr, const char* format, ...)](#strviewt-strbufprnfstrbuft-bufptr-const-char-format)
* [strview_t strbuf_vprnf(strbuf_t** buf_ptr, const char* format, va_list va)](#strviewt-strbufvprnfstrbuft-bufptr-const-char-format-valist-va)
* [strview_t strbuf_append_printf(strbuf_t** buf_ptr, const char* format, ...)](#strviewt-strbufappendprintfstrbuft-bufptr-const-char-format)
* [strview_t strbuf_append_vprintf(strbuf_t** buf_ptr, const char* format, va_list va)](#strviewt-strbufappendvprintfstrbuft-bufptr-const-char-format-valist-va)
* [strview_t strbuf_append_prnf(strbuf_t** buf_ptr, const char* format, ...)](#strviewt-strbufappendprnfstrbuft-bufptr-const-char-format)
* [strview_t strbuf_append_vprnf(strbuf_t** buf_ptr, const char* format, va_list va)](#strviewt-strbufappendvprnfstrbuft-bufptr-const-char-format-valist-va)
* [strbuf_t* strbuf_create(size_t initial_capacity, strbuf_allocator_t* allocator)](#strbuf_t-strbuf_createsize_t-initial_capacity-strbuf_allocator_t-allocator)
* [strbuf_t* strbuf_create_fixed(void* addr, size_t addr_size)](#strbuf_t-strbuf_create_fixedvoid-addr-size_t-addr_size)
* [void strbuf_destroy(strbuf_t** buf_ptr)](#void-strbuf_destroystrbuf_t-buf_ptr)
* [strview_t strbuf_view(strbuf_t** buf_ptr)](#strview_t-strbuf_viewstrbuf_t-buf_ptr)
* [strview_t strbuf_shrink(strbuf_t** buf_ptr)](#strview_t-strbuf_shrinkstrbuf_t-buf_ptr)
* [strview_t strbuf_grow(strbuf_t** buf_ptr, int min_size)](#strview_t-strbuf_growstrbuf_t-buf_ptr-int-min_size)
* [strview_t strbuf_assign(strbuf_t** buf_ptr, strview_t str)](#strview_t-strbuf_assignstrbuf_t-buf_ptr-strview_t-str)
* [strview_t strbuf_cat(strbuf_t** buf_ptr, ...)](#strview_t-strbuf_catstrbuf_t-buf_ptr)
* [strview_t strbuf_vcat(strbuf_t** buf_ptr, int n_args, va_list va)](#strview_t-strbuf_vcatstrbuf_t-buf_ptr-int-n_args-va_list-va)
* [strview_t strbuf_append(strbuf_t** buf_ptr, strview_t str)](#strview_t-strbuf_appendstrbuf_t-buf_ptr-str)
* [strview_t strbuf_append_char(strbuf_t** buf_ptr, char c)](#strview_t-strbuf_append_charstrbuf_t-buf_ptr-char-c)
* [strview_t strbuf_prepend(strbuf_t** buf_ptr, strview_t str)](#strview_t-strbuf_prependstrbuf_t-buf_ptr-str)
* [strview_t strbuf_strip(strbuf_t** buf_ptr, strview_t stripchars)](#strview_t-strbuf_stripstrbuf_t-buf_ptr-stripchars)
* [strview_t strbuf_insert_at_index(strbuf_t** buf_ptr, int index, strview_t str)](#strview_t-strbuf_insert_at_indexstrbuf_t-buf_ptr-int-index-str)
* [strview_t strbuf_insert_before(strbuf_t** buf_ptr, strview_t dst, strview_t src)](#strview_t-strbuf_insert_beforestrbuf_t-buf_ptr-strview_t-dst-src)
* [strview_t strbuf_insert_after(strbuf_t** buf_ptr, strview_t dst, strview_t src)](#strview_t-strbuf_insert_afterstrbuf_t-buf_ptr-strview_t-dst-src)
* [strview_t strbuf_printf(strbuf_t** buf_ptr, const char* format, ...)](#strview_t-strbuf_printfstrbuf_t-buf_ptr-const-char-format)
* [strview_t strbuf_vprintf(strbuf_t** buf_ptr, const char* format, va_list va)](#strview_t-strbuf_vprintfstrbuf_t-buf_ptr-const-char-format-va_list-va)
* [strview_t strbuf_prnf(strbuf_t** buf_ptr, const char* format, ...)](#strview_t-strbuf_prnfstrbuf_t-buf_ptr-const-char-format)
* [strview_t strbuf_vprnf(strbuf_t** buf_ptr, const char* format, va_list va)](#strview_t-strbuf_vprnfstrbuf_t-buf_ptr-const-char-format-va_list-va)
* [strview_t strbuf_append_printf(strbuf_t** buf_ptr, const char* format, ...)](#strview_t-strbuf_append_printfstrbuf_t-buf_ptr-const-char-format)
* [strview_t strbuf_append_vprintf(strbuf_t** buf_ptr, const char* format, va_list va)](#strview_t-strbuf_append_vprintfstrbuf_t-buf_ptr-const-char-format-va_list-va)
* [strview_t strbuf_append_prnf(strbuf_t** buf_ptr, const char* format, ...)](#strview_t-strbuf_append_prnfstrbuf_t-buf_ptr-const-char-format)
* [strview_t strbuf_append_vprnf(strbuf_t** buf_ptr, const char* format, va_list va)](#strview_t-strbuf_append_vprnfstrbuf_t-buf_ptr-const-char-format-va_list-va)


## About
Expand Down

0 comments on commit ed572cb

Please sign in to comment.