String type module header file. More...
Go to the source code of this file.
Data Structures | |
struct | string_t |
Enumerations | |
enum | E_MCL_STRING_TYPE { MCL_STRING_COPY_DESTROY, MCL_STRING_NOT_COPY_DESTROY, MCL_STRING_NOT_COPY_NOT_DESTROY } |
This type defines the different kind of string behaviors during string initialization and destroy. More... | |
Functions | |
E_MCL_ERROR_CODE | string_initialize (const string_t *other, string_t **string) |
Initializes an string_t object with another one. More... | |
E_MCL_ERROR_CODE | string_initialize_new (const char *value, mcl_size_t value_length, string_t **string) |
Initializes a new string_t object with the given value and length. More... | |
E_MCL_ERROR_CODE | string_initialize_dynamic (const char *value, mcl_size_t value_length, string_t **string) |
Initializes a dynamic string_t object with the given value and length. More... | |
E_MCL_ERROR_CODE | string_initialize_static (const char *value, mcl_size_t value_length, string_t **string) |
Initializes a static string_t object with the given value and length. More... | |
E_MCL_ERROR_CODE | string_set (string_t *string, const char *value, mcl_size_t value_length) |
Sets the buffer of the string with a new value. More... | |
E_MCL_ERROR_CODE | string_compare (const string_t *string, const string_t *other) |
Compare the contents of two string_t's. More... | |
E_MCL_ERROR_CODE | string_compare_with_cstr (const string_t *string, const char *other) |
Compare the contents of string_t with a C string. More... | |
E_MCL_ERROR_CODE | string_split (string_t *string, const char token, list_t **string_list) |
Splits the string with the given char and returns the result as an list_t of string_t's. More... | |
E_MCL_ERROR_CODE | string_convert_binary_to_hex (const mcl_uint8_t *buffer, mcl_size_t buffer_size, string_t **hex_data) |
void | string_release (string_t *string) |
Clears the content of the string. And deallocates the memory. More... | |
void | string_destroy (string_t **string) |
Destroys the allocated resources of the string. More... | |
E_MCL_ERROR_CODE | string_concatenate_cstr (string_t *string, char *c_string, string_t **result) |
Concatenates two strings of type string_t into a string_t . More... | |
E_MCL_ERROR_CODE | string_concatenate (string_t *string_1, string_t *string_2, string_t **result) |
Concatenates a C string (i.e. a char array) More... | |
E_MCL_ERROR_CODE | string_replace (string_t *source, const char *old_string, const char *new_string, string_t **result) |
Replaces old_string with new_string . More... | |
Variables | |
const char * | hex_table |
String type module header file.
Definition in file string_type.h.
enum E_MCL_STRING_TYPE |
This type defines the different kind of string behaviors during string initialization and destroy.
The type of a string will be determined by which initialize function has called for it.
Definition at line 33 of file string_type.h.
E_MCL_ERROR_CODE string_compare | ( | const string_t * | string, |
const string_t * | other | ||
) |
Compare the contents of two string_t's.
[in] | string | String handler to compare. |
[in] | other | Other string handler to compare. |
Definition at line 129 of file string_type.c.
References string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, and string_compare_with_cstr().
Referenced by _add_item_meta_payload_details(), and http_request_add_header().
E_MCL_ERROR_CODE string_compare_with_cstr | ( | const string_t * | string, |
const char * | other | ||
) |
Compare the contents of string_t with a C string.
[in] | string | String handler to compare. |
[in] | other | Zero terminating C string to compare. |
Definition at line 139 of file string_type.c.
References string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, string_t::length, MCL_DEBUG, MCL_FAIL, MCL_NULL, MCL_OK, string_util_strlen(), and string_util_strncmp().
Referenced by _compare_item_meta_of_event(), http_processor_update_security_information(), mcl_store_new_event(), and string_compare().
E_MCL_ERROR_CODE string_concatenate | ( | string_t * | string_1, |
string_t * | string_2, | ||
string_t ** | result | ||
) |
Concatenates a C string (i.e. a char array)
[in] | string_1 | String to which the string_2 will be concatenated. |
[in] | string_2 | String which will be concatenated to string_1 . |
[out] | result | The string that is result of the concatenation. |
Definition at line 416 of file string_type.c.
References ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, string_t::length, MCL_FAIL, MCL_NULL, MCL_OK, string_destroy(), string_initialize_new(), string_util_snprintf(), VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _add_authentication_header_to_request(), and _compose_access_token_request_payload().
E_MCL_ERROR_CODE string_concatenate_cstr | ( | string_t * | string, |
char * | c_string, | ||
string_t ** | result | ||
) |
Concatenates two strings of type string_t
into a string_t
.
[in] | string | String to which the cstring will be concatenated. |
[in] | c_string | Char array which will be concatenated to string . |
[out] | result | The string that is result of the concatenation. |
Definition at line 465 of file string_type.c.
References ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, MCL_NULL, MCL_OK, string_destroy(), string_initialize_new(), string_util_snprintf(), string_util_strlen(), VERBOSE_ENTRY, and VERBOSE_LEAVE.
E_MCL_ERROR_CODE string_convert_binary_to_hex | ( | const mcl_uint8_t * | buffer, |
mcl_size_t | buffer_size, | ||
string_t ** | hex_data | ||
) |
Converts given buffer to its hex representation as string. Allocates a new memory for resulting string with the size of
. The returned string is zero terminated.
[in] | buffer | The buffer which contains data to be converted. |
[in] | buffer_size | The length of the buffer . |
[out] | hex_data | The newly allocated string which contains conversion result and which is zero terminated. |
Definition at line 272 of file string_type.c.
References ASSERT_CODE_MESSAGE, hex_table, MCL_CALLOC, MCL_NULL, MCL_NULL_CHAR, MCL_OK, MCL_OUT_OF_MEMORY, string_initialize_new(), VERBOSE_ENTRY, and VERBOSE_LEAVE.
void string_destroy | ( | string_t ** | string | ) |
Destroys the allocated resources of the string.
After destroy operation, string handler shouldn't be used.
[in] | string | Address of the string handler to destroy. It's value will be set to MCL_NULL after destroying. |
Definition at line 326 of file string_type.c.
References MCL_FREE, MCL_NULL, string_release(), VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _add_authentication_header_to_request(), _compose_access_token_request_payload(), _concatenate_host_and_endpoint(), _create_self_issued_jwt_payload(), _destroy_data_point(), _destroy_data_source(), _destroy_value_set(), _destroy_value_set_value(), _exchange_prepare_data(), _generate_correlation_id_string(), _generate_random_boundary(), _generate_token(), _get_header_and_payload_encoded_base64_url(), _join_with_dot(), _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), _response_header_callback(), _store_list_destroy_callback(), custom_data_destroy(), data_source_configuration_destroy(), event_destroy(), event_list_destroy(), file_destroy(), http_client_initialize(), http_processor_destroy(), http_processor_exchange(), http_processor_get_access_token(), http_processor_register(), http_processor_stream(), http_processor_update_security_information(), http_request_add_header(), http_request_add_tuple(), http_request_destroy(), http_response_get_header(), jwt_get_token(), mcl_communication_destroy(), mcl_communication_process(), mcl_event_set_option(), security_handler_destroy(), storage_load_rsa_registration_information(), storage_load_shared_secret_registration_information(), string_array_destroy(), string_concatenate(), string_concatenate_cstr(), string_split(), time_series_destroy(), and time_util_convert_to_iso_8601_format().
E_MCL_ERROR_CODE string_initialize | ( | const string_t * | other, |
string_t ** | string | ||
) |
Initializes an string_t object with another one.
The content of the buffer of the other
string will be copied into the new string's buffer. The type of the string will be MCL_STRING_COPY_DESTROY.
[in] | other | Other string_t object to initialize from. |
[out] | string | Will point to the initialized string_t object. |
Definition at line 24 of file string_type.c.
References _initialize(), ASSERT_CODE_MESSAGE, string_t::buffer, string_t::length, MCL_ERROR, MCL_FREE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_STRING_COPY_DESTROY, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by http_request_initialize(), http_response_get_header(), and mcl_data_source_configuration_get_id().
E_MCL_ERROR_CODE string_initialize_dynamic | ( | const char * | value, |
mcl_size_t | value_length, | ||
string_t ** | string | ||
) |
Initializes a dynamic string_t object with the given value and length.
A Dynamic string means that it will not allocate any memory space for its buffer. Its buffer will point to the address of the initial value
but it frees the buffer when string_destroy() is called.
This is good for usage like this :
If received length is zero, length of the string will be calculated.
value
must be a zero-terminated C string.[in] | value | The content to initialize the string with. If it is not NULL it will be copied into the buffer of the string. If it is NULL, an empty string with NULL buffer will be created. |
[in] | value_length | The length of the value . If this length is non zero it will be accepted as the correct length of the string. If the length is not known can be passed as zero and initialize function will calculate the length itself. |
[out] | string | Will point to the initialized string_t object. |
Definition at line 68 of file string_type.c.
References _initialize(), ASSERT_CODE_MESSAGE, MCL_ERROR, MCL_FREE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_STRING_NOT_COPY_DESTROY, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _compose_rsa_key_rotation_json(), _compose_rsa_onboarding_json(), _custom_load_register_info(), _encode_with_table(), _process_registration_response_rsa_3072(), http_processor_update_security_information(), json_from_data_source_configuration_payload(), json_from_event_payload(), json_from_item_meta(), json_from_time_series_payload(), jwt_get_token(), random_generate_guid(), string_array_to_string(), and string_replace().
E_MCL_ERROR_CODE string_initialize_new | ( | const char * | value, |
mcl_size_t | value_length, | ||
string_t ** | string | ||
) |
Initializes a new string_t object with the given value and length.
A New string means that it will copy the content of value into its buffer and frees the buffer when string_destroy() is called. If received length is zero, length of the string will be calculated.
This is good for usage like this :
value
must be a zero-terminated C string.[in] | value | The content to initialize the string with. If it is not NULL it will be copied into the buffer of the string. If it is NULL, an empty string with NULL buffer will be created. |
[in] | value_length | The length of the value . If this length is non zero it will be accepted as the correct length of the string. If the length is not known can be passed as zero and initialize function will calculate the length itself. |
[out] | string | Will point to the initialized string_t object. |
Definition at line 46 of file string_type.c.
References _initialize(), ASSERT_CODE_MESSAGE, MCL_ERROR, MCL_FREE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_STRING_COPY_DESTROY, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _concatenate_host_and_endpoint(), _generate_correlation_id_string(), _generate_random_boundary(), _initialize_custom_data_meta_fields(), _initialize_meta(), _process_registration_response_rsa_3072(), _response_header_callback(), event_initialize(), file_initialize(), http_client_initialize(), http_processor_register(), http_request_add_header(), json_util_get_string(), mcl_communication_initialize(), mcl_communication_process(), mcl_data_source_configuration_add_data_point(), mcl_data_source_configuration_add_data_source(), mcl_event_set_option(), mcl_time_series_add_value(), mcl_time_series_new_value_set(), storage_load_rsa_registration_information(), storage_load_shared_secret_registration_information(), string_concatenate(), string_concatenate_cstr(), string_convert_binary_to_hex(), string_split(), and time_util_convert_to_iso_8601_format().
E_MCL_ERROR_CODE string_initialize_static | ( | const char * | value, |
mcl_size_t | value_length, | ||
string_t ** | string | ||
) |
Initializes a static string_t object with the given value and length.
A Static string means that it will not allocate any memory space for its buffer. Its buffer will point to the address of the initial value
and also it will not free the buffer when string_destroy() is called. If received length is zero, length of the string will be calculated.
This is good for usage like this :
value
must be a zero-terminated C string.[in] | value | The content to initialize the string with. If it is not NULL it will be copied into the buffer of the string. If it is NULL, an empty string with NULL buffer will be created. |
[in] | value_length | The length of the value . If this length is non zero it will be accepted as the correct length of the string. If the length is not known can be passed as zero and initialize function will calculate the length itself. |
[out] | string | Will point to the initialized string_t object. |
Definition at line 90 of file string_type.c.
References _initialize(), ASSERT_CODE_MESSAGE, MCL_ERROR, MCL_FREE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_STRING_NOT_COPY_NOT_DESTROY, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _add_authentication_header_to_request(), _compose_access_token_request_payload(), _initialize_custom_data_meta_fields(), _initialize_meta(), file_initialize(), and http_processor_get_access_token().
void string_release | ( | string_t * | string | ) |
Clears the content of the string. And deallocates the memory.
Clears the content of the string, sets the buffer to MCL_NULL and the length to zero.
[in] | string | String to be released. |
Definition at line 298 of file string_type.c.
References string_t::buffer, MCL_FREE, MCL_NULL, MCL_STRING_COPY_DESTROY, MCL_STRING_NOT_COPY_DESTROY, MCL_VERBOSE, string_t::type, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by string_destroy(), and string_set().
E_MCL_ERROR_CODE string_replace | ( | string_t * | source, |
const char * | old_string, | ||
const char * | new_string, | ||
string_t ** | result | ||
) |
Replaces old_string
with new_string
.
[in] | source | The string in which the replacement will be done. |
[in] | old_string | Part of source that will be replaced. |
[in] | new_string | New string which will be replaced with old_string . |
[out] | result | String that is created as result of the replacement. |
Definition at line 433 of file string_type.c.
References ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, string_t::length, MCL_CALLOC, MCL_FAIL, MCL_FREE, MCL_NULL, MCL_OUT_OF_MEMORY, MCL_TRUE, string_initialize_dynamic(), string_util_find(), string_util_strlen(), string_util_strncat(), VERBOSE_ENTRY, and VERBOSE_LEAVE.
E_MCL_ERROR_CODE string_set | ( | string_t * | string, |
const char * | value, | ||
mcl_size_t | value_length | ||
) |
Sets the buffer of the string with a new value.
First string_release() is called and the buffer is released with or without freeing it depending on the string type. Then buffer assigned to the new value again either by copying or by referencing depending on string type. String type and behavior will not be changed with this function.
[in] | string | String handle to be set. |
[in] | value | The new value to be set to the string. This must be a zero terminated C string. |
[in] | value_length | If value length is known, by passing it with this parameter would reduce operation cost by avoiding to calculate it again. If this parameter is given as 0, string_set will calculate the length. |
Definition at line 112 of file string_type.c.
References _initialize(), ASSERT_CODE_MESSAGE, MCL_OK, string_release(), VERBOSE_ENTRY, and VERBOSE_LEAVE.
E_MCL_ERROR_CODE string_split | ( | string_t * | string, |
const char | token, | ||
list_t ** | string_list | ||
) |
Splits the string with the given char and returns the result as an list_t of string_t's.
[in] | string | String handler to split. |
[in] | token | Char value to split the string. |
[out] | string_list | The prepared list containing the splitted strings. |
string_list
has no space for an additional split. Definition at line 179 of file string_type.c.
References ASSERT_CODE_MESSAGE, string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, list_add(), list_destroy_with_content(), list_initialize(), MCL_DEBUG, MCL_ERROR, MCL_NULL, MCL_NULL_CHAR, MCL_OK, string_destroy(), and string_initialize_new().
Referenced by http_response_get_header().
const char* hex_table |
Definition at line 19 of file string_type.c.
Referenced by string_convert_binary_to_hex().