Design Pattern Examples
Overview of object-oriented design patterns
helpers/replace.h File Reference

Declaration of various helper functions for replacing characters or strings in a string. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __REPLACE_H__
 

Functions

void replace_chr (char *s, char c1, char c2)
 Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-sensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string.
 
void replace_chri (char *s, char c1, char c2)
 Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-insensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string.
 
char * replace_str (const char *s, const char *str1, const char *str2)
 Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-sensitive search, returning a new string.
 
char * replace_stri (const char *s, const char *str1, const char *str2)
 Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-insensitive search, returning a new string.
 

Detailed Description

Declaration of various helper functions for replacing characters or strings in a string.

Definition in file helpers/replace.h.

Macro Definition Documentation

◆ __REPLACE_H__

#define __REPLACE_H__

Definition at line 8 of file helpers/replace.h.

Function Documentation

◆ replace_chr()

void replace_chr ( char *  s,
char  c1,
char  c2 
)

Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-sensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string.

Parameters
sString to modify
c1Character to replace
c2Character to replace with

Definition at line 17 of file replace.c.

Referenced by Composite_FileAccess_GetEntry().

◆ replace_chri()

void replace_chri ( char *  s,
char  c1,
char  c2 
)

Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-insensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string.

Parameters
sString to modify
c1Character to replace
c2Character to replace with

Definition at line 51 of file replace.c.

◆ replace_str()

char * replace_str ( const char *  s,
const char *  str1,
const char *  str2 
)

Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-sensitive search, returning a new string.

Parameters
sString to modify
str1String to replace
str2String to replace with (can be an empty string to remove str1).
Returns
Returns a new string containing the modifications. The string must be released using free()

Definition at line 127 of file replace.c.

References _append_range().

Referenced by Command_Operation_Replace(), and Memento_Operation_Replace().

◆ replace_stri()

char * replace_stri ( const char *  s,
const char *  str1,
const char *  str2 
)

Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-insensitive search, returning a new string.

Parameters
sString to modify
str1String to replace
str2String to replace with (can be an empty string to remove str1).
Returns
Returns a new string containing the modifications. The string must be released using free()

Definition at line 163 of file replace.c.

References _append_range(), and strstri().