extern "C" {
#endif
+#if !defined(_di_fl_string_append_) || !defined(_di_fl_string_dynamic_append_) || !defined(_di_fl_string_dynamic_partial_append_)
+ f_return_status private_fl_string_append(const f_string source, const f_string_length source_length, f_string_dynamic *destination) {
+ f_status status = f_none;
+
+ f_string_length total = destination->used + source_length;
+
+ if (total > f_string_max_size) return f_status_set_error(f_string_too_large);
+
+ if (total > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), total);
+ if (f_status_is_error(status)) return status;
+ }
+
+ memcpy(destination->string + destination->used, source, source_length);
+
+ destination->used = total;
+
+ return f_none;
+ }
+#endif // !defined(_di_fl_string_append_) || !defined(_di_fl_string_dynamic_append_) || !defined(_di_fl_string_dynamic_partial_append_)
+
#if !defined(_di_fl_string_compare_) || !defined(_di_fl_string_dynamic_compare_) || !defined(_di_fl_string_dynamic_partial_compare_)
f_return_status private_fl_string_compare(const f_string string1, const f_string string2, const f_string_length offset1, const f_string_length offset2, const f_string_length stop1, const f_string_length stop2) {
f_string_length i1 = offset1;
}
#endif // !defined(_di_fl_string_mash_) || !defined(_di_fl_string_dynamic_mash_) || !defined(_di_fl_string_dynamic_partial_mash_)
+#if !defined(_di_fl_string_prepend_) || !defined(_di_fl_string_dynamic_prepend_) || !defined(_di_fl_string_dynamic_partial_prepend_)
+ f_return_status private_fl_string_prepend(const f_string source, const f_string_length source_length, f_string_dynamic *destination) {
+ f_status status = f_none;
+
+ f_string_length total = destination->used + source_length;
+
+ if (total > f_string_max_size) return f_status_set_error(f_string_too_large);
+
+ if (total > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), total);
+ if (f_status_is_error(status)) return status;
+ }
+
+ if (destination->used > 0) {
+ memmove(destination->string + source_length, destination->string, destination->used);
+ memcpy(destination->string, source, source_length);
+ }
+ else {
+ memcpy(destination->string, source, source_length);
+ }
+
+ destination->used = total;
+
+ return f_none;
+ }
+#endif // !defined(_di_fl_string_prepend_) || !defined(_di_fl_string_dynamic_prepend_) || !defined(_di_fl_string_dynamic_partial_prepend_)
+
#if !defined(_di_fl_string_rip_) || !defined(_di_fl_string_dynamic_rip_)
f_return_status private_fl_string_rip(const f_string string, const f_string_length start, const f_string_length stop, f_string_dynamic *result) {
// The start and stop point are inclusive locations, and therefore start - stop is actually 1 too few locations.
#endif
/**
+ * Private implementation of fl_string_append().
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param source
+ * The source string to append.
+ * @param source_length
+ * Total number of bytes to copy from source string.
+ * @param destination
+ * The destination string the source and glue are appended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_append()
+ * @see fl_string_dynamic_append()
+ * @see fl_string_dynamic_partial_append()
+ */
+#if !defined(_di_fl_string_append_) || !defined(_di_fl_string_dynamic_append_) || !defined(_di_fl_string_dynamic_partial_append_)
+ extern f_return_status private_fl_string_append(const f_string source, const f_string_length source_length, f_string_dynamic *destination) f_gcc_attribute_visibility_internal;
+#endif // !defined(_di_fl_string_append_) || !defined(_di_fl_string_dynamic_append_) || !defined(_di_fl_string_dynamic_partial_append_)
+
+/**
* Private implementation of fl_string_compare().
*
* Intended to be shared to each of the different implementation variations.
#endif // !defined(_di_fl_string_mash_) || !defined(_di_fl_string_dynamic_mash_) || !defined(_di_fl_string_dynamic_partial_mash_)
/**
+ * Private implementation of fl_string_prepend().
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param source
+ * The source string to prepend.
+ * @param source_length
+ * Total number of bytes to copy from source string.
+ * @param destination
+ * The destination string the source and glue are prepended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_prepend()
+ * @see fl_string_dynamic_prepend()
+ * @see fl_string_dynamic_partial_prepend()
+ */
+#if !defined(_di_fl_string_prepend_) || !defined(_di_fl_string_dynamic_prepend_) || !defined(_di_fl_string_dynamic_partial_prepend_)
+ extern f_return_status private_fl_string_prepend(const f_string source, const f_string_length source_length, f_string_dynamic *destination) f_gcc_attribute_visibility_internal;
+#endif // !defined(_di_fl_string_prepend_) || !defined(_di_fl_string_dynamic_prepend_) || !defined(_di_fl_string_dynamic_partial_prepend_)
+
+/**
* Private implementation of fl_string_rip().
*
* Intended to be shared to each of the different implementation variations.
extern "C" {
#endif
+#ifndef _di_fl_string_append_
+ f_return_status fl_string_append(const f_string source, const f_string_length source_length, f_string_dynamic *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source_length < 1) return f_status_set_error(f_invalid_parameter);
+ if (destination == 0) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ return private_fl_string_append(source, source_length, destination);
+ }
+#endif // _di_fl_string_append_
+
#ifndef _di_fl_string_compare_
f_return_status fl_string_compare(const f_string string1, const f_string string2, const f_string_length length1, const f_string_length length2) {
#ifndef _di_level_1_parameter_checking_
}
#endif // _di_fl_string_dynamic_compare_trim_
+#ifndef _di_fl_string_dynamic_append_
+ f_return_status fl_string_dynamic_append(const f_string_dynamic source, f_string_dynamic *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source.used < 1) return f_status_set_error(f_invalid_parameter);
+ if (destination == 0) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ return private_fl_string_append(source.string, source.used, destination);
+ }
+#endif // _di_fl_string_dynamic_append_
+
#ifndef _di_fl_string_dynamic_mash_
f_return_status fl_string_dynamic_mash(const f_string glue, const f_string_length glue_length, const f_string_dynamic source, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
}
#endif // _di_fl_string_dynamic_partial_compare_trim_
+#ifndef _di_fl_string_dynamic_partial_append_
+ f_return_status fl_string_dynamic_partial_append(const f_string_dynamic source, const f_string_location offset, f_string_dynamic *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source.used < 1) return f_status_set_error(f_invalid_parameter);
+ if (destination == 0) return f_status_set_error(f_invalid_parameter);
+
+ if (offset.start > offset.stop) return f_status_set_error(f_invalid_parameter);
+ if (source.used <= offset.stop) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ return private_fl_string_append(source.string + offset.start, (offset.stop - offset.start) + 1, destination);
+ }
+#endif // _di_fl_string_dynamic_partial_append_
+
#ifndef _di_fl_string_dynamic_partial_mash_
f_return_status fl_string_dynamic_partial_mash(const f_string glue, const f_string_length glue_length, const f_string_dynamic source, const f_string_location offset, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
}
#endif // _di_fl_string_dynamic_partial_mash_
+#ifndef _di_fl_string_dynamic_partial_prepend_
+ f_return_status fl_string_dynamic_partial_prepend(const f_string_dynamic source, const f_string_location offset, f_string_dynamic *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source.used < 1) return f_status_set_error(f_invalid_parameter);
+ if (destination == 0) return f_status_set_error(f_invalid_parameter);
+
+ if (offset.start > offset.stop) return f_status_set_error(f_invalid_parameter);
+ if (source.used <= offset.stop) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ return private_fl_string_prepend(source.string + offset.start, (offset.stop - offset.start) + 1, destination);
+ }
+#endif // _di_fl_string_dynamic_partial_prepend_
+
+#ifndef _di_fl_string_dynamic_prepend_
+ f_return_status fl_string_dynamic_prepend(const f_string_dynamic source, f_string_dynamic *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source.used < 1) return f_status_set_error(f_invalid_parameter);
+ if (destination == 0) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ return private_fl_string_prepend(source.string, source.used, destination);
+ }
+#endif // _di_fl_string_dynamic_prepend_
+
#ifndef _di_fl_string_dynamic_rip_
f_return_status fl_string_dynamic_rip(const f_string_dynamic buffer, const f_string_location location, f_string_dynamic *result) {
#ifndef _di_level_1_parameter_checking_
}
#endif // _di_fl_string_mash_
+#ifndef _di_fl_string_prepend_
+ f_return_status fl_string_prepend(const f_string source, const f_string_length source_length, f_string_dynamic *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source_length < 1) return f_status_set_error(f_invalid_parameter);
+ if (destination == 0) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ return private_fl_string_prepend(source, source_length, destination);
+ }
+#endif // _di_fl_string_prepend_
+
#ifndef _di_fl_string_rip_
f_return_status fl_string_rip(const f_string string, const f_string_length start, const f_string_length stop, f_string_dynamic *result) {
#ifndef _di_level_1_parameter_checking_
#endif
/**
+ * Append the source string onto the destination.
+ *
+ * @param source
+ * The source string to append.
+ * @param source_length
+ * Total number of bytes to copy from source string.
+ * @param destination
+ * The destination string the source is appended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_append()
+ * @see fl_string_dynamic_append()
+ * @see fl_string_dynamic_partial_append()
+ */
+#ifndef _di_fl_string_append_
+ extern f_return_status fl_string_append(const f_string source, const f_string_length source_length, f_string_dynamic *destination);
+#endif // _di_fl_string_append_
+
+/**
* Compare two strings, similar to strncmp().
*
* This does not stop on NULL.
#endif // _di_fl_string_compare_trim_
/**
+ * Append the source string onto the destination.
+ *
+ * @param source
+ * The source string to append.
+ * @param destination
+ * The destination string the source is appended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_append()
+ * @see fl_string_dynamic_append()
+ * @see fl_string_dynamic_partial_append()
+ */
+#ifndef _di_fl_string_dynamic_append_
+ extern f_return_status fl_string_dynamic_append(const f_string_dynamic source, f_string_dynamic *destination);
+#endif // _di_fl_string_dynamic_append_
+
+/**
* Compare two strings, similar to strncmp().
*
* This does not stop on NULL.
#endif // _di_fl_string_dynamic_partial_compare_trim_
/**
+ * Append the source string onto the destination.
+ *
+ * @param source
+ * The source string to append.
+ * @param offset
+ * A range within the source to restrict the append from.
+ * @param destination
+ * The destination string the source is appended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_append()
+ * @see fl_string_dynamic_append()
+ * @see fl_string_dynamic_partial_append()
+ */
+#ifndef _di_fl_string_dynamic_partial_append_
+ extern f_return_status fl_string_dynamic_partial_append(const f_string_dynamic source, const f_string_location offset, f_string_dynamic *destination);
+#endif // _di_fl_string_dynamic_partial_append_
+
+/**
* Append the source string onto the destination with the glue in between.
*
* If the destination string is empty, then no glue is appended.
#endif // _di_fl_string_dynamic_partial_mash_
/**
+ * Prepend the source string onto the destination.
+ *
+ * Prepend operations require memory move operations and are therefore likely more expensive than append operations.
+ *
+ * @param source
+ * The source string to prepend.
+ * @param offset
+ * A range within the source to restrict the prepend from.
+ * @param destination
+ * The destination string the source is prepended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_append()
+ * @see fl_string_prepend()
+ * @see fl_string_dynamic_append()
+ * @see fl_string_dynamic_prepend()
+ * @see fl_string_dynamic_partial_append()
+ */
+#ifndef _di_fl_string_dynamic_partial_append_
+ extern f_return_status fl_string_dynamic_partial_prepend(const f_string_dynamic source, const f_string_location offset, f_string_dynamic *destination);
+#endif // _di_fl_string_dynamic_partial_append_
+
+/**
+ * Prepend the source string onto the destination.
+ *
+ * Prepend operations require memory move operations and are therefore likely more expensive than append operations.
+ *
+ * @param source
+ * The source string to prepend.
+ * @param destination
+ * The destination string the source is prepended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_append()
+ * @see fl_string_prepend()
+ * @see fl_string_dynamic_append()
+ * @see fl_string_dynamic_partial_append()
+ * @see fl_string_dynamic_partial_prepend()
+ */
+#ifndef _di_fl_string_dynamic_prepend_
+ extern f_return_status fl_string_dynamic_prepend(const f_string_dynamic source, f_string_dynamic *destination);
+#endif // _di_fl_string_dynamic_prepend_
+
+/**
* Allocate a new string from the provided range in the buffer.
*
* @param buffer
#endif // _di_fl_string_mash_
/**
+ * Prepend the source string onto the destination.
+ *
+ * Prepend operations require memory move operations and are therefore likely more expensive than append operations.
+ *
+ * @param source
+ * The source string to prepend.
+ * @param source_length
+ * Total number of bytes to copy from source string.
+ * @param destination
+ * The destination string the source is prepended onto.
+ *
+ * @return
+ * f_none on success.
+ * f_string_max_size (with error bit) if the combined string is too large.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ * f_error_allocation (with error bit) on memory allocation error.
+ * f_error_reallocation (with error bit) on memory reallocation error.
+ *
+ * @see fl_string_append()
+ * @see fl_string_dynamic_append()
+ * @see fl_string_dynamic_prepend()
+ * @see fl_string_dynamic_partial_append()
+ * @see fl_string_dynamic_partial_prepend()
+ */
+#ifndef _di_fl_string_prepend_
+ extern f_return_status fl_string_prepend(const f_string source, const f_string_length source_length, f_string_dynamic *destination);
+#endif // _di_fl_string_prepend_
+
+/**
* Allocate a new string from the provided range in the string.
*
* @param string