Move some common and repeated code into private functions.
Be sure to allow and handle whitespace after a valid object close that is being delimited within content.
Begin adding support for nested in the extended list content write.
- The idea here is to have a whitelist of ranges to ignore.
- This offloads the possible complex logic to a higher level.
The basic and extended list level 2 write functions should both accept a single content instead of an array of content.
Rename the fss write functions, appending _string.
- These functions accept a string instead of an appropriate object/content structure.
- I will need to write the functions that accept the appropriate object/content structures to perform the same tasks.
Make the prepend a constant pointer to make it easier to not specify it (no variable needs to be defined, just pass 0).
}
#endif // _di_fl_fss_basic_content_read_
-#ifndef _di_fl_fss_basic_object_write_
- f_return_status fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_basic_object_write_string_
+ f_return_status fl_fss_basic_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
if (!destination) return F_status_set_error(F_parameter);
return status;
}
-#endif // _di_fl_fss_basic_object_write_
+#endif // _di_fl_fss_basic_object_write_string_
-#ifndef _di_fl_fss_basic_content_write_
- f_return_status fl_fss_basic_content_write(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_basic_content_write_string_
+ f_return_status fl_fss_basic_content_write_string(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
if (!destination) return F_status_set_error(F_parameter);
return F_none_eos;
}
-#endif // _di_fl_fss_basic_content_write_
+#endif // _di_fl_fss_basic_content_write_string_
#ifdef __cplusplus
} // extern "C"
#endif // _di_fl_fss_basic_content_read_
/**
- * Write an fss-0000 object.
+ * Write an fss-0000 object from a given string.
*
* This will write the given string range as a valid object.
* Anything within this range will be escaped as necessary.
* Errors (with error bit) from: f_fss_is_space().
* Errors (with error bit) from: f_utf_buffer_increment().
*/
-#ifndef _di_fl_fss_basic_object_write_
- extern f_return_status fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_basic_object_write_
+#ifndef _di_fl_fss_basic_object_write_string_
+ extern f_return_status fl_fss_basic_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_basic_object_write_string_
/**
- * Write an fss-0000 content.
+ * Write an fss-0000 content from a given string.
*
* This will write the given string range as a valid content.
* Anything within this range will be escaped as necessary.
* F_parameter (with error bit) if a parameter is invalid.
* F_string_too_large (with error bit) if appended string length is too large to store in the destination.
*/
-#ifndef _di_fl_fss_basic_content_write_
- extern f_return_status fl_fss_basic_content_write(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_basic_content_write_
+#ifndef _di_fl_fss_basic_content_write_string_
+ extern f_return_status fl_fss_basic_content_write_string(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_basic_content_write_string_
#ifdef __cplusplus
} // extern "C"
}
#endif // _di_fl_fss_basic_list_content_read_
-#ifndef _di_fl_fss_basic_list_object_write_
- f_return_status fl_fss_basic_list_object_write(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_basic_list_object_write_string_
+ f_return_status fl_fss_basic_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
return F_none;
}
-#endif // _di_fl_fss_basic_list_object_write_
+#endif // _di_fl_fss_basic_list_object_write_string_
-#ifndef _di_fl_fss_basic_list_content_write_
- f_return_status fl_fss_basic_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t prepend, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_basic_list_content_write_string_
+ f_return_status fl_fss_basic_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
if (!destination) return F_status_set_error(F_parameter);
destination->string[destination->used++] = content.string[range->start];
has_graph = F_true;
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
+ for (range->start++; range->start <= range->stop && range->start < content.used; range->start++) {
- for (; range->start <= range->stop && range->start < content.used; range->start++) {
-
- if (content.string[range->start] == f_fss_delimit_placeholder) {
- continue;
- }
- else if (content.string[range->start] != f_fss_delimit_slash) {
- break;
- }
+ if (content.string[range->start] == f_fss_delimit_placeholder) continue;
+ if (content.string[range->start] != f_fss_delimit_slash) break;
destination->string[destination->used++] = f_fss_delimit_slash;
slash_count++;
} // for
if (content.string[range->start] == f_fss_basic_list_open) {
- start = range->start;
-
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
-
- while (range->start < content.used && range->start <= range->stop) {
-
- if (content.string[range->start] == f_fss_eol) {
- do_prepend = F_true;
- break;
- }
-
- status = f_fss_is_space(content, *range);
- if (F_status_is_error(status)) break;
-
- if (status == F_false) break;
-
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
- } // while
+ start = range->start++;
+ status = private_fl_fss_basic_list_write_skip_whitespace(content, range);
if (F_status_is_error(status)) break;
if (content.string[range->start] == f_fss_eol || range->start >= content.used || range->start > range->stop) {
} // while
destination->string[destination->used++] = f_fss_delimit_slash;
- has_graph = F_false;
- is_comment = F_false;
- }
- else {
- status = private_fl_fss_destination_increase(destination);
- if (F_status_is_error(status)) break;
- }
+ destination->string[destination->used++] = f_fss_basic_list_open;
- destination->string[destination->used++] = f_fss_basic_list_open;
+ range->start = start + 1;
- if (content.string[range->start] == f_fss_eol) {
- destination->string[destination->used++] = f_fss_eol;
+ status = private_fl_fss_basic_list_write_add_until_end(content, range, destination);
+ if (F_status_is_error(status)) break;
+
+ continue;
}
+ status = private_fl_fss_destination_increase(destination);
+ if (F_status_is_error(status)) break;
+
+ destination->string[destination->used++] = f_fss_basic_list_open;
range->start = start + 1;
continue;
}
}
else if (content.string[range->start] == f_fss_basic_list_open && !is_comment) {
start = range->start++;
- has_graph = F_true;
-
- while (range->start < content.used && range->start <= range->stop) {
-
- if (content.string[range->start] == f_fss_eol) break;
-
- status = f_fss_is_space(content, *range);
- if (F_status_is_error(status)) break;
-
- if (status == F_false) break;
-
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
- } // while
-
- if (F_status_is_error(status)) break;
if (do_prepend) {
status = private_fl_fss_destination_prepend(prepend, destination);
do_prepend = F_false;
}
+ has_graph = F_true;
+
+ status = private_fl_fss_basic_list_write_skip_whitespace(content, range);
+ if (F_status_is_error(status)) break;
+
if (content.string[range->start] == f_fss_eol || range->start >= content.used || range->start > range->stop) {
- if (content.string[range->start] == f_fss_eol) {
- do_prepend = F_true;
- }
// increase by slash and basic list open and possible newline.
status = private_fl_fss_destination_increase_by(3, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = f_fss_delimit_slash;
- has_graph = F_false;
- is_comment = F_false;
- }
- else {
- status = private_fl_fss_destination_increase(destination);
- if (F_status_is_error(status)) break;
- }
+ destination->string[destination->used++] = f_fss_basic_list_open;
- destination->string[destination->used++] = f_fss_basic_list_open;
+ range->start = start + 1;
- if (content.string[range->start] == f_fss_eol) {
- destination->string[destination->used++] = f_fss_eol;
+ status = private_fl_fss_basic_list_write_add_until_end(content, range, destination);
+ if (F_status_is_error(status)) break;
+
+ continue;
}
+ status = private_fl_fss_destination_increase(destination);
+ if (F_status_is_error(status)) break;
+
+ destination->string[destination->used++] = f_fss_basic_list_open;
range->start = start + 1;
continue;
}
return F_none;
}
-#endif // _di_fl_fss_basic_list_content_write_
+#endif // _di_fl_fss_basic_list_content_write_string_
#ifdef __cplusplus
} // extern "C"
#endif // _di_fl_fss_basic_list_object_read_
/**
- * Read an fss-0002 content.
+ * Read an fss-0002 content from a given string.
*
* This will update the buffer at the given range with any placeholders to unescape any escaped data.
* Calling this more than once on the same buffer range could result in multiple unescaping.
*
* Errors (with error bit) from: f_utf_buffer_increment().
*/
-#ifndef _di_fl_fss_basic_list_object_write_
- extern f_return_status fl_fss_basic_list_object_write(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_basic_list_object_write_
+#ifndef _di_fl_fss_basic_list_object_write_string_
+ extern f_return_status fl_fss_basic_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_basic_list_object_write_string_
/**
- * Write an fss-0002 content.
+ * Write an fss-0002 content from a given string.
*
* This will write the given string range as a valid content.
* Anything within this range will be escaped as necessary.
* @param prepend
* A string of whitespace to prepend at the start of each line.
* This should only be whitespace, anything else could product invalid content.
- * Set prepend.used to 0 to not use.
+ * Set the pointer address to 0 to disable.
* @param range
* The start/stop location within the content string to write as an content.
* @param destination
*
* Errors (with error bit) from: f_utf_buffer_increment().
*/
-#ifndef _di_fl_fss_basic_list_content_write_
- extern f_return_status fl_fss_basic_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t prepend, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_basic_list_content_write_
+#ifndef _di_fl_fss_basic_list_content_write_string_
+ extern f_return_status fl_fss_basic_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_basic_list_content_write_string_
#ifdef __cplusplus
} // extern "C"
}
#endif // _di_fl_fss_extended_content_read_
-#ifndef _di_fl_fss_extended_object_write_
-f_return_status fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_extended_object_write_string_
+f_return_status fl_fss_extended_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
if (!destination) return F_status_set_error(F_parameter);
return status;
}
-#endif // _di_fl_fss_extended_object_write_
+#endif // _di_fl_fss_extended_object_write_string_
-#ifndef _di_fl_fss_extended_content_write_
- f_return_status fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_extended_content_write_string_
+ f_return_status fl_fss_extended_content_write_string(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
if (!destination) return F_status_set_error(F_parameter);
return status;
}
-#endif // _di_fl_fss_extended_content_write_
+#endif // _di_fl_fss_extended_content_write_string_
#ifdef __cplusplus
} // extern "C"
#endif // _di_fl_fss_extended_content_read_
/**
- * Write an fss-0001 object.
+ * Write an fss-0001 object from a given string.
*
* This will write the given string range as a valid object.
* Anything within this range will be escaped as necessary.
* Errors (with error bit) from: f_fss_is_space().
* Errors (with error bit) from: f_utf_buffer_increment().
*/
-#ifndef _di_fl_fss_extended_object_write_
- extern f_return_status fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_extended_object_write_
+#ifndef _di_fl_fss_extended_object_write_string_
+ extern f_return_status fl_fss_extended_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_extended_object_write_string_
/**
- * Write an fss-0001 content.
+ * Write an fss-0001 content from a given string.
*
* This will write the given string range as a valid content.
* Anything within this range will be escaped as necessary.
* Errors (with error bit) from: f_fss_is_space().
* Errors (with error bit) from: f_utf_buffer_increment().
*/
-#ifndef _di_fl_fss_extended_content_write_
- extern f_return_status fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_extended_content_write_
+#ifndef _di_fl_fss_extended_content_write_string_
+ extern f_return_status fl_fss_extended_content_write_string(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_extended_content_write_string_
#ifdef __cplusplus
} // extern "C"
}
#endif // _di_fl_fss_extended_list_content_read_
-#ifndef _di_fl_fss_extended_list_object_write_
- f_return_status fl_fss_extended_list_object_write(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_extended_list_object_write_string_
+ f_return_status fl_fss_extended_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
return F_none;
}
-#endif // _di_fl_fss_extended_list_object_write_
+#endif // _di_fl_fss_extended_list_object_write_string_
-#ifndef _di_fl_fss_extended_list_content_write_
- f_return_status fl_fss_extended_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t prepend, f_string_range_t *range, f_string_dynamic_t *destination) {
+#ifndef _di_fl_fss_extended_list_content_write_string_
+ f_return_status fl_fss_extended_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_string_range_t *range, f_string_dynamic_t *destination) {
#ifndef _di_level_1_parameter_checking_
if (!range) return F_status_set_error(F_parameter);
if (!destination) return F_status_set_error(F_parameter);
f_string_length_t slash_count = 0;
f_string_length_t start = 0;
+ f_array_length_t r = 0;
+
uint8_t width = 0;
while (range->start <= range->stop && range->start < content.used) {
}
destination->string[destination->used++] = content.string[range->start];
- has_graph = F_true;
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
+ for (range->start++; range->start <= range->stop && range->start < content.used; range->start++) {
- for (; range->start <= range->stop && range->start < content.used; range->start++) {
-
- if (content.string[range->start] == f_fss_delimit_placeholder) {
- continue;
- }
- else if (content.string[range->start] != f_fss_delimit_slash) {
- break;
- }
+ if (content.string[range->start] == f_fss_delimit_placeholder) continue;
+ if (content.string[range->start] != f_fss_delimit_slash) break;
destination->string[destination->used++] = f_fss_delimit_slash;
slash_count++;
} // for
- if (content.string[range->start] == f_fss_extended_list_open) {
- start = range->start;
-
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
-
- while (range->start < content.used && range->start <= range->stop) {
-
- if (content.string[range->start] == f_fss_eol) {
- do_prepend = F_true;
- break;
- }
-
- status = f_fss_is_space(content, *range);
- if (F_status_is_error(status)) break;
-
- if (status == F_false) break;
-
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
- } // while
+ if (content.string[range->start] == f_fss_extended_list_open || content.string[range->start] == f_fss_extended_list_close) {
+ start = range->start++;
+ status = private_fl_fss_basic_list_write_skip_whitespace(content, range);
if (F_status_is_error(status)) break;
- if (content.string[range->start] == f_fss_eol || range->start >= content.used || range->start > range->stop) {
+ if (has_graph && content.string[range->start] == f_fss_extended_list_close) {
+ // do nothing.
+ }
+ else if (content.string[range->start] == f_fss_eol || range->start >= content.used || range->start > range->stop) {
// increase by total slashes + 1, along with the extended list open and possible newline.
status = private_fl_fss_destination_increase_by(slash_count + 3, destination);
} // while
destination->string[destination->used++] = f_fss_delimit_slash;
- has_graph = F_false;
- is_comment = F_false;
- }
- else {
- status = private_fl_fss_destination_increase(destination);
+ destination->string[destination->used++] = content.string[start];
+
+ range->start = start + 1;
+
+ status = private_fl_fss_basic_list_write_add_until_end(content, range, destination);
if (F_status_is_error(status)) break;
+
+ if (content.string[range->start] != f_fss_eol) {
+ has_graph = F_true;
+ }
+
+ continue;
}
- destination->string[destination->used++] = f_fss_extended_list_open;
+ // increase by character at "start" and possible newline.
+ status = private_fl_fss_destination_increase_by(2, destination);
+ if (F_status_is_error(status)) break;
+
+ destination->string[destination->used++] = content.string[start];
if (content.string[range->start] == f_fss_eol) {
destination->string[destination->used++] = f_fss_eol;
continue;
}
}
- else if (content.string[range->start] == f_fss_extended_list_open && !is_comment) {
+ else if ((content.string[range->start] == f_fss_extended_list_open || (!has_graph && content.string[range->start] == f_fss_extended_list_close)) && !is_comment) {
start = range->start++;
- has_graph = F_true;
-
- while (range->start < content.used && range->start <= range->stop) {
-
- if (content.string[range->start] == f_fss_eol) break;
-
- status = f_fss_is_space(content, *range);
- if (F_status_is_error(status)) break;
-
- if (status == F_false) break;
-
- status = f_utf_buffer_increment(content, range, 1);
- if (F_status_is_error(status)) break;
- } // while
-
- if (F_status_is_error(status)) break;
if (do_prepend) {
status = private_fl_fss_destination_prepend(prepend, destination);
do_prepend = F_false;
}
+ has_graph = F_true;
+
+ status = private_fl_fss_basic_list_write_skip_whitespace(content, range);
+ if (F_status_is_error(status)) break;
+
if (content.string[range->start] == f_fss_eol || range->start >= content.used || range->start > range->stop) {
if (content.string[range->start] == f_fss_eol) {
do_prepend = F_true;
}
+ if (ignore && ignore->used) {
+ for (r = 0; r < ignore->used; r++) {
+ if (start >= ignore->array[r].start && start <= ignore->array[r].stop) break;
+ } // for
+
+ if (r < ignore->used) {
+ status = private_fl_fss_destination_increase(destination);
+ if (F_status_is_error(status)) break;
+
+ destination->string[destination->used++] = content.string[start];
+ range->start = start + 1;
+ ends_on_eol = F_false;
+ continue;
+ }
+ }
+
// increase by slash and extended list open and possible newline.
status = private_fl_fss_destination_increase_by(3, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = f_fss_delimit_slash;
- has_graph = F_false;
- is_comment = F_false;
- }
- else {
- status = private_fl_fss_destination_increase(destination);
- if (F_status_is_error(status)) break;
- }
+ destination->string[destination->used++] = content.string[start];
- destination->string[destination->used++] = f_fss_extended_list_open;
+ range->start = start + 1;
- if (content.string[range->start] == f_fss_eol) {
- destination->string[destination->used++] = f_fss_eol;
- ends_on_eol = F_true;
- }
- else {
- ends_on_eol = F_false;
+ status = private_fl_fss_basic_list_write_add_until_end(content, range, destination);
+ if (F_status_is_error(status)) break;
+
+ continue;
}
+ status = private_fl_fss_destination_increase(destination);
+ if (F_status_is_error(status)) break;
+
+ destination->string[destination->used++] = content.string[start];
range->start = start + 1;
continue;
}
return F_none;
}
-#endif // _di_fl_fss_extended_list_content_write_
+#endif // _di_fl_fss_extended_list_content_write_string_
#ifdef __cplusplus
} // extern "C"
#endif // _di_fl_fss_extended_list_content_read_
/**
- * Write an fss-0003 object.
+ * Write an fss-0003 object from a given string.
*
* This will write the given string range as a valid object.
* Anything within this range will be escaped as necessary.
*
* Errors (with error bit) from: f_utf_buffer_increment().
*/
-#ifndef _di_fl_fss_extended_list_object_write_
- extern f_return_status fl_fss_extended_list_object_write(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_extended_list_object_write_
+#ifndef _di_fl_fss_extended_list_object_write_string_
+ extern f_return_status fl_fss_extended_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_extended_list_object_write_string_
/**
- * Write an fss-0003 content.
+ * Write an fss-0003 content from a given string.
*
* This will write the given string range as a valid content.
* Anything within this range will be escaped as necessary.
* @param prepend
* A string of whitespace to prepend at the start of each line.
* This should only be whitespace, anything else could product invalid content.
- * Set prepend.used to 0 to not use.
+ * Set the pointer address to 0 to disable.
+ * @param ignore
+ * An optional list of ranges within the string to ignore.
+ * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close.
+ * Any valid nested object open or valid nested object close inside an ingore range will not be escaped.
+ * Set the pointer address to 0 to disable.
* @param range
* The start/stop location within the content string to write as an content.
* @param destination
*
* Errors (with error bit) from: f_utf_buffer_increment().
*/
-#ifndef _di_fl_fss_extended_list_content_write_
- extern f_return_status fl_fss_extended_list_content_write(const f_string_static_t content, const uint8_t complete, const f_string_static_t prepend, f_string_range_t *range, f_string_dynamic_t *destination);
-#endif // _di_fl_fss_extended_list_content_write_
+#ifndef _di_fl_fss_extended_list_content_write_string_
+ extern f_return_status fl_fss_extended_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_string_range_t *range, f_string_dynamic_t *destination);
+#endif // _di_fl_fss_extended_list_content_write_string_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_)
+#if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_)
f_return_status private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_string_length_t used_start, f_string_dynamic_t *destination) {
f_status_t status = F_none;
f_string_range_t destination_range = f_macro_string_range_t_initialize(destination->used);
return F_none;
}
-#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_)
+#endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_)
-#if !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
+ f_return_status private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_string_range_t *range, f_string_dynamic_t *destination) {
+ f_status_t status = F_none;
+
+ for (; range->start <= range->stop && range->start < buffer.used; range->start++) {
+
+ if (buffer.string[range->start] == f_fss_delimit_placeholder) continue;
+ if (buffer.string[range->start] == f_fss_eol) break;
+
+ status = private_fl_fss_destination_increase(destination);
+ if (F_status_is_error(status)) break;
+
+ destination->string[destination->used++] = buffer.string[range->start];
+ } // for
+
+ return status;
+ }
+#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
+
+
+#if !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_)
f_return_status private_fl_fss_basic_list_write_object_trim(const f_string_length_t used_start, f_string_dynamic_t *destination) {
f_status_t status = F_none;
f_string_range_t destination_range = f_macro_string_range_t_initialize(destination->used);
return F_none;
}
-#endif // !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+#endif // !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_)
+
+#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
+ f_return_status private_fl_fss_basic_list_write_skip_whitespace(const f_string_static_t buffer, f_string_range_t *range) {
+ f_status_t status = F_none;
+
+ while (range->start <= range->stop && range->start < buffer.used) {
+
+ if (buffer.string[range->start] == f_fss_delimit_placeholder) {
+ range->start++;
+ continue;
+ }
+
+ if (buffer.string[range->start] == f_fss_eol) break;
+
+ status = f_fss_is_space(buffer, *range);
+ if (F_status_is_error(status)) break;
+
+ if (status == F_false) break;
+
+ status = f_utf_buffer_increment(buffer, range, 1);
+ if (F_status_is_error(status)) break;
+ } // while
+
+ return status;
+ }
+#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
#if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_)
f_return_status private_fl_fss_basic_read(const bool object_as, f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_string_lengths_t *delimits) {
}
#endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_)
-#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_)
+#if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_)
f_return_status private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quote, f_string_range_t *range, f_string_dynamic_t *destination) {
f_status_t status = F_none;
return F_none_eos;
}
-#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_)
+#endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_)
-#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
f_return_status private_fl_fss_destination_increase(f_string_dynamic_t *destination) {
f_status_t status = F_none;
return status;
}
-#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
-#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
f_return_status private_fl_fss_destination_increase_by(const f_string_length_t amount, f_string_dynamic_t *destination) {
f_status_t status = F_none;
return status;
}
-#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
-#if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_)
- f_return_status private_fl_fss_destination_prepend(const f_string_static_t prepend, f_string_dynamic_t *destination) {
+#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
+ f_return_status private_fl_fss_destination_prepend(const f_string_static_t *prepend, f_string_dynamic_t *destination) {
- if (!prepend.used) {
+ if (!prepend || !prepend->used) {
return F_none;
}
- if (prepend.used) {
- f_status_t status = private_fl_fss_destination_increase_by(prepend.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = private_fl_fss_destination_increase_by(prepend->used, destination);
+ if (F_status_is_error(status)) return status;
- for (f_string_length_t i = 0; i < prepend.used; i++) {
- destination->string[destination->used++] = prepend.string[i];
+ for (f_string_length_t i = 0; i < prepend->used; i++) {
+ destination->string[destination->used++] = prepend->string[i];
} // for
return F_none;
}
-#endif // !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
#ifdef __cplusplus
} // extern "C"
*
* Errors (with error bit) from: f_fss_is_space().
*
- * @see fl_fss_basic_object_write()
- * @see fl_fss_extended_object_write()
+ * @see fl_fss_basic_object_write_string()
+ * @see fl_fss_extended_object_write_string()
*/
-#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_)
+#if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_)
extern f_return_status private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_string_length_t used_start, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
-#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_)
+#endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_)
+
+/**
+ * Add all bytes to destination until stop point, buffer end, or EOL.
+ *
+ * @param buffer
+ * The buffer to seek through.
+ * @param range
+ * The start/stop location within the buffer string to process.
+ * @param destination
+ * The buffer where the bytes are written to.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: private_fl_fss_destination_increase().
+ *
+ * @see fl_fss_basic_list_content_write_string()
+ * @see fl_fss_extended_list_content_write_string()
+ * @see private_fl_fss_destination_increase()
+ */
+#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
+ extern f_return_status private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_string_range_t *range, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
+#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
/**
* Trim a given object used by the basic list and extended list object write functions.
*
* Errors (with error bit) from: f_fss_is_space().
*
- * @see fl_fss_basic_list_object_write()
- * @see fl_fss_extended_list_object_write()
+ * @see fl_fss_basic_list_object_write_string()
+ * @see fl_fss_extended_list_object_write_string()
*/
-#if !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+#if !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_)
extern f_return_status private_fl_fss_basic_list_write_object_trim(const f_string_length_t used_start, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
-#endif // !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_)
+#endif // !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_)
+
+/**
+ * Skip past whitespace, seeking until stop point, buffer end, or EOL.
+ *
+ * @param buffer
+ * The buffer to seek through.
+ * @param range
+ * The start/stop location within the buffer string to process.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_fss_is_space().
+ * Errors (with error bit) from: f_utf_buffer_increment().
+ *
+ * @see fl_fss_basic_list_content_write_string()
+ * @see fl_fss_extended_list_content_write_string()
+ */
+#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
+ extern f_return_status private_fl_fss_basic_list_write_skip_whitespace(const f_string_static_t buffer, f_string_range_t *range) f_gcc_attribute_visibility_internal;
+#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
/**
* Private implementation of fl_fss_basic_object_read().
#endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_)
/**
- * Private implementation of fl_fss_basic_object_write().
+ * Private implementation of fl_fss_basic_object_write_string().
*
* Intended to be shared to each of the different implementation variations.
*
*
* Errors (with error bit) from: f_utf_buffer_increment().
*
- * @see fl_fss_basic_object_write()
- * @see fl_fss_extended_object_write()
- * @see fl_fss_extended_content_write()
+ * @see fl_fss_basic_object_write_string()
+ * @see fl_fss_extended_object_write_string()
+ * @see fl_fss_extended_content_write_string()
*/
-#if !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write) || !defined(_di_fl_fss_extended_content_write_)
+#if !defined(fl_fss_basic_object_write_string) || !defined(fl_fss_extended_object_write_string) || !defined(_di_fl_fss_extended_content_write_string_)
extern f_return_status private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
-#endif // !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write) || !defined(_di_fl_fss_extended_content_write_)
+#endif // !defined(fl_fss_basic_object_write_string) || !defined(fl_fss_extended_object_write_string) || !defined(_di_fl_fss_extended_content_write_string_)
/**
* Increase the size of destination buffer, but only if necessary.
* F_memory_reallocation (with error bit) on reallocation error.
* F_string_too_large (with error bit) if appended string length is too large to store in the destination.
*
- * @see fl_fss_basic_object_write()
- * @see fl_fss_basic_content_write()
- * @see fl_fss_basic_list_object_write()
- * @see fl_fss_basic_list_content_write()
- * @see fl_fss_extended_object_write()
- * @see fl_fss_extended_content_write()
- * @see fl_fss_extended_list_object_write()
- * @see fl_fss_extended_list_content_write()
+ * @see fl_fss_basic_object_write_string()
+ * @see fl_fss_basic_content_write_string()
+ * @see fl_fss_basic_list_object_write_string()
+ * @see fl_fss_basic_list_content_write_string()
+ * @see fl_fss_extended_object_write_string()
+ * @see fl_fss_extended_content_write_string()
+ * @see fl_fss_extended_list_object_write_string()
+ * @see fl_fss_extended_list_content_write_string()
*/
-#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
extern f_return_status private_fl_fss_destination_increase(f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
-#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
/**
* Increase the size of destination buffer by the given amount, but only if necessary.
* F_memory_reallocation (with error bit) on reallocation error.
* F_string_too_large (with error bit) if appended string length is too large to store in the destination.
*
- * @see fl_fss_basic_object_write()
- * @see fl_fss_basic_content_write()
- * @see fl_fss_basic_list_object_write()
- * @see fl_fss_basic_list_content_write()
- * @see fl_fss_extended_object_write()
- * @see fl_fss_extended_content_write()
- * @see fl_fss_extended_list_object_write()
- * @see fl_fss_extended_list_content_write()
+ * @see fl_fss_basic_object_write_string()
+ * @see fl_fss_basic_content_write_string()
+ * @see fl_fss_basic_list_object_write_string()
+ * @see fl_fss_basic_list_content_write_string()
+ * @see fl_fss_extended_object_write_string()
+ * @see fl_fss_extended_content_write_string()
+ * @see fl_fss_extended_list_object_write_string()
+ * @see fl_fss_extended_list_content_write_string()
*/
-#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
f_return_status private_fl_fss_destination_increase_by(const f_string_length_t amount, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
-#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_extended_list_object_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_basic_content_write_string_) || !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
/**
* Prepend the given string onto the destination buffer, allocating space as necessary.
*
* @param prepend
* A string to prepend at the start of each line, such as spaces.
- * Set prepend.used to 0 to not use.
+ * Set the pointer address to 0 to disable.
* @param destination
* The destination buffer to prepend to.
*
* F_memory_reallocation (with error bit) on reallocation error.
* F_string_too_large (with error bit) if appended string length is too large to store in the destination.
*
- * @see fl_fss_basic_list_content_write()
- * @see fl_fss_extended_list_content_write()
+ * @see fl_fss_basic_list_content_write_string()
+ * @see fl_fss_extended_list_content_write_string()
*/
-#if !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_)
- f_return_status private_fl_fss_destination_prepend(const f_string_static_t prepend, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
-#endif // !defined(_di_fl_fss_basic_list_content_write_) || !defined(_di_fl_fss_extended_list_content_write_)
+#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
+ f_return_status private_fl_fss_destination_prepend(const f_string_static_t *prepend, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal;
+#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_)
#ifdef __cplusplus
} // extern "C"
}
#endif // _di_fll_fss_basic_read_
-#ifndef _di_fll_fss_basic_write_
- f_return_status fll_fss_basic_write(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination) {
+#ifndef _di_fll_fss_basic_write_string_
+ f_return_status fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination) {
#ifndef _di_level_2_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_2_parameter_checking_
f_status_t status = 0;
f_string_range_t range = f_macro_string_range_t_initialize(object.used);
- status = fl_fss_basic_object_write(object, quote, f_fss_complete_full, &range, destination);
+ status = fl_fss_basic_object_write_string(object, quote, f_fss_complete_full, &range, destination);
if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
return status;
range.start = 0;
range.stop = content.used - 1;
- status = fl_fss_basic_content_write(content, f_fss_complete_full, &range, destination);
+ status = fl_fss_basic_content_write_string(content, f_fss_complete_full, &range, destination);
if (F_status_is_error(status)) return status;
}
else {
return status;
}
-#endif // _di_fll_fss_basic_write_
+#endif // _di_fll_fss_basic_write_string_
#ifdef __cplusplus
} // extern "C"
* This will be populated with all valid contents found.
* @param quoted_objects
* An array of all objects discovered with quotes and the quote discovered.
- * Set pointer address to 0 to disable.
+ * Set the pointer address to 0 to disable.
*
* @return
* F_none on success.
* F_parameter (with error bit) if a parameter is invalid.
* F_utf (with error bit) is returned on failure to read/process a UTF-8 character.
*
- * Errors (with error bit) from: fl_fss_basic_content_write().
- * Errors (with error bit) from: fl_fss_basic_object_write().
+ * Errors (with error bit) from: fl_fss_basic_content_write_string().
+ * Errors (with error bit) from: fl_fss_basic_object_write_string().
* Errors (with error bit) from: fl_string_dynamic_size_increase().
*/
-#ifndef _di_fll_fss_basic_write_
- extern f_return_status fll_fss_basic_write(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination);
-#endif // _di_fll_fss_basic_write_
+#ifndef _di_fll_fss_basic_write_string_
+ extern f_return_status fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination);
+#endif // _di_fll_fss_basic_write_string_
#ifdef __cplusplus
} // extern "C"
}
#endif // _di_fll_fss_basic_list_read_
-#ifndef _di_fll_fss_basic_list_write_
- f_return_status fll_fss_basic_list_write(const f_string_static_t object, const f_string_statics_t contents, const f_string_static_t contents_prepend, f_string_dynamic_t *destination) {
+#ifndef _di_fll_fss_basic_list_write_string_
+ f_return_status fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_string_dynamic_t *destination) {
#ifndef _di_level_2_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_2_parameter_checking_
f_status_t status = 0;
f_string_range_t range = f_macro_string_range_t_initialize(object.used);
- status = fl_fss_basic_list_object_write(object, f_fss_complete_full, &range, destination);
+ status = fl_fss_basic_list_object_write_string(object, f_fss_complete_full, &range, destination);
if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
return status;
}
if (status == F_none || status == F_none_stop || status == F_none_eos || status == F_none_eol) {
- if (contents.used && contents.array[0].used) {
+ if (content.used) {
range.start = 0;
- range.stop = contents.array[0].used - 1;
-
- status = fl_fss_basic_list_content_write(contents.array[0], f_fss_complete_full, contents_prepend, &range, destination);
+ range.stop = content.used - 1;
+ }
+ else {
+ range.start = 1;
+ range.stop = 0;
}
+
+ status = fl_fss_basic_list_content_write_string(content, f_fss_complete_full, content_prepend, &range, destination);
}
return status;
}
-#endif // _di_fll_fss_basic_list_write_
+#endif // _di_fll_fss_basic_list_write_string_
#ifdef __cplusplus
} // extern "C"
*
* @param object
* A string representing the object.
- * @param contents
- * An array of strings representing multiple content to write.
- * @param contents_prepend
- * A string to prepend at the start of each line in contents, such as spaces.
- * Set prepend.used to 0 to not use.
+ * @param content
+ * A string representing the content.
+ * @param content_prepend
+ * A string to prepend at the start of each line in content, such as spaces.
+ * Set the pointer address to 0 to disable.
* @param buffer
* The buffer to write to.
*
* F_parameter (with error bit) if a parameter is invalid.
* F_utf (with error bit) is returned on failure to read/process a UTF-8 character.
*
- * Errors (with error bit) from: fl_fss_basic_list_content_write().
- * Errors (with error bit) from: fl_fss_basic_list_object_write().
+ * Errors (with error bit) from: fl_fss_basic_list_content_write_string().
+ * Errors (with error bit) from: fl_fss_basic_list_object_write_string().
* Errors (with error bit) from: fl_string_dynamic_size_increase().
*/
-#ifndef _di_fll_fss_basic_list_write_
- extern f_return_status fll_fss_basic_list_write(const f_string_static_t object, const f_string_statics_t contents, const f_string_static_t contents_prepend, f_string_dynamic_t *buffer);
-#endif // _di_fll_fss_basic_list_write_
+#ifndef _di_fll_fss_basic_list_write_string_
+ extern f_return_status fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_string_dynamic_t *buffer);
+#endif // _di_fll_fss_basic_list_write_string_
#ifdef __cplusplus
} // extern "C"
}
#endif // _di_fll_fss_extended_read_
-#ifndef _di_fll_fss_extended_write_
- f_return_status fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination) {
+#ifndef _di_fll_fss_extended_write_string_
+ f_return_status fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination) {
#ifndef _di_level_2_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_2_parameter_checking_
f_status_t status = 0;
f_string_range_t range = f_macro_string_range_t_initialize(object.used);
- status = fl_fss_extended_object_write(object, quote, f_fss_complete_full, &range, destination);
+ status = fl_fss_extended_object_write_string(object, quote, f_fss_complete_full, &range, destination);
if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
return status;
range.stop = 0;
}
- status = fl_fss_extended_content_write(contents.array[i], quote, complete, &range, destination);
+ status = fl_fss_extended_content_write_string(contents.array[i], quote, complete, &range, destination);
if (F_status_is_error(status)) {
return status;
return status;
}
-#endif // _di_fll_fss_extended_write_
+#endif // _di_fll_fss_extended_write_string_
#ifdef __cplusplus
} // extern "C"
* This will be populated with all valid contents found.
* @param quoted_objects
* An array of all objects discovered with quotes and the quote discovered.
- * Set pointer address to 0 to disable.
+ * Set the pointer address to 0 to disable.
* @param quoted_contents
* An array of all contents discovered with quotes and the quote discovered.
- * Set pointer address to 0 to disable.
+ * Set the pointer address to 0 to disable.
*
* @return
* F_none on success.
* F_parameter (with error bit) if a parameter is invalid.
* F_utf (with error bit) is returned on failure to read/process a UTF-8 character.
*
- * Errors (with error bit) from: fl_fss_extended_content_write().
- * Errors (with error bit) from: fl_fss_extended_object_write().
+ * Errors (with error bit) from: fl_fss_extended_content_write_string().
+ * Errors (with error bit) from: fl_fss_extended_object_write_string().
* Errors (with error bit) from: fl_string_dynamic_size_increase().
*/
-#ifndef _di_fll_fss_extended_write_
- extern f_return_status fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination);
-#endif // _di_fll_fss_extended_write_
+#ifndef _di_fll_fss_extended_write_string_
+ extern f_return_status fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination);
+#endif // _di_fll_fss_extended_write_string_
#ifdef __cplusplus
} // extern "C"
}
#endif // _di_fll_fss_extended_list_read_
-/*
-#ifndef _di_fll_fss_extended_list_write_
- f_return_status fll_fss_extended_list_write(const f_string_static_t object, const f_string_statics_t contents, f_string_dynamic_t *buffer) {
- #ifndef _di_level_3_parameter_checking_
- if (!buffer) return F_status_set_error(F_parameter);
- if (contents.used > contents.size) return F_status_set_error(F_parameter);
- #endif // _di_level_3_parameter_checking_
+#ifndef _di_fll_fss_extended_list_write_string_
+ f_return_status fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_string_dynamic_t *destination) {
+ #ifndef _di_level_2_parameter_checking_
+ if (!destination) return F_status_set_error(F_parameter);
+ #endif // _di_level_2_parameter_checking_
f_status_t status = 0;
- f_array_length_t current = 0;
- f_string_range_t range = f_string_range_t_initialize;
+ f_string_range_t range = f_macro_string_range_t_initialize(object.used);
- range.start = 0;
- range.stop = object.used - 1;
-
- status = fl_fss_extended_list_object_write(object, &range, buffer);
+ status = fl_fss_extended_list_object_write_string(object, f_fss_complete_full, &range, destination);
if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
return status;
}
if (status == F_none || status == F_none_stop || status == F_none_eos || status == F_none_eol) {
- if (contents.used > 0) {
+ if (content.used) {
range.start = 0;
- range.stop = contents.array[0].used - 1;
-
- status = fl_fss_extended_list_content_write(contents.array[0], &range, buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return status;
- }
+ range.stop = content.used - 1;
}
else {
- if (buffer->used == buffer->size) {
- status = fl_string_dynamic_size_increase(f_fss_default_allocation_step, buffer);
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer->used] = f_string_eol[0];
- buffer->used++;
+ range.start = 1;
+ range.stop = 0;
}
+
+ status = fl_fss_extended_list_content_write_string(content, f_fss_complete_full, content_prepend, ignore, &range, destination);
}
- return F_none;
+ return status;
}
-#endif // _di_fll_fss_extended_list_write_
-*/
+#endif // _di_fll_fss_extended_list_write_string_
#ifdef __cplusplus
} // extern "C"
*
* @param object
* A string representing the object.
- * @param contents
- * An array of strings representing multiple content to write.
- * @param buffer
- * The buffer to write to.
+ * @param content
+ * A string representing the content.
+ * @param content_prepend
+ * A string to prepend at the start of each line in content, such as spaces.
+ * Set the pointer address to 0 to disable.
+ * @param ignore
+ * An optional list of ranges within the string to ignore.
+ * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close.
+ * Any valid nested object open or valid nested object close inside an ingore range will not be escaped.
+ * Set the pointer address to 0 to disable.
+ * @param destination
+ * The buffer where the content is written to.
*
* @return
* F_none on success.
* F_parameter (with error bit) if a parameter is invalid.
* F_utf (with error bit) is returned on failure to read/process a UTF-8 character.
*
- * Errors (with error bit) from: fl_fss_extended_list_content_write().
- * Errors (with error bit) from: fl_fss_extended_list_object_write().
+ * Errors (with error bit) from: fl_fss_extended_list_content_write_string().
+ * Errors (with error bit) from: fl_fss_extended_list_object_write_string().
* Errors (with error bit) from: fl_string_dynamic_size_increase().
*/
-#ifndef _di_fll_fss_extended_list_write_
- //extern f_return_status fll_fss_extended_list_write(const f_string_static_t object, const f_string_statics_t contents, f_string_dynamic_t *buffer);
-#endif // _di_fll_fss_extended_list_write_
+#ifndef _di_fll_fss_extended_list_write_string_
+ extern f_return_status fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_string_dynamic_t *destination);
+#endif // _di_fll_fss_extended_list_write_string_
#ifdef __cplusplus
} // extern "C"
}
}
- status = fl_fss_basic_list_object_write(*object, complete, &range, buffer);
+ status = fl_fss_basic_list_object_write_string(*object, complete, &range, buffer);
if (F_status_set_fine(status) == F_none_eol) {
fss_basic_list_write_error_parameter_unsupported_eol_print(data);
}
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_list_object_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_list_object_write_string", F_true);
return status;
}
}
range.start = 0;
range.stop = content->used - 1;
- status = fl_fss_basic_list_content_write(*content, object ? f_fss_complete_full : f_fss_complete_none, data.prepend, &range, buffer);
+ status = fl_fss_basic_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &data.prepend, &range, buffer);
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_list_content_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_list_content_write_string", F_true);
return status;
}
}
}
}
- status = fl_fss_basic_object_write(*object, quote, complete, &range, buffer);
+ status = fl_fss_basic_object_write_string(*object, quote, complete, &range, buffer);
if (F_status_set_fine(status) == F_none_eol) {
fss_basic_write_error_parameter_unsupported_eol_print(data);
}
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_object_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_object_write_string", F_true);
return status;
}
}
range.stop = 0;
}
- status = fl_fss_basic_content_write(*content, object ? f_fss_complete_full : f_fss_complete_none, &range, buffer);
+ status = fl_fss_basic_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &range, buffer);
if (F_status_set_fine(status) == F_none_eol) {
fss_basic_write_error_parameter_unsupported_eol_print(data);
}
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_content_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_content_write_string", F_true);
return status;
}
}
}
}
- status = fl_fss_extended_list_object_write(*object, complete, &range, buffer);
+ status = fl_fss_extended_list_object_write_string(*object, complete, &range, buffer);
if (F_status_set_fine(status) == F_none_eol) {
fss_extended_list_write_error_parameter_unsupported_eol_print(data);
}
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_list_object_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_list_object_write_string", F_true);
return status;
}
}
range.start = 0;
range.stop = content->used - 1;
- status = fl_fss_extended_list_content_write(*content, object ? f_fss_complete_full : f_fss_complete_none, data.prepend, &range, buffer);
+ // @todo: add const f_string_ranges_t *ignore parameter.
+ status = fl_fss_extended_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &data.prepend, 0, &range, buffer);
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_list_content_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_list_content_write_string", F_true);
return status;
}
}
}
}
- status = fl_fss_extended_object_write(*object, quote, complete, &range, buffer);
+ status = fl_fss_extended_object_write_string(*object, quote, complete, &range, buffer);
if (F_status_set_fine(status) == F_none_eol) {
fss_extended_write_error_parameter_unsupported_eol_print(data);
}
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_object_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_object_write_string", F_true);
return F_status_set_error(status);
}
}
range.stop = 0;
}
- status = fl_fss_extended_content_write(contents->array[i], quote, i + 1 < contents->used ? f_fss_complete_next : f_fss_complete_end, &range, buffer);
+ status = fl_fss_extended_content_write_string(contents->array[i], quote, i + 1 < contents->used ? f_fss_complete_next : f_fss_complete_end, &range, buffer);
if (F_status_set_fine(status) == F_none_eol) {
fss_extended_write_error_parameter_unsupported_eol_print(data);
}
if (F_status_is_error(status)) {
- fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_content_write", F_true);
+ fll_error_print(data.error, F_status_set_fine(status), "fl_fss_extended_content_write_string", F_true);
return F_status_set_error(status);
}
} // for