#include <commons/string.h>
Más...
Ir al código fuente de este archivo.
Funciones | |
| char * | string_new (void) |
| Crea un string vacio. | |
| char * | string_itoa (int number) |
| Crea un string en formato decimal a partir de un número. | |
| char * | string_from_format (const char *format,...) |
| Crea un nuevo string a partir de un formato especificado. | |
| char * | string_from_vformat (const char *format, va_list arguments) |
Crea un nuevo string a partir de un formato especificado pasando un va_list con los argumentos. | |
| char * | string_repeat (char ch, int count) |
Crea un string de longitud count con el mismo caracter. | |
| void | string_append (char **original, char *string_to_add) |
| Agrega al primer string el segundo. | |
| void | string_n_append (char **original, char *string_to_add, int n) |
| Agrega al primer string un máximo de n caracteres del segundo. | |
| void | string_append_with_format (char **original, const char *format,...) |
| Concatena al primer string el resultado de aplicar los parametros al formato especificado. | |
| char * | string_duplicate (char *original) |
| Retorna una copia del string pasado como argumento. | |
| void | string_to_upper (char *text) |
| Pone en mayuscula todos los caracteres de un string. | |
| void | string_to_lower (char *text) |
| Pone en minuscula todos los caracteres de un string. | |
| void | string_capitalized (char *text) |
| Capitaliza un string. | |
| void | string_trim (char **text) |
| Remueve todos los caracteres vacios de la derecha y la izquierda. | |
| void | string_trim_left (char **text) |
| Remueve todos los caracteres vacios de la izquierda. | |
| void | string_trim_right (char **text) |
| Remueve todos los caracteres vacios de la derecha. | |
| int | string_length (char *text) |
| Retorna la longitud del string. | |
| bool | string_is_empty (char *text) |
| Retorna si un string es "". | |
| bool | string_starts_with (char *text, char *begin) |
Retorna un boolean que indica si el string text comienza con el string begin pasado por parametro. | |
| bool | string_ends_with (char *text, char *end) |
Retorna un boolean que indica si el string text finaliza con el string end pasado por parametro. | |
| bool | string_equals_ignore_case (char *actual, char *expected) |
| Retorna si dos strings son iguales ignorando las mayusculas y minusculas. | |
| char ** | string_split (char *text, char *separator) |
| Separa un string dado un separador. | |
| char ** | string_n_split (char *text, int n, char *separator) |
| Separa un string tantas veces por su separador como n lo permita. | |
| char * | string_substring (char *text, int start, int length) |
| Retorna los length caracteres de text empezando en start en un nuevo string. | |
| char * | string_substring_from (char *text, int start) |
| Retorna el substring de text desde el indice start hasta el último de la palabra. | |
| char * | string_substring_until (char *text, int length) |
| Retorna los primeros length caracteres de text como un nuevo string. | |
| void | string_iterate_lines (char **strings, void(*closure)(char *)) |
| Itera un array de strings y aplica la función closure a cada uno. | |
| char ** | string_get_string_as_array (char *text) |
| Retorna un array de strings a partir de un string formateado como array. | |
| char * | string_reverse (char *text) |
| Retorna el texto invertido. No se maneja el caso de NULL, si se pasa NULL su comportamiento no esta determinado. | |
| char * | string_replace (char *text, char *substring, char *replacement) |
| Retorna una copia de un string con todas las ocurrencias de un substring no vacío siendo reemplazadas por otro string. | |
| bool | string_contains (char *text, char *substring) |
| Retorna un boolean que indica si text contiene o no a substring. | |
| char ** | string_array_new (void) |
| Crea un array de strings vacio. | |
| void | string_array_destroy (char **array) |
| Destruye un array con sus strings. | |
| int | string_array_size (char **array) |
| Retorna la cantidad de líneas del array de strings. | |
| bool | string_array_is_empty (char **array) |
| Verifica si el array de strings está vacío. | |
| void | string_array_push (char ***array, char *text) |
| Agrega un string al final del array. | |
| char * | string_array_replace (char **array, int pos, char *text) |
| Reemplaza un string en un array por otro. | |
| char * | string_array_pop (char **array) |
| Quita el último string del array y lo retorna. | |
#include <commons/string.h>
| char * string_new | ( | void | ) |
Crea un string vacio.
free() | char * string_itoa | ( | int | number | ) |
Crea un string en formato decimal a partir de un número.
| [in] | number | Número entero a convertir |
free()| char * string_from_format | ( | const char * | format, |
| ... | |||
| ) |
Crea un nuevo string a partir de un formato especificado.
| [in] | format | Formato a aplicar, igual que en printf() |
free()| char * string_from_vformat | ( | const char * | format, |
| va_list | arguments | ||
| ) |
Crea un nuevo string a partir de un formato especificado pasando un va_list con los argumentos.
| [in] | format | Formato a aplicar, igual que en vprintf() |
| [in] | arguments | Lista de argumentos a aplicar, igual que en vprintf() |
free() | char * string_repeat | ( | char | ch, |
| int | count | ||
| ) |
Crea un string de longitud count con el mismo caracter.
| [in] | ch | Caracter a repetir |
| [in] | count | Cantidad de veces a repetir el caracter |
free()| void string_append | ( | char ** | original, |
| char * | string_to_add | ||
| ) |
Agrega al primer string el segundo.
| [in,out] | original | Puntero al string al que se le va a concatenar el segundo. Debe apuntar a un puntero liberable con free() |
| [in] | string_to_add | String a concatenar. Admite todo tipo de strings |
| void string_n_append | ( | char ** | original, |
| char * | string_to_add, | ||
| int | n | ||
| ) |
Agrega al primer string un máximo de n caracteres del segundo.
| [in,out] | original | Puntero al string a modificar. Debe apuntar a un string liberable con free() |
| [in] | string_to_add | String a concatenar. Admite todo tipo de strings |
| [in] | n | Cantidad máxima de caracteres a concatenar |
| void string_append_with_format | ( | char ** | original, |
| const char * | format, | ||
| ... | |||
| ) |
Concatena al primer string el resultado de aplicar los parametros al formato especificado.
| [in,out] | original | Puntero al string a modificar. Debe apuntar a un string liberable con free() |
| [in] | format | Formato a aplicar, igual que en printf() |
| char * string_duplicate | ( | char * | original | ) |
Retorna una copia del string pasado como argumento.
| [in] | original | String a duplicar. Admite todo tipo de strings |
free()| void string_to_upper | ( | char * | text | ) |
Pone en mayuscula todos los caracteres de un string.
| [in,out] | text | String a modificar. Debe apuntar a cualquier porción de memoria modificable (en el stack o en el heap) |
| void string_to_lower | ( | char * | text | ) |
Pone en minuscula todos los caracteres de un string.
| [in,out] | text | String a modificar. Debe apuntar a cualquier porción de memoria modificable (en el stack o en el heap) |
| void string_capitalized | ( | char * | text | ) |
Capitaliza un string.
| [in,out] | text | String a modificar. Debe apuntar a cualquier porción de memoria modificable (en el stack o en el heap) |
| void string_trim | ( | char ** | text | ) |
Remueve todos los caracteres vacios de la derecha y la izquierda.
| [in,out] | text | Puntero al string a modificar. Debe apuntar a un string liberable con free() |
| void string_trim_left | ( | char ** | text | ) |
Remueve todos los caracteres vacios de la izquierda.
| [in,out] | text | Puntero al string a modificar. Debe apuntar a un string liberable con free() |
| void string_trim_right | ( | char ** | text | ) |
Remueve todos los caracteres vacios de la derecha.
| [in,out] | text | Puntero al string a modificar. Debe apuntar a un string liberable con free() |
| int string_length | ( | char * | text | ) |
Retorna la longitud del string.
| [in] | text | String a medir. Admite todo tipo de strings |
| bool string_is_empty | ( | char * | text | ) |
Retorna si un string es "".
| [in] | text | String a evaluar. Admite todo tipo de strings |
| bool string_starts_with | ( | char * | text, |
| char * | begin | ||
| ) |
Retorna un boolean que indica si el string text comienza con el string begin pasado por parametro.
| [in] | text | String a evaluar. Admite todo tipo de strings |
| [in] | begin | String a buscar. Admite todo tipo de strings |
| bool string_ends_with | ( | char * | text, |
| char * | end | ||
| ) |
Retorna un boolean que indica si el string text finaliza con el string end pasado por parametro.
| [in] | text | String a evaluar. Admite todo tipo de strings |
| [in] | end | String a buscar. Admite todo tipo de strings |
| bool string_equals_ignore_case | ( | char * | actual, |
| char * | expected | ||
| ) |
Retorna si dos strings son iguales ignorando las mayusculas y minusculas.
| [in] | actual | String a comparar. Admite todo tipo de strings |
| [in] | expected | String a comparar. Admite todo tipo de strings |
| char ** string_split | ( | char * | text, |
| char * | separator | ||
| ) |
Separa un string dado un separador.
| [in] | text | String a separar. Admite todo tipo de strings |
| [in] | separator | Separador a utilizar. Admite todo tipo de strings |
string_array_destroy()| char ** string_n_split | ( | char * | text, |
| int | n, | ||
| char * | separator | ||
| ) |
Separa un string tantas veces por su separador como n lo permita.
| [in] | text | String a separar. Admite todo tipo de strings |
| [in] | n | Cantidad máxima de veces que se puede separar |
| [in] | separator | String separador a utilizar. Admite todo tipo de strings |
string_array_destroy()| char * string_substring | ( | char * | text, |
| int | start, | ||
| int | length | ||
| ) |
Retorna los length caracteres de text empezando en start en un nuevo string.
| [in] | text | String a partir del cual se obtiene el substring. Admite todo tipo de strings |
| [in] | start | Indice desde el cual se obtiene el substring |
| [in] | length | Cantidad de caracteres a obtener |
free()| char * string_substring_from | ( | char * | text, |
| int | start | ||
| ) |
Retorna el substring de text desde el indice start hasta el último de la palabra.
| [in] | text | String a partir del cual se obtiene el substring. Admite todo tipo de strings |
| [in] | start | Indice desde el cual se obtiene el substring |
free() | char * string_substring_until | ( | char * | text, |
| int | length | ||
| ) |
Retorna los primeros length caracteres de text como un nuevo string.
| [in] | text | String a partir del cual se obtiene el substring. Admite todo tipo de strings |
| [in] | length | Cantidad de caracteres a obtener |
free() | void string_iterate_lines | ( | char ** | strings, |
| void(*)(char *) | closure | ||
| ) |
Itera un array de strings y aplica la función closure a cada uno.
| [in] | strings | Array de strings a iterar |
| [in] | closure | Función a aplicar a cada string |
| char ** string_get_string_as_array | ( | char * | text | ) |
Retorna un array de strings a partir de un string formateado como array.
| [in] | text | String a convertir. Admite todo tipo de strings |
string_array_destroy()| char * string_reverse | ( | char * | text | ) |
Retorna el texto invertido. No se maneja el caso de NULL, si se pasa NULL su comportamiento no esta determinado.
| [in] | text | String a invertir. Admite todo tipo de strings |
free()| char * string_replace | ( | char * | text, |
| char * | substring, | ||
| char * | replacement | ||
| ) |
Retorna una copia de un string con todas las ocurrencias de un substring no vacío siendo reemplazadas por otro string.
| [in] | text | String a modificar. Admite todo tipo de strings |
| [in] | substring | Substring a reemplazar. Admite todo tipo de strings |
| [in] | replacement | String a insertar. Admite todo tipo de strings |
free()| bool string_contains | ( | char * | text, |
| char * | substring | ||
| ) |
Retorna un boolean que indica si text contiene o no a substring.
| [in] | text | String a evaluar. Admite todo tipo de strings |
| [in] | substring | Substring a buscar. Admite todo tipo de strings |
| char ** string_array_new | ( | void | ) |
Crea un array de strings vacio.
string_array_destroy() | void string_array_destroy | ( | char ** | array | ) |
Destruye un array con sus strings.
| [in,out] | array | Puntero al array a destruir. Debe apuntar a un array de strings liberables con free() y terminado en NULL |
| int string_array_size | ( | char ** | array | ) |
Retorna la cantidad de líneas del array de strings.
| [in] | array | Array de strings terminado en NULL |
| bool string_array_is_empty | ( | char ** | array | ) |
Verifica si el array de strings está vacío.
| [in] | array | Array de strings terminado en NULL |
| void string_array_push | ( | char *** | array, |
| char * | text | ||
| ) |
Agrega un string al final del array.
| [in,out] | array | Puntero al array a modificar. Debe apuntar a un array de strings modificable y terminado en NULL |
| [in] | text | String a agregar. Debe ser liberable con free(), pero pasa a formar parte del array, por lo que no debe ser liberado |
| char * string_array_replace | ( | char ** | array, |
| int | pos, | ||
| char * | text | ||
| ) |
Reemplaza un string en un array por otro.
| [in,out] | array | Array a modificar. Debe apuntar a un array de strings terminado en NULL |
| [in] | pos | Posición del string a reemplazar |
| [in] | text | Nuevo string a insertar. Debe ser liberable con free(), pero pasa a formar parte del array, por lo que no debe ser liberado |
free() | char * string_array_pop | ( | char ** | array | ) |
Quita el último string del array y lo retorna.
| [in,out] | array | Array a modificar. Debe apuntar a un array de strings terminado en NULL |
free()