sgdk
|
String manipulations. More...
Go to the source code of this file.
Defines | |
#define | _STRING_H_ |
#define | isdigit(c) ((c) >= '0' && (c) <= '9') |
Test if specified character is a digit or not. | |
#define | va_start(v, l) __builtin_va_start(v,l) |
#define | va_end(v) __builtin_va_end(v) |
#define | va_arg(v, l) __builtin_va_arg(v,l) |
Typedefs | |
typedef void * | __gnuc_va_list |
typedef __gnuc_va_list | va_list |
Functions | |
u16 | strlen (const char *str) |
Calculate the length of a string (limited to 65535 characters maximum). | |
u16 | strnlen (const char *str, u16 maxlen) |
Compute the length of a string, to a maximum number of bytes. | |
s16 | strcmp (const char *str1, const char *str2) |
Compare the 2 strings. | |
char * | strcpy (char *dest, const char *src) |
Copy a string. | |
char * | strncpy (char *dest, const char *src, u16 len) |
Copy the first 'len' character of string. | |
char * | strcat (char *dest, const char *src) |
Concatenate two strings. | |
u16 | sprintf (char *buffer, const char *fmt,...) __attribute__((format(printf |
Composes a string with the same text that would be printed if format was used on printf, but instead of being printed, the content is stored as a C string in the buffer pointed by str. | |
u16 char * | strclr (char *str) |
Clear a string. | |
char * | strreplacechar (char *str, char oldc, char newc) |
Replace the given character in a string. | |
u16 | intToStr (s32 value, char *str, u16 minsize) |
Convert a s32 value to string (input value should be in [-500000000..500000000] range). | |
u16 | uintToStr (u32 value, char *str, u16 minsize) |
Convert a u32 value to string (input value should be in [0..500000000] range). | |
u16 | intToHex (u32 value, char *str, u16 minsize) |
Convert a u32 value to hexadecimal string. | |
void | fix32ToStr (fix32 value, char *str, u16 numdec) |
Convert a fix32 value to string. | |
void | fix16ToStr (fix16 value, char *str, u16 numdec) |
Convert a fix16 value to string. |
String manipulations.
This unit provides basic null terminated string operations and type conversions.
Convert a fix16 value to string.
value | The fix16 value to convert to string. |
str | Destination string (it must be large enough to receive result). |
numdec | Number of wanted decimal. |
Converts the specified fix16 value to string.
Convert a fix32 value to string.
value | The fix32 value to convert to string. |
str | Destination string (it must be large enough to receive result). |
numdec | Number of wanted decimal. |
Converts the specified fix32 value to string.
Convert a u32 value to hexadecimal string.
value | The u32 integer value to convert to hexadecimal string. |
str | Destination string (it must be large enough to receive result). |
minsize | Minimum size of resulting string. |
Converts the specified u32 value to hexadecimal string.
If resulting value is shorter than requested minsize the method prepends result with '0' character.
Convert a s32 value to string (input value should be in [-500000000..500000000] range).
value | The s32 integer value to convert to string (input value should be in [-500000000..500000000] range). |
str | Destination string (it must be large enough to receive result). |
minsize | Minimum size of resulting string. |
Converts the specified s32 value to string.
If resulting value is shorter than requested minsize the method prepends result with '0' character.
u16 sprintf | ( | char * | buffer, |
const char * | fmt, | ||
... | |||
) |
Composes a string with the same text that would be printed if format was used on printf, but instead of being printed, the content is stored as a C string in the buffer pointed by str.
buffer | Destination string (it must be large enough to receive result). |
fmt | C string that contains the text to be written to destination string. It can optionally contain embedded format specifiers. |
... | (additional arguments) Depending on the format string, the function may expect a sequence of additional arguments, each containing a value to be used to replace a format specifier in the format string. |
There should be at least as many of these arguments as the number of values specified in the format specifiers.
Additional arguments are ignored by the function.
Copy the string pointed by 'fmt' param to the 'buffer' param.
If 'fmt' includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers
char* strcat | ( | char * | dest, |
const char * | src | ||
) |
Concatenate two strings.
dest | Destination string (it must be large enough to receive appending). |
src | Source string. |
Appends the source string to the destination string.
u16 char* strclr | ( | char * | str | ) |
Clear a string.
str | string to clear. |
Clear the specified string.
s16 strcmp | ( | const char * | str1, |
const char * | str2 | ||
) |
Compare the 2 strings.
str1 | The string we want to compare. |
str2 | The string we want to compare. |
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 null-character is reached.
char* strcpy | ( | char * | dest, |
const char * | src | ||
) |
Copy a string.
dest | Destination string (it must be large enough to receive the copy). |
src | Source string. |
Copies the source string to destination.
u16 strlen | ( | const char * | str | ) |
Calculate the length of a string (limited to 65535 characters maximum).
str | The string we want to calculate the length. |
This function calculates and returns the length of the specified string (limited to 65535 characters maximum).
char* strncpy | ( | char * | dest, |
const char * | src, | ||
u16 | len | ||
) |
Copy the first 'len' character of string.
dest | Destination string (its size must be >= (len + 1)). |
src | Source string. |
len | Maximum number of character to copy. |
Copies the source string to destination.
Compute the length of a string, to a maximum number of bytes.
str | The string whose length you want to calculate. |
maxlen | The maximum length to check. |
The strnlen() function computes the length of the string pointed to by 'str', not including the terminating null character ('\0'),
up to a maximum of 'maxlen' bytes. The function doesn't check any more than the first 'maxlen' bytes.
char* strreplacechar | ( | char * | str, |
char | oldc, | ||
char | newc | ||
) |
Replace the given character in a string.
str | The string to operate on. |
oldc | The character being replaced. |
newc | The character 'oldc' is replaced with. |
Replace all occurrences of character in a null-terminated string.
Convert a u32 value to string (input value should be in [0..500000000] range).
value | The u32 integer value to convert to string (input value should be in [0..500000000] range). |
str | Destination string (it must be large enough to receive result). |
minsize | Minimum size of resulting string. |
Converts the specified u32 value to string.
If resulting value is shorter than requested minsize the method prepends result with '0' character.