This should further simplify the standard color processing code for when color codes are replaced with empty strings.
#ifndef _di_fll_program_parameter_process_
f_status_t fll_program_parameter_process(const f_console_arguments_t arguments, f_console_parameters_t parameters, const f_console_parameter_ids_t choices, const bool right, f_array_lengths_t *remaining, f_color_context_t *context) {
+
f_status_t status = F_none;
status = f_console_parameter_process(arguments, parameters, remaining);
}
#endif // _di_fll_program_parameter_process_
+#ifndef _di_fll_program_parameter_process_empty_
+ void fll_program_parameter_process_empty(f_color_context_t *context, f_color_set_t *sets[]) {
+
+ context->set.warning = f_color_set_empty_s;
+ context->set.error = f_color_set_empty_s;
+ context->set.title = f_color_set_empty_s;
+ context->set.notable = f_color_set_empty_s;
+ context->set.important = f_color_set_empty_s;
+ context->set.standout = f_color_set_empty_s;
+ context->set.normal = f_color_set_empty_s;
+ context->set.normal_reset = f_color_set_empty_s;
+
+ if (sets) {
+ for (f_array_length_t i = 0; sets[i]; ++i) {
+ *sets[i] = f_color_set_empty_s;
+ }
+ }
+ }
+#endif // _di_fll_program_parameter_process_empty_
+
#ifndef _di_fll_program_parameter_additional_append_
f_status_t fll_program_parameter_additional_append(const f_string_t *argv, const f_array_lengths_t values, f_string_dynamics_t *destination) {
#ifndef _di_level_2_parameter_checking_
#endif // _di_fll_program_parameter_process_
/**
+ * Set the provided context to empty along with all additional color sets.
+ *
+ * This will allow for safe usage of the color context and color sets to be safely processed when colors are disabled.
+ *
+ * @param context
+ * The primary color context to assign.
+ * @param sets
+ * (optional) A NULL terminated array representing additional sets to assign as empty.
+ * Set to NULL to not use.
+ */
+#ifndef _di_fll_program_parameter_process_empty_
+ extern void fll_program_parameter_process_empty(f_color_context_t *context, f_color_set_t *sets[]);
+#endif // _di_fll_program_parameter_process_empty_
+
+/**
* Allocate new strings from all of the provided locations.
*
* These new strings are appended onto the destination.
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->warning.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
-
- data->warning.context = f_color_set_empty_s;
- data->warning.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, &data->warning.context, &data->warning.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->warning.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
-
- data->warning.context = f_color_set_empty_s;
- data->warning.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, &data->warning.context, &data->warning.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {
data->error.notable = data->context.set.notable;
}
else {
- data->context.set.warning = f_color_set_empty_s;
- data->context.set.error = f_color_set_empty_s;
- data->context.set.title = f_color_set_empty_s;
- data->context.set.notable = f_color_set_empty_s;
- data->context.set.important = f_color_set_empty_s;
- data->context.set.standout = f_color_set_empty_s;
- data->context.set.normal = f_color_set_empty_s;
- data->context.set.normal_reset = f_color_set_empty_s;
-
- data->error.context = f_color_set_empty_s;
- data->error.notable = f_color_set_empty_s;
+ f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+ fll_program_parameter_process_empty(&data->context, sets);
}
if (F_status_is_error(status)) {