String array module header file. More...
#include "string_type.h"
Go to the source code of this file.
Data Structures | |
struct | string_array_item_t |
struct | string_array_t |
Macros | |
#define | DEFAULT_INCREMENT_VALUE 5 |
Default increment value of the array. More... | |
Functions | |
E_MCL_ERROR_CODE | string_array_initialize (mcl_size_t count, string_array_t **array) |
String array initialize method. More... | |
E_MCL_ERROR_CODE | string_array_set_increment (string_array_t *array, mcl_size_t increment_value) |
Sets the increment value of the array. More... | |
E_MCL_ERROR_CODE | string_array_add (string_array_t *array, string_t *string, mcl_bool_t destroy) |
Adds an string_t string object into the array. More... | |
E_MCL_ERROR_CODE | string_array_set (string_array_t *array, mcl_size_t index, string_t *string) |
To set the string item at a specified index in the string array. More... | |
string_t * | string_array_get (string_array_t *array, mcl_size_t index) |
To get the string_t string object at a specified index. More... | |
string_t * | string_array_to_string (string_array_t *array) |
To concatenate the strings in the array. More... | |
void | string_array_destroy (string_array_t **array) |
Destroys the string array handle. More... | |
String array module header file.
Definition in file string_array.h.
#define DEFAULT_INCREMENT_VALUE 5 |
Default increment value of the array.
Incrementing the array means if during an add operation, there initialized array count is not enough to hold the additional item, array increasses it's size by this value. To override this default value string_array_set_increment() can be used.
Definition at line 28 of file string_array.h.
Referenced by string_array_add(), and string_array_initialize().
E_MCL_ERROR_CODE string_array_add | ( | string_array_t * | array, |
string_t * | string, | ||
mcl_bool_t | destroy | ||
) |
Adds an string_t string object into the array.
Caller also have to decide wheter this string object should be destroyed or not when string array is destroyed.
[in] | array | String array handle to operate. |
[in] | string | The string_t string object to be added into the array. |
[in] | destroy | Destroy flag is used to decide during string_array_destroy() operation wheter call string_destroy() for this string item or not. |
Definition at line 70 of file string_array.c.
References ASSERT_CODE_MESSAGE, string_array_t::count, DEBUG_ENTRY, DEBUG_LEAVE, DEFAULT_INCREMENT_VALUE, string_array_item_t::destroy, string_array_t::increment_value, string_array_t::index, string_array_t::items, MCL_DEBUG, MCL_FALSE, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_RESIZE, string_array_item_t::string, and string_array_t::total_length.
Referenced by _join_with_dot(), _response_header_callback(), and http_request_add_header().
void string_array_destroy | ( | string_array_t ** | array | ) |
Destroys the string array handle.
With a loop over its items, check destroy
flag of each of the items and calls string_destroy() if the flag is MCL_TRUE.
[in] | array | Address of string array handle. String array will be MCL_NULL after this operation. |
Definition at line 174 of file string_array.c.
References string_array_t::count, DEBUG_ENTRY, DEBUG_LEAVE, string_array_item_t::destroy, string_array_t::items, MCL_DEBUG, MCL_FREE, MCL_NULL, MCL_TRUE, string_array_item_t::string, and string_destroy().
Referenced by _join_with_dot(), http_client_send(), http_request_destroy(), and http_response_destroy().
string_t* string_array_get | ( | string_array_t * | array, |
mcl_size_t | index | ||
) |
To get the string_t string object at a specified index.
[in] | array | String array handle to operate. |
[in] | index | Specifes the index in the array of the reqeusted string object. Index has to be greater than 0 and smaller then array's current index. |
Definition at line 114 of file string_array.c.
References ASSERT_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, string_array_t::items, MCL_NULL, and string_array_item_t::string.
Referenced by _set_request_options(), and http_response_get_header().
E_MCL_ERROR_CODE string_array_initialize | ( | mcl_size_t | count, |
string_array_t ** | array | ||
) |
String array initialize method.
Initializes a string array handle suitable to hold count
items.
[in] | count | Initial item count that this string array will hold. This count value might be changed if it is not enough for future add operations. |
[out] | array | Initialized string array handle. |
count
is zero. Definition at line 19 of file string_array.c.
References ASSERT_CODE_MESSAGE, string_array_t::count, DEFAULT_INCREMENT_VALUE, string_array_item_t::destroy, string_array_t::increment_value, string_array_t::index, string_array_t::items, MCL_ERROR_RETURN, MCL_FALSE, MCL_FREE, MCL_INVALID_PARAMETER, MCL_MALLOC, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, string_array_item_t::string, string_array_t::total_length, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _join_with_dot(), http_client_send(), and http_request_initialize().
E_MCL_ERROR_CODE string_array_set | ( | string_array_t * | array, |
mcl_size_t | index, | ||
string_t * | string | ||
) |
To set the string item at a specified index in the string array.
[in] | array | String array hadnle to operate. |
[in] | index | Index value. It has to be greater than 0 and smaller than arrays current count value. |
[in] | string | The string_t string object to be set into the array at index . |
index
is out of bounds. E_MCL_ERROR_CODE string_array_set_increment | ( | string_array_t * | array, |
mcl_size_t | increment_value | ||
) |
Sets the increment value of the array.
Incrementing the array means if during an add operation, there initialized array count is not enough to hold the additional item, array increasses it's size by its increment value. With this function this value can be set. For its default value refer to DEFAULT_INCREMENT_VALUE.
[in] | array | String array handle to operate. |
[in] | increment_value | The increment value. Have to be greater than 0. |
increment_value
is zero. Definition at line 58 of file string_array.c.
References ASSERT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, string_array_t::increment_value, MCL_INVALID_PARAMETER, and MCL_OK.
string_t* string_array_to_string | ( | string_array_t * | array | ) |
To concatenate the strings in the array.
It collects the strings in its array and concatenates them into a final string and returns it.
[in] | array | String array handle to operate. |
Definition at line 132 of file string_array.c.
References ASSERT_MESSAGE, string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, string_array_t::index, string_array_t::items, string_t::length, MCL_DEBUG, MCL_ERROR_RETURN_POINTER, MCL_FREE, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR, MCL_OK, string_array_item_t::string, string_initialize_dynamic(), string_util_strncat(), and string_array_t::total_length.
Referenced by _join_with_dot().