LAL  7.5.0.1-08ee4f4

Detailed Description

XLAL string manipulation routines.

Author
Creighton, J. D. E.

Prototypes

int XLALStringPrint (char *s, size_t n, const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(3
 
int char * XLALStringAppend (char *s, const char *append)
 Like strcat but dynamically reallocates string with LALRealloc. More...
 
char * XLALStringAppendFmt (char *s, const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(2
 
char char * XLALStringDuplicate (const char *s)
 Like strdup but uses LAL allocation routines (free with LALFree). More...
 
size_t XLALStringCopy (char *dst, const char *src, size_t size)
 Copy sources string src to destination string dst. More...
 
size_t XLALStringConcatenate (char *dst, const char *src, size_t size)
 Concatenate sources string src to the end of destination string dst. More...
 
int XLALStringToLowerCase (char *string)
 Turn a string in-place into lowercase without using locale-dependent functions. More...
 
int XLALStringToUpperCase (char *string)
 Turn a string in-place into uppercase without using locale-dependent functions. More...
 
int XLALStringCaseCompare (const char *s1, const char *s2)
 Compare two strings, ignoring case and without using locale-dependent functions. More...
 
int XLALStringNCaseCompare (const char *s1, const char *s2, size_t n)
 Compare the first N characters of two strings, ignoring case and without using locale-dependent functions. More...
 
char * XLALStringCaseSubstring (const char *haystack, const char *needle)
 Locates substring needle in string haystack, ignoring case and without using locale-dependent functions. More...
 
char * XLALStringToken (char **s, const char *delim, int empty)
 Return the next token delimited by any character in 'delim' from the string 's', which is updated to point just pass the returned token. More...
 
char * XLALStringTranslate (char *s, int(*f)(int, void *), void *param)
 Return the string 's' applying the function 'f(c, param)' to all characters 'c'. More...
 
char * XLALStringStripChars (char *s, int(*f)(int))
 Return the string 's' with all characters for which 'f()' is true removed. More...
 
char * XLALStringKeepChars (char *s, int(*f)(int))
 Return the string 's' with all characters for which 'f()' is false removed. More...
 
char * XLALStringReplaceChar (char *s, const int from, const int to)
 Return the string 's' with all characters 'from' replaced with 'to'. More...
 

Function Documentation

◆ XLALStringPrint()

int XLALStringPrint ( char *  s,
size_t  n,
const char *  fmt,
  ... 
)

◆ XLALStringAppend()

int char* XLALStringAppend ( char *  s,
const char *  append 
)

Like strcat but dynamically reallocates string with LALRealloc.

Definition at line 50 of file LALString.c.

◆ XLALStringAppendFmt()

char* XLALStringAppendFmt ( char *  s,
const char *  fmt,
  ... 
)

◆ XLALStringDuplicate()

char char* XLALStringDuplicate ( const char *  s)

Like strdup but uses LAL allocation routines (free with LALFree).

Definition at line 89 of file LALString.c.

◆ XLALStringCopy()

size_t XLALStringCopy ( char *  dst,
const char *  src,
size_t  size 
)

Copy sources string src to destination string dst.

Up to size - 1 characters are copied and destination string dst is guaranteed to be NUL-terminated. Return value is the length of source string src. If this is greater than or equal to the size of the destination string buffer, size, then truncation has occurred. Should be nearly equivalent to strlcpy.

Definition at line 104 of file LALString.c.

◆ XLALStringConcatenate()

size_t XLALStringConcatenate ( char *  dst,
const char *  src,
size_t  size 
)

Concatenate sources string src to the end of destination string dst.

Characters are added to destination string dst until the source string src is exhausted or the length of destination string dst is size - 1 characters. Destination string dst is guaranteed to be NUL-terminated. Return value is the initial length of destination string dst plus the length of source string src. If this is greater than or equal to the size of the destination string buffer, size, then truncation has occurred. Should be nearly equivalent to strlcat.

Definition at line 131 of file LALString.c.

◆ XLALStringToLowerCase()

int XLALStringToLowerCase ( char *  string)

Turn a string in-place into lowercase without using locale-dependent functions.

Definition at line 153 of file LALString.c.

◆ XLALStringToUpperCase()

int XLALStringToUpperCase ( char *  string)

Turn a string in-place into uppercase without using locale-dependent functions.

Definition at line 182 of file LALString.c.

◆ XLALStringCaseCompare()

int XLALStringCaseCompare ( const char *  s1,
const char *  s2 
)

Compare two strings, ignoring case and without using locale-dependent functions.

Definition at line 210 of file LALString.c.

◆ XLALStringNCaseCompare()

int XLALStringNCaseCompare ( const char *  s1,
const char *  s2,
size_t  n 
)

Compare the first N characters of two strings, ignoring case and without using locale-dependent functions.

Definition at line 219 of file LALString.c.

◆ XLALStringCaseSubstring()

char* XLALStringCaseSubstring ( const char *  haystack,
const char *  needle 
)

Locates substring needle in string haystack, ignoring case and without using locale-dependent functions.

Definition at line 267 of file LALString.c.

◆ XLALStringToken()

char* XLALStringToken ( char **  s,
const char *  delim,
int  empty 
)

Return the next token delimited by any character in 'delim' from the string 's', which is updated to point just pass the returned token.

If 'empty' is true, empty tokens are accepted.

Definition at line 292 of file LALString.c.

◆ XLALStringTranslate()

char* XLALStringTranslate ( char *  s,
int(*)(int, void *)  f,
void *  param 
)

Return the string 's' applying the function 'f(c, param)' to all characters 'c'.

If 'f()' returns < 0, the character is stripped from the string.

Definition at line 324 of file LALString.c.

◆ XLALStringStripChars()

char* XLALStringStripChars ( char *  s,
int(*)(int)  f 
)

Return the string 's' with all characters for which 'f()' is true removed.

Definition at line 354 of file LALString.c.

◆ XLALStringKeepChars()

char* XLALStringKeepChars ( char *  s,
int(*)(int)  f 
)

Return the string 's' with all characters for which 'f()' is false removed.

Definition at line 368 of file LALString.c.

◆ XLALStringReplaceChar()

char* XLALStringReplaceChar ( char *  s,
const int  from,
const int  to 
)

Return the string 's' with all characters 'from' replaced with 'to'.

Definition at line 382 of file LALString.c.