src/strext.c File Reference
String extension functions.
More...
Functions |
bool | se_to_ulint (const char *buffer, unsigned long int *dest) |
| Attempts to parse the string in buffer as an unsigned long int in base-10.
|
bool | se_to_float (const char *buffer, float *dest) |
| Attempts to parse the string in buffer as a floating point.
|
char * | se_trim_spaces (char *buffer) |
| Trims leading and trailing spaces from a string.
|
char * | se_skip_leading_spaces (char *buffer) |
| Returns a new pointer from buffer past the leading spaces.
|
void | se_remove_trailing_spaces (char *buffer) |
| Removes spaces from buffer by replacing the first trailing space with a NULL terminator.
|
int | se_icompare (const char *a, const char *b) |
| Compares a with b, regardless of case.
|
int | se_incompare (const char *a, const char *b, const size_t n) |
| Compares a with b, regardless of case for n characters.
|
bool | se_is_space (const char ch) |
| Returns true if the given character is a tab or space.
|
char * | se_nchr (char *buffer, const size_t n, const char ch) |
| Returns the first occurance of the given character for a max of n characters.
|
Detailed Description
String extension functions.
For stuff that isn't in the standard library.
- Date:
- 21 Jan 2010
- Author:
- Zachary Sims <zacs7@users.sourceforge.net>
Module prefix: se_ (avoid ISO C reserved prefix of str*)
$Id$
Function Documentation
int se_icompare |
( |
const char * |
a, |
|
|
const char * |
b | |
|
) |
| | |
Compares a with b, regardless of case.
- Parameters:
-
| a | The string to compare b with. |
| b | The string to compare a with. |
- Returns:
- Zero if the strings are equal. Else less than zero is returned if a is less than b. Otherwise positive value is returned if a is greater than b.
int se_incompare |
( |
const char * |
a, |
|
|
const char * |
b, |
|
|
const size_t |
n | |
|
) |
| | |
Compares a with b, regardless of case for n characters.
- Parameters:
-
| a | The string to compare b with. |
| b | The string to compare a with. |
| n | The maximum number of characters to compare. |
- Returns:
- Zero if the strings are equal. Else less than zero is returned if a is less than b. Otherwise positive value is returned if a is greater than b.
bool se_is_space |
( |
const char |
ch |
) |
|
Returns true if the given character is a tab or space.
- Parameters:
-
- Returns:
- true if the character is or ' '. False is returned otherwise.
char* se_nchr |
( |
char * |
buffer, |
|
|
const size_t |
n, |
|
|
const char |
ch | |
|
) |
| | |
Returns the first occurance of the given character for a max of n characters.
- Parameters:
-
| buffer | The string to search in. |
| ch | The char to search for. |
| n | The maximum number of characters to traverse. |
- Returns:
- The first occurance of ch. On error, NULL is returned.
void se_remove_trailing_spaces |
( |
char * |
buffer |
) |
|
Removes spaces from buffer by replacing the first trailing space with a NULL terminator.
- See also:
- se_skip_leading_spaces()
- Parameters:
-
| buffer | The NULL terminated string to remove spaces from. |
char* se_skip_leading_spaces |
( |
char * |
buffer |
) |
|
Returns a new pointer from buffer past the leading spaces.
Note: Be careful with malloc()'d memory since the pointer will be lost unless you save it. A space is anything given by isspace(ch).
- See also:
- se_remove_trailing_spaces()
- Parameters:
-
| buffer | The NULL terminated string to skip spaces from. |
- Returns:
- A pointer to the first non-space character of buffer.
bool se_to_float |
( |
const char * |
buffer, |
|
|
float * |
dest | |
|
) |
| | |
Attempts to parse the string in buffer as a floating point.
- Parameters:
-
| buffer | The string to parse. |
| dest | Where to put the float. Only written to on success. |
- Returns:
- true if the float was parsed. Otherwise, false is returned on error.
bool se_to_ulint |
( |
const char * |
buffer, |
|
|
unsigned long int * |
dest | |
|
) |
| | |
Attempts to parse the string in buffer as an unsigned long int in base-10.
- Parameters:
-
| buffer | The string to parse. |
| dest | Where to put the unsigned long integer. Only written to on success. |
- Returns:
- true if the integer was parsed. Otherwise, false is returned on error.
char* se_trim_spaces |
( |
char * |
buffer |
) |
|