Ver Fonte

Added documentation to DString functions.

Aaro Saila há 3 semanas atrás
pai
commit
80f91f0116
2 ficheiros alterados com 100 adições e 6 exclusões
  1. 67 0
      include/scufcont/DString.h
  2. 33 6
      src/DString.c

+ 67 - 0
include/scufcont/DString.h

@@ -17,11 +17,36 @@ typedef struct {
     size_t capacity;
 } SCDString;
 
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_alloc(SCDString *const dstr, const char *str, const size_t len);
+
+/**
+  @param dstr Must not be allocated with any of the alloc functions. This functions allocates it.
+
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_alloc_copy(SCDString *const dstr, const SCDString *const o);
+
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_reserve(SCDString *const dstr, const size_t new_capacity);
+
 void SCDString_free(SCDString *const dstr);
+
+/**
+  @param dst Must have been allocated with one of the allocation functions.
+
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_copy(const SCDString *const src, SCDString *const dst);
+
 bool SCDString_equal(const SCDString *const s1, const SCDString *s2);
 bool SCDString_equal_c_str(const SCDString *const s1, const char *s2);
 bool SCDString_equal_next_chars_c_str(
@@ -30,12 +55,27 @@ bool SCDString_equal_next_chars_c_str(
     const size_t str_len,
     const size_t s
 );
+
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_concat_char(SCDString *const dstr, const char ch);
+
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_concat_c_str(
     SCDString *const dstr,
     const char *str,
     const size_t str_len
 );
+
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_alloc_concat_c_strs(
     SCDString *const dstr,
     const char *s1,
@@ -43,16 +83,43 @@ ScufContResult SCDString_alloc_concat_c_strs(
     const char *s2,
     const size_t s2_len
 );
+
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_split(
     const SCDString *const dstr,
     const char *delim,
     SCDString **const split_arr,
     size_t *const arr_len
 );
+
 void SCDString_split_arr_free(SCDString **const arr, const size_t arr_len);
+
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_mod(SCDString *const dstr, const size_t at, const char ch);
+
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_remove_no_resize(SCDString *const dstr, const size_t at);
+
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_remove(SCDString *const dstr, const size_t at);
+
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_insert(SCDString *const dstr, const size_t at, const char ch);
 
 #endif // SCUFCONT_DSTRING_H_

+ 33 - 6
src/DString.c

@@ -19,9 +19,6 @@ ScufContResult SCDString_alloc(SCDString *const dstr, const char *str, const siz
     return SCUFCONT_SUCCESS;
 }
 
-/**
-  @param dstr Must not be allocated with any of the alloc functions. This functions allocates it.
-*/
 ScufContResult SCDString_alloc_copy(SCDString *const dstr, const SCDString *const o) {
     return SCDString_alloc(dstr, SCDString_c_str(o), o->len);
 }
@@ -55,9 +52,6 @@ void SCDString_resize_to_fit(SCDString *const dstr) {
     }
 }
 
-/**
-  @param dst Must have been allocated with one of the allocation functions.
-*/
 ScufContResult SCDString_copy(const SCDString *const src, SCDString *const dst) {
     ScufContResult res = SCDString_reserve(dst, src->len + 1);
     if (res != SCUFCONT_SUCCESS) {
@@ -128,6 +122,10 @@ bool SCDString_equal_next_chars_c_str(
     return true;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_concat_char(SCDString *const dstr, const char ch) {
     const size_t new_len = dstr->len + 1;
     if (new_len > dstr->capacity) {
@@ -144,6 +142,10 @@ ScufContResult SCDString_concat_char(SCDString *const dstr, const char ch) {
     return SCUFCONT_SUCCESS;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_concat_c_str(
     SCDString *const dstr,
     const char *str,
@@ -164,6 +166,10 @@ ScufContResult SCDString_concat_c_str(
     return SCUFCONT_SUCCESS;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_alloc_concat_c_strs(
     SCDString *const dstr,
     const char *s1,
@@ -182,6 +188,10 @@ ScufContResult SCDString_alloc_concat_c_strs(
     return SCUFCONT_SUCCESS;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_split(
     const SCDString *const dstr,
     const char *delim,
@@ -244,6 +254,10 @@ void SCDString_split_arr_free(SCDString **const arr, const size_t arr_len) {
     *arr = NULL;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_mod(SCDString *const dstr, const size_t at, const char ch) {
     if (at > dstr->len - 1) {
         return SCUFCONT_OUT_OF_BOUNDS;
@@ -254,6 +268,10 @@ ScufContResult SCDString_char_mod(SCDString *const dstr, const size_t at, const
     return SCUFCONT_SUCCESS;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_remove_no_resize(SCDString *const dstr, const size_t at) {
     if (at > dstr->len - 1) {
         return SCUFCONT_OUT_OF_BOUNDS;
@@ -264,6 +282,10 @@ ScufContResult SCDString_char_remove_no_resize(SCDString *const dstr, const size
     return SCUFCONT_SUCCESS;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_remove(SCDString *const dstr, const size_t at) {
     const ScufContResult res = SCDString_char_remove_no_resize(dstr, at);
     if (res != SCUFCONT_SUCCESS) {
@@ -275,6 +297,11 @@ ScufContResult SCDString_char_remove(SCDString *const dstr, const size_t at) {
     return SCUFCONT_SUCCESS;
 }
 
+/**
+  @return SCUFCONT_OUT_OF_BOUNDS
+  @return SCUFCONT_OUT_OF_MEMORY
+  @return SCUFCONT_SUCCESS
+*/
 ScufContResult SCDString_char_insert(SCDString *const dstr, const size_t at, const char ch) {
     if (at > dstr->len) {
         return SCUFCONT_OUT_OF_BOUNDS;