Generic String Methods.
More...
#include <stringmethods.h>
|
template<class C > |
static bool | ContainOnlySpaces (const C *src, size_t len) |
|
template<class C > |
static int | Find (const C *src, size_t len, const C car, int pos=0, bool CaseSensitive=true) |
|
template<class C > |
static int | FindStr (const C *src, size_t len, const C *str, size_t strlen, int pos=0, bool CaseSensitive=true) |
|
template<class C > |
static int | FindAnyStr (const C *src, size_t len, const C *str, size_t strlen, int pos=0, bool CaseSensitive=true) |
|
template<class C > |
static bool | Begins (const C *src, size_t len, const C *begin, size_t beginlen, bool CaseSensitive=true, bool skip=false) |
|
template<class C > |
static bool | Ends (const C *src, size_t len, const C *end, size_t endlen, bool CaseSensitive=true, bool skip=false) |
|
template<class C > |
static bool | IsAt (const C *src, size_t len, const C *sub, size_t sublen, int pos, bool CaseSensitive=true) |
|
Generic String Methods.
This class proposes some generic static methods working on array of characters ending with a 0.
static bool ContainOnlySpaces |
( |
const C * |
src, |
|
|
size_t |
len |
|
) |
| |
|
static |
Look if the string contains only spaces.
- Template Parameters
-
- Parameters
-
src | Character array. |
len | Length of the character array. |
static int Find |
( |
const C * |
src, |
|
|
size_t |
len, |
|
|
const C |
car, |
|
|
int |
pos = 0 , |
|
|
bool |
CaseSensitive = true |
|
) |
| |
|
static |
Find the position of a given character in the string.
- Template Parameters
-
- Parameters
-
src | Character array. |
len | Length of the character array. |
car | Character to find. |
pos | Position to start the search. Negative values start the search from the end. |
CaseSensitive | Is the search case sensitive. |
- Returns
- The position of the first occurrence or -1 if the character was not found.
static int FindStr |
( |
const C * |
src, |
|
|
size_t |
len, |
|
|
const C * |
str, |
|
|
size_t |
strlen, |
|
|
int |
pos = 0 , |
|
|
bool |
CaseSensitive = true |
|
) |
| |
|
static |
Find the position of a given string in the string.
- Template Parameters
-
- Parameters
-
src | Character array. |
len | Length of the character array. |
str | String to find. |
strlen | Length of the string to find. |
pos | Position to start the search. Negative values start the search from the end. |
CaseSensitive | Is the search case sensitive. |
- Returns
- The position of the first occurrence or -1 if the string was not found.
static int FindAnyStr |
( |
const C * |
src, |
|
|
size_t |
len, |
|
|
const C * |
str, |
|
|
size_t |
strlen, |
|
|
int |
pos = 0 , |
|
|
bool |
CaseSensitive = true |
|
) |
| |
|
static |
Find the position of a character of a given set in the string.
- Template Parameters
-
- Parameters
-
src | Character array. |
len | Length of the character array. |
str | String to find. |
strlen | Length of the string to find. |
pos | Position to start the search. Negative values start the search from the end. |
CaseSensitive | Is the search case sensitive. |
- Returns
- The position of the first occurrence or -1 if the character was not found.
static bool Begins |
( |
const C * |
src, |
|
|
size_t |
len, |
|
|
const C * |
begin, |
|
|
size_t |
beginlen, |
|
|
bool |
CaseSensitive = true , |
|
|
bool |
skip = false |
|
) |
| |
|
static |
Look if a string begins with a given sub-string.
- Template Parameters
-
- Parameters
-
src | Character array. |
len | Length of the character array. |
begin | String to to search for. |
beginlen | Length of the string to find. |
CaseSensitive | Is the search case sensitive. |
skip | If true, leading spaces are skipped for the comparison. |
- Returns
- true if the string begins with the sub-string.
static bool Ends |
( |
const C * |
src, |
|
|
size_t |
len, |
|
|
const C * |
end, |
|
|
size_t |
endlen, |
|
|
bool |
CaseSensitive = true , |
|
|
bool |
skip = false |
|
) |
| |
|
static |
Look if a string ends with a given sub-string.
- Template Parameters
-
- Parameters
-
src | Character array. |
len | Length of the character array. |
end | String to to search for. |
endlen | Length of the string to find. |
CaseSensitive | Is the search case sensitive. |
skip | If true, ending spaces are skipped for the comparison. |
- Returns
- true if the string ends with the sub-string.
static bool IsAt |
( |
const C * |
src, |
|
|
size_t |
len, |
|
|
const C * |
sub, |
|
|
size_t |
sublen, |
|
|
int |
pos, |
|
|
bool |
CaseSensitive = true |
|
) |
| |
|
static |
Verify if a given sub-string is at a given position.
- Template Parameters
-
- Parameters
-
src | Character array. |
len | Length of the character array. |
sub | String to to search for. |
sublen | Length of the string to find. |
pos | Position to start the search. Negative values start the search from the end. |
CaseSensitive | Is the search case sensitive. |
- Returns
- true if the string at a given position.