55 #if !defined(__AMXC_STRING_H__)
56 #define __AMXC_STRING_H__
71 #define AMXC_STRING_MAX SIZE_MAX
95 #define amxc_string_from_llist_it(ll_it) \
96 amxc_container_of(ll_it, amxc_string_t, it)
304 const size_t length);
335 const char*
const text,
383 const size_t offset);
566 __attribute__ ((format(printf, 2, 3)));
636 const char* fmt, ...) \
637 __attribute__ ((format(printf, 3, 4)));
684 __attribute__ ((format(printf, 2, 3)));
695 const char* fmt, va_list args);
753 const char* fmt, ...) \
754 __attribute__ ((format(printf, 3, 4)));
802 __attribute__ ((format(printf, 2, 3)));
921 const char*
const text,
922 const size_t length) {
954 const char*
const text,
955 const size_t length) {
977 return string != NULL ?
string->length : 0;
998 return string != NULL ?
string->last_used : 0;
1016 return string != NULL ? (
string->last_used == 0) :
true;
Ambiorix linked list API header file.
void amxc_string_delete(amxc_string_t **string)
Frees the previously allocated string.
const char * amxc_string_get(const amxc_string_t *const string, const size_t offset)
Gets the content of the string buffer.
int amxc_string_to_lower(amxc_string_t *const string)
Converts all upper case characters to lower case.
int amxc_string_bytes_2_hex_binary(amxc_string_t *const string, const char bytes[], const uint32_t len, const char *sep)
Creates a hexbinary string from an array of bytes.
int amxc_string_setf(amxc_string_t *const string, const char *fmt,...) __attribute__((format(printf
Sets the content of the string using printf like formatting.
AMXC_INLINE size_t amxc_string_buffer_length(const amxc_string_t *const string)
Gets the current size of the allocate string buffer.
int int amxc_string_vsetf_checked(amxc_string_t *const string, amxc_string_is_safe_cb_t is_safe_cb, const char *fmt, va_list args)
va_list version of amxc_string_setf_checked
int amxc_string_push_buffer(amxc_string_t *const string, char *buffer, size_t length)
Sets the string buffer.
int amxc_string_vsetf(amxc_string_t *const string, const char *fmt, va_list ap)
Sets the content of the string using printf like formatting.
size_t amxc_string_set(amxc_string_t *const string, const char *text)
Sets a 0 terminated string in the string buffer.
AMXC_INLINE int amxc_string_append(amxc_string_t *const string, const char *const text, const size_t length)
Appends text to the end of the current content of the string buffer.
int amxc_string_replace(amxc_string_t *const string, const char *needle, const char *newstr, uint32_t max)
Replaces a number of sub-string occurrences in a string.
char * amxc_string_dup(const amxc_string_t *const string, const size_t start, size_t length)
Creates a full or partial copy of the text in the string buffer.
_amxc_string_flags
amxc_string_set_at possible flags
void amxc_string_reset(amxc_string_t *const string)
Resets the buffer, reset the content to all 0.
int amxc_string_to_upper(amxc_string_t *const string)
Converts all lower case characters to upper case.
int amxc_string_copy(amxc_string_t *const dest, const amxc_string_t *const src)
Copies the content.
AMXC_INLINE int amxc_string_insert_at(amxc_string_t *const string, const size_t pos, const char *text, size_t length)
Inserts a string of the given length into a string at a certain position.
int amxc_string_new(amxc_string_t **string, const size_t length)
Allocates a string.
AMXC_INLINE size_t amxc_string_text_length(const amxc_string_t *const string)
Gets the current size of the used string buffer.
bool(* amxc_string_is_safe_cb_t)(const char *replacement)
Checks if given replacement is safe to be included in a bigger string in a particular language.
int amxc_string_search(const amxc_string_t *const string, const char *needle, uint32_t start_pos)
Searches a sub-string in a string.
int int amxc_string_vappendf(amxc_string_t *const string, const char *fmt, va_list ap)
Appends a formatted string to a string.
AMXC_INLINE int amxc_string_prepend(amxc_string_t *const string, const char *const text, const size_t length)
Inserts text at the beginning of the current content of the string buffer.
int int amxc_string_vappendf_checked(amxc_string_t *target_string, amxc_string_is_safe_cb_t is_safe_cb, const char *fmt, va_list args)
va_list version of amxc_string_appendf_checked
int amxc_string_appendf_checked(amxc_string_t *string, amxc_string_is_safe_cb_t is_safe_cb, const char *fmt,...) __attribute__((format(printf
Appends a formatted string while performing safety checks on the replacements.
int amxc_string_grow(amxc_string_t *const string, const size_t length)
Grows the string buffer.
int int amxc_string_vprependf(amxc_string_t *const string, const char *fmt, va_list ap)
Prepends a formatted string to a string.
int amxc_string_shrink(amxc_string_t *const string, const size_t length)
Shrinks the string buffer.
int(* amxc_string_is_char_fn_t)(int c)
Definition of the signature of the "is char" callback function.
void amxc_string_trim(amxc_string_t *const string, amxc_string_is_char_fn_t fn)
Trim.
int amxc_string_init(amxc_string_t *const string, const size_t length)
Initializes a string.
int amxc_string_setf_checked(amxc_string_t *target_string, amxc_string_is_safe_cb_t is_safe_cb, const char *fmt,...) __attribute__((format(printf
Sets the content of a string using printf like formatting while performing safety checks on the repla...
enum _amxc_string_flags amxc_string_flags_t
amxc_string_set_at possible flags
int amxc_string_appendf(amxc_string_t *const string, const char *fmt,...) __attribute__((format(printf
Appends a formatted string to a string.
int amxc_string_remove_at(amxc_string_t *const string, const size_t pos, size_t length)
Removes part of the text in the string buffer.
int amxc_string_set_at(amxc_string_t *const string, const size_t pos, const char *const text, const size_t length, const amxc_string_flags_t flags)
Set text in the string buffer at a certain position.
int amxc_string_hex_binary_2_bytes(const amxc_string_t *const string, char **bytes, uint32_t *len, const char *sep)
Creates an array of bytes from a hex binary string.
void amxc_string_triml(amxc_string_t *const string, amxc_string_is_char_fn_t fn)
Trim left.
void amxc_string_trimr(amxc_string_t *const string, amxc_string_is_char_fn_t fn)
Trim right.
int bool amxc_string_is_numeric(const amxc_string_t *const string)
Checks if a string is fully numeric.
AMXC_INLINE bool amxc_string_is_empty(const amxc_string_t *const string)
Checks if the string is empty.
int amxc_string_prependf(amxc_string_t *const string, const char *fmt,...) __attribute__((format(printf
Prepends a formatted string to a string.
struct _amxc_string amxc_string_t
The string structure.
void amxc_string_clean(amxc_string_t *const string)
Frees the string buffer and reset length attributes.
char * amxc_string_take_buffer(amxc_string_t *const string)
Takes the string buffer.
The linked list iterator structure.