Dynamic string functions. More...
Functions | |
| TRIO_PUBLIC_STRING trio_string_t * | trio_string_create (int initial_size) |
| Create a new dynamic string. More... | |
| TRIO_PUBLIC_STRING void | trio_string_destroy (trio_string_t *self) |
| Deallocate the dynamic string and its contents. More... | |
| TRIO_PUBLIC_STRING char * | trio_string_get (trio_string_t *self, int offset) |
| Get a pointer to the content. More... | |
| TRIO_PUBLIC_STRING char * | trio_string_extract (trio_string_t *self) |
| Extract the content. More... | |
| TRIO_PUBLIC_STRING void | trio_xstring_set (trio_string_t *self, char *buffer) |
| Set the content of the dynamic string. More... | |
| TRIO_PUBLIC_STRING int | trio_string_append (trio_string_t *self, trio_string_t *other) |
| Append the second string to the first. More... | |
| TRIO_PUBLIC_STRING int | trio_string_contains (trio_string_t *self, trio_string_t *other) |
| Search for the first occurrence of second parameter in the first. More... | |
Dynamic string functions.
SYNOPSIS
cc ... -ltrio -lm #include <triostr.h>
DESCRIPTION
| TRIO_PUBLIC_STRING int trio_string_append | ( | trio_string_t * | self, |
| trio_string_t * | other | ||
| ) |
Append the second string to the first.
| self | Dynamic string to be modified. |
| other | Dynamic string to copy from. |
References trio_copy().
| TRIO_PUBLIC_STRING int trio_string_contains | ( | trio_string_t * | self, |
| trio_string_t * | other | ||
| ) |
Search for the first occurrence of second parameter in the first.
| self | Dynamic string to be modified. |
| other | Dynamic string to copy from. |
References trio_contains().
| TRIO_PUBLIC_STRING trio_string_t* trio_string_create | ( | int | initial_size | ) |
Create a new dynamic string.
| initial_size | Initial size of the buffer. |
References trio_string_destroy().
| TRIO_PUBLIC_STRING void trio_string_destroy | ( | trio_string_t * | self | ) |
Deallocate the dynamic string and its contents.
| self | Dynamic string |
References trio_destroy().
Referenced by trio_asprintf(), trio_asprintfv(), trio_string_create(), and trio_vasprintf().
| TRIO_PUBLIC_STRING char* trio_string_extract | ( | trio_string_t * | self | ) |
Extract the content.
| self | Dynamic String |
The content is removed from the dynamic string. This enables destruction of the dynamic string without deallocation of the content.
Referenced by trio_asprintf(), trio_asprintfv(), and trio_vasprintf().
| TRIO_PUBLIC_STRING char* trio_string_get | ( | trio_string_t * | self, |
| int | offset | ||
| ) |
Get a pointer to the content.
| self | Dynamic string. |
| offset | Offset into content. |
Offset can be zero, positive, or negative. If offset is zero, then the start of the content will be returned. If offset is positive, then a pointer to offset number of characters from the beginning of the content is returned. If offset is negative, then a pointer to offset number of characters from the ending of the string, starting at the terminating zero, is returned.
| TRIO_PUBLIC_STRING void trio_xstring_set | ( | trio_string_t * | self, |
| char * | buffer | ||
| ) |
Set the content of the dynamic string.
| self | Dynamic String |
| buffer | The new content. |
Sets the content of the dynamic string to a copy buffer. An existing content will be deallocated first, if necessary.
buffer. You are responsible for deallocating buffer yourself. References trio_destroy(), and trio_duplicate().