dynamiC
0.1
|
Definition of C string manipulation functions. More...
#include "dynamic_string.h"
Go to the source code of this file.
Macros | |
#define | FLOAT_DIGITS 100000. |
Functions | |
dyn_ushort | dyn_strlen (dyn_const_str str) |
Returns the length of an string. More... | |
void | dyn_strcat (dyn_str destination, dyn_const_str source) |
Concatenate strings. More... | |
void | dyn_strcat2 (dyn_str destination, dyn_const_str source) |
Concatenate strings, required memory is automatically allocated. More... | |
void | dyn_strcpy (dyn_str destination, dyn_const_str source) |
Copy string. More... | |
dyn_ushort | dyn_itoa_len (dyn_int i) |
Calculates the number of required characters for integer to string (decimal) conversion, minus increases the value by one. More... | |
void | dyn_itoa (dyn_str str, dyn_int i) |
Integer to ASCII-string conversion. More... | |
dyn_ushort | dyn_ftoa_len (const dyn_float f) |
Calculates the number of required characters for float to string (decimal) conversion, minus increases the value by one. More... | |
void | dyn_ftoa (dyn_str str, const dyn_float f) |
Float to ASCII-string conversion (decimal). More... | |
dyn_char | dyn_strcmp (dyn_const_str a, dyn_const_str b) |
Compares the string a to the string b. More... | |
Definition of C string manipulation functions.
This project is released under the MIT-License.
Definition in file dynamic_string.c.
Float to ASCII-string conversion (decimal).
The length of the character-array has to be sufficient, it can be calculated previously with function dyn_ftoa_len.
[out] | str | character array with with new ASCII representation of f |
[in] | f | float value to convert |
Definition at line 185 of file dynamic_string.c.
Referenced by dyn_get_bool().
dyn_ushort dyn_ftoa_len | ( | const dyn_float | f | ) |
Calculates the number of required characters for float to string (decimal) conversion, minus increases the value by one.
f | float value to check |
Definition at line 162 of file dynamic_string.c.
Referenced by dyn_get_bool().
Integer to ASCII-string conversion.
The length of the character array has to have a sufficient length, it can be calculated previously with function dyn_itoa_len "(" str ")"
[out] | str | character array with ASCII representation of i |
[in] | i | integer value to convert |
Definition at line 140 of file dynamic_string.c.
Referenced by dyn_get_bool().
dyn_ushort dyn_itoa_len | ( | dyn_int | i | ) |
Calculates the number of required characters for integer to string (decimal) conversion, minus increases the value by one.
Examples:
i | integer value to convert |
Definition at line 114 of file dynamic_string.c.
Referenced by dyn_get_bool(), and dyn_itoa().
void dyn_strcat | ( | dyn_str | destination, |
dyn_const_str | source | ||
) |
Concatenate strings.
Appends a copy of the source string to the destination string. The terminating null character in destination is overwritten by the first character of source, and a null-character is included at the end of the new string formed by the concatenation of both in destination.
destination and source shall not overlap and the length of destination must be sufficient for concatenation, otherwise use dyn_strcat2.
destination | Pointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string. |
source | C string to be appended. This should not overlap destination. |
Definition at line 54 of file dynamic_string.c.
Referenced by dyn_dict_string_add(), dyn_get_bool(), dyn_list_string_add(), and dyn_strcat2().
void dyn_strcat2 | ( | dyn_str | destination, |
dyn_const_str | source | ||
) |
Concatenate strings, required memory is automatically allocated.
Appends a copy of the source string to the destination string and adds automatically required memory. The terminating null character in destination
is overwritten by the first character of source, and a null-character is included at the end of the new string formed by the concatenation of both in destination.
destination and source shall not overlap.
destination | Pointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string. |
source | C string to be appended. This should not overlap destination. |
Definition at line 76 of file dynamic_string.c.
dyn_char dyn_strcmp | ( | dyn_const_str | a, |
dyn_const_str | b | ||
) |
Compares the string a to the string b.
This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminating '\0' is reached.
a | char array to be compared |
b | char array to be compared |
<0 | the first character that does not match has a lower value in a than in b |
0 | the contents of both strings are equal |
>0 | the first character that does not match has a greater value in a than in b |
Definition at line 212 of file dynamic_string.c.
Referenced by dyn_dict_has_key().
void dyn_strcpy | ( | dyn_str | destination, |
dyn_const_str | source | ||
) |
Copy string.
Copies the C string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point).
To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C string as source (including the terminating null character), and should not overlap in memory with source.
[out] | destination | Pointer to the destination array where the content is to be copied. |
[in] | source | C string to be copied. |
Definition at line 94 of file dynamic_string.c.
Referenced by dyn_set_string(), and dyn_strcat().
dyn_ushort dyn_strlen | ( | dyn_const_str | str | ) |
Returns the length of an string.
Iteratates through an character array to sum up its length, the end is defined by the character '\0'.
str | Pointer to an character array |
Definition at line 27 of file dynamic_string.c.
Referenced by dyn_dict_string_add(), dyn_dict_string_len(), dyn_get_bool(), dyn_list_string_add(), dyn_set_string(), dyn_size(), dyn_strcat(), and dyn_strcat2().