]> Kevux Git Server - fll/commitdiff
Update: add f_fss_set_quoted.
authorKevin Day <thekevinday@gmail.com>
Fri, 10 Jul 2020 05:09:25 +0000 (00:09 -0500)
committerKevin Day <thekevinday@gmail.com>
Fri, 10 Jul 2020 05:09:25 +0000 (00:09 -0500)
An f_fss_set that includes object and content quoted type properties.

level_0/f_fss/c/fss-set.h

index bf9f751a3674a97eee0f50ebfb6c2eba89c18a2a..d47a42904588962c5e5c5c3195c749d7d3ff1c12 100644 (file)
@@ -22,8 +22,8 @@ extern "C" {
  * The objects and contents should each be of the same used and size.
  * Any deviation to this would require implementing custom equivelents to the standard management macros.
  *
- * objects: The array of objects.
- * contents: The array of contents.
+ * objects:  the array of objects.
+ * contents: the array of contents.
  */
 #ifndef _di_f_fss_set_
   typedef struct {
@@ -80,8 +80,8 @@ extern "C" {
  * This holds an array of f_fss_set.
  *
  * array: an array of f_fss_set.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
+ * size:  total amount of allocated space.
+ * used:  total number of allocated spaces used.
  */
 #ifndef _di_fss_sets_
   typedef struct {
@@ -111,7 +111,7 @@ extern "C" {
    * This does not deallocate memory, be certain that memory is not allocated before calling this to avoid potential memory leaks.
    *
    * status:     the status to return.
-   * sets:      the f_fss_sets structure to operate on.
+   * sets:       the f_fss_sets structure to operate on.
    * new_length: the new size of the array.
    */
   #define f_macro_fss_sets_new(status, sets, length) \
@@ -128,7 +128,7 @@ extern "C" {
    * Delete a fss content sets.
    *
    * status: the status to return.
-   * sets:  the f_fss_sets structure to operate on.
+   * sets:   the f_fss_sets structure to operate on.
    */
   #define f_macro_fss_sets_delete(status, sets) \
     status = F_none; \
@@ -145,7 +145,7 @@ extern "C" {
    * Destroy a fss content sets.
    *
    * status: the status to return.
-   * sets:  the f_fss_sets structure to operate on.
+   * sets:   the f_fss_sets structure to operate on.
    */
   #define f_macro_fss_sets_destroy(status, sets) \
     status = F_none; \
@@ -196,7 +196,7 @@ extern "C" {
    * Resize a fss content sets.
    *
    * status:     the status to return.
-   * sets:      the f_fss_sets structure to operate on.
+   * sets:       the f_fss_sets structure to operate on.
    * new_length: the new size of the array.
    */
   #define f_macro_fss_sets_resize(status, sets, new_length) \
@@ -222,7 +222,7 @@ extern "C" {
    * Adjust a fss content sets.
    *
    * status:     the status to return.
-   * sets:      the f_fss_sets structure to operate on.
+   * sets:       the f_fss_sets structure to operate on.
    * new_length: he new size of the array.
    */
   #define f_macro_fss_sets_adjust(status, sets, new_length) \
@@ -245,6 +245,276 @@ extern "C" {
     }
 #endif // _di_fss_sets_
 
+/**
+ * This holds an fss object with a set of fss content, along with their quoted types.
+ *
+ * The objects, contents, and quoteds should each be of the same used and size.
+ * Any deviation to this would require implementing custom equivelents to the standard management macros.
+ *
+ * objects:         the array of objects.
+ * contents:        the array of contents.
+ * objects_quoted:  the array of objects quoted types.
+ * contents_quoted: the array of contents quoted types.
+ */
+#ifndef _di_f_fss_set_quoted_
+  typedef struct {
+    f_fss_objects objects;
+    f_fss_contents contents;
+
+    f_fss_quoteds objects_quoted;
+    f_fss_quotedss contents_quoted;
+  } f_fss_set_quoted;
+
+  #define f_fss_set_quoted_initialize { f_fss_objects_initialize, f_fss_contents_initialize, f_fss_quoteds_initialize, f_fss_quotedss_initialize }
+
+  #define f_macro_fss_set_quoted_clear(set) \
+    f_macro_fss_objects_clear(set.objects) \
+    f_macro_fss_contents_clear(set.contents) \
+    f_macro_fss_quoteds_clear(set.objects_quoted) \
+    f_macro_fss_quotedss_clear(set.contents_quoted)
+
+  #define f_macro_fss_set_quoted_new(status, set, length) \
+    f_macro_fss_objects_new(status, set.objects, length) \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_contents_new(status, set.contents, length) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quoteds_new(status, set.objects_quoted, length) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quotedss_new(status, set.contents_quoted, length) \
+    }
+
+  #define f_macro_fss_set_quoted_delete(status, set) \
+    f_macro_fss_objects_delete(status, set.objects) \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_contents_delete(status, set.contents) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quoteds_delete(status, set.objects_quoted) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quotedss_delete(status, set.contents_quoted) \
+    }
+
+  #define f_macro_fss_set_quoted_destroy(status, set) \
+    f_macro_fss_objects_destroy(status, set.objects) \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_contents_destroy(status, set.contents) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quoteds_destroy(status, set.objects_quoted) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quotedss_destroy(status, set.contents_quoted) \
+    }
+
+  #define f_macro_fss_set_quoted_delete_simple(set) \
+    f_macro_fss_objects_delete_simple(set.objects) \
+    f_macro_fss_contents_delete_simple(set.contents) \
+    f_macro_fss_quoteds_delete_simple(set.objects_quoted) \
+    f_macro_fss_quotedss_delete_simple(set.contents_quoted)
+
+  #define f_macro_fss_set_quoted_destroy_simple(set) \
+    f_macro_fss_objects_destroy_simple(set.objects) \
+    f_macro_fss_contents_destroy_simple(set.contents) \
+    f_macro_fss_quoteds_destroy_simple(set.objects_quoted) \
+    f_macro_fss_quotedss_destroy_simple(set.contents_quoted)
+
+  #define f_macro_fss_set_quoted_resize(status, set, new_length) \
+    f_macro_fss_objects_resize(status, set.objects, new_length) \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_contents_resize(status, set.contents, new_length) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quoteds_resize(status, set.objects_quoted, new_length) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quotedss_resize(status, set.contents_quoted, new_length) \
+    }
+
+  #define f_macro_fss_set_quoted_adjust(status, set, new_length) \
+    f_macro_fss_objects_resize(status, set.objects, new_length) \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_contents_resize(status, set.contents, new_length) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quoteds_resize(status, set.objects_quoted, new_length) \
+    } \
+    if (F_status_is_fine(status)) { \
+      f_macro_fss_quotedss_resize(status, set.contents_quoted, new_length) \
+    }
+#endif // _di_f_fss_set_quoted_
+
+/**
+ * This holds an array of f_fss_set_quoted.
+ *
+ * array: an array of f_fss_set_quoted.
+ * size:  total amount of allocated space.
+ * used:  total number of allocated spaces used.
+ */
+#ifndef _di_fss_set_quoteds_
+  typedef struct {
+    f_fss_set *array;
+
+    f_array_length size;
+    f_array_length used;
+  } f_fss_set_quoteds;
+
+  #define f_fss_set_quoteds_initialize { 0, 0, 0 }
+
+  /**
+   * Reset a fss content sets to 0 (clear all values).
+   *
+   * This does not deallocate memory, be certain that memory is not allocated before calling this to avoid potential memory leaks.
+   *
+   * sets: the f_fss_set_quoteds structure to operate on.
+   */
+  #define f_macro_fss_set_quoteds_clear(sets) \
+    sets.array = 0; \
+    sets.size = 0; \
+    sets.used = 0;
+
+  /**
+   * Create a new fss content sets.
+   *
+   * This does not deallocate memory, be certain that memory is not allocated before calling this to avoid potential memory leaks.
+   *
+   * status:     the status to return.
+   * sets:       the f_fss_set_quoteds structure to operate on.
+   * new_length: the new size of the array.
+   */
+  #define f_macro_fss_set_quoteds_new(status, sets, length) \
+    sets.array = 0; \
+    sets.size = 0; \
+    sets.used = 0; \
+    status = f_memory_new((void **) & sets.array, sizeof(f_fss_set_quoted), length); \
+    if (status == F_none) { \
+      sets.size = length; \
+      sets.used = 0; \
+    }
+
+  /**
+   * Delete a fss content sets.
+   *
+   * status: the status to return.
+   * sets:   the f_fss_set_quoteds structure to operate on.
+   */
+  #define f_macro_fss_set_quoteds_delete(status, sets) \
+    status = F_none; \
+    sets.used = sets.size; \
+    while (sets.used > 0) { \
+      sets.used--; \
+      f_macro_fss_set_quoted_delete(status, sets.array[sets.used]); \
+      if (status != F_none) break; \
+    } \
+    if (status == F_none) status = f_memory_delete((void **) & sets.array, sizeof(f_fss_set_quoted), sets.size); \
+    if (status == F_none) sets.size = 0;
+
+  /**
+   * Destroy a fss content sets.
+   *
+   * status: the status to return.
+   * sets:   the f_fss_set_quoteds structure to operate on.
+   */
+  #define f_macro_fss_set_quoteds_destroy(status, sets) \
+    status = F_none; \
+    sets.used = sets.size; \
+    while (sets.used > 0) { \
+      sets.used--; \
+      f_macro_fss_set_quoted_destroy(status, sets.array[sets.used]); \
+      if (status != F_none) break; \
+    } \
+    if (status == F_none) status = f_memory_destroy((void **) & sets.array, sizeof(f_fss_set_quoted), sets.size); \
+    if (status == F_none) sets.size = 0;
+
+  /**
+   * Delete a fss content sets.
+   *
+   * sets: the f_fss_set_quoteds structure to operate on.
+   */
+  #define f_macro_fss_set_quoteds_delete_simple(sets) \
+    sets.used = sets.size; \
+    while (sets.used > 0) { \
+      sets.used--; \
+      f_macro_fss_set_quoted_delete_simple(sets.array[sets.used]); \
+      if (sets.used == 0) { \
+        if (f_memory_delete((void **) & sets.array, sizeof(f_fss_set_quoted), sets.size)) { \
+          sets.size = 0; \
+        } \
+      } \
+    }
+
+  /**
+   * Destroy a fss content sets.
+   *
+   * sets: the f_fss_set_quoteds structure to operate on.
+   */
+  #define f_macro_fss_set_quoteds_destroy_simple(sets) \
+    sets.used = sets.size; \
+    while (sets.used > 0) { \
+      sets.used--; \
+      f_macro_fss_set_quoted_destroy_simple(sets.array[sets.used]); \
+      if (sets.used == 0) { \
+        if (f_memory_destroy((void **) & sets.array, sizeof(f_fss_set_quoted), sets.size)) { \
+          sets.size = 0; \
+        } \
+      } \
+    }
+
+  /**
+   * Resize a fss content sets.
+   *
+   * status:     the status to return.
+   * sets:       the f_fss_set_quoteds structure to operate on.
+   * new_length: the new size of the array.
+   */
+  #define f_macro_fss_set_quoteds_resize(status, sets, new_length) \
+    status = F_none; \
+    if (new_length < sets.size) { \
+      for (f_array_length _macro__i = sets.size - new_length; _macro__i < sets.size; _macro__i++) { \
+        f_macro_fss_set_quoted_delete(status, sets.array[_macro__i]); \
+        if (status != F_none) break; \
+      } \
+    } \
+    if (status == F_none) status = f_memory_resize((void **) & sets.array, sizeof(f_fss_set_quoted), sets.size, new_length); \
+    if (status == F_none) { \
+      if (new_length > sets.size) { \
+        for (f_array_length _macro__i = sets.size; _macro__i < new_length; _macro__i++) { \
+          memset(&sets.array[_macro__i], 0, sizeof(f_fss_set_quoted)); \
+        } \
+      } \
+      sets.size = new_length; \
+      if (sets.used > sets.size) sets.used = new_length; \
+    }
+
+  /**
+   * Adjust a fss content sets.
+   *
+   * status:     the status to return.
+   * sets:       the f_fss_set_quoteds structure to operate on.
+   * new_length: he new size of the array.
+   */
+  #define f_macro_fss_set_quoteds_adjust(status, sets, new_length) \
+    status = F_none; \
+    if (new_length < sets.size) { \
+      for (f_array_length _macro__i = sets.size - new_length; _macro__i < sets.size; _macro__i++) { \
+        f_macro_fss_set_quoted_destroy(status, sets.array[_macro__i]); \
+        if (status != F_none) break; \
+      } \
+    } \
+    if (status == F_none) status = f_memory_adjust((void **) & sets.array, sizeof(f_fss_set_quoted), sets.size, new_length); \
+    if (status == F_none) { \
+      if (new_length > sets.size) { \
+        for (f_array_length _macro__i = sets.size; _macro__i < new_length; _macro__i++) { \
+          memset(&sets.array[_macro__i], 0, sizeof(f_fss_set_quoted)); \
+        } \
+      } \
+      sets.size = new_length; \
+      if (sets.used > sets.size) sets.used = new_length; \
+    }
+#endif // _di_fss_set_quoteds_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif