-
Notifications
You must be signed in to change notification settings - Fork 0
mdz_ansi_dyn_replace
Maksym Dzyubenko edited this page Oct 8, 2024
·
1 revision
Replace every occurence of pcItemsBefore
with pcItemsAfter
in Data. If there is not enouhgh Capacity
, realloc()
function set in mdz_ansi_dyn_setAllocFunctions()
will be used
enum mdz_error mdz_ansi_dyn_replace(
mdz_AnsiDyn** ppsAnsi,
size_t nLeftPos,
size_t nRightPos,
const char* pcItemsBefore,
size_t nCountBefore,
const char* pcItemsAfter,
size_t nCountAfter,
mdz_bool bFromLeft,
enum mdz_ansi_replace_type enReplacementType);
Parameter | Description |
---|---|
ppsAnsi |
pointer to address of string returned by mdz_ansi_dyn_create() or mdz_ansi_dyn_attach() . If after reallocation string address will be changed, new address will be stored here |
nLeftPos |
0-based start position to search from left. Use 0 to search from the beginning of Data |
nRightPos |
0-based end position to search up to. Use Size-1 to search till the end of Data |
pcItemsBefore |
items to find. Cannot be NULL
|
nCountBefore |
number of items to find. Cannot be 0 |
pcItemsAfter |
pointer to items to replace with. Can be NULL
|
nCountAfter |
number of items to replace. Can be 0 |
bFromLeft |
mdz_true if search for items to replace from left side, otherwise from right |
enReplacementType |
type of replacement when nCountAfter > nCountBefore (thus Size is growing). For now only MDZ_ANSI_REPLACE_DUAL is supported (please refer to description of mdz_ansi_replace_type enum) |
Return | Description |
---|---|
MDZ_ERROR_LICENSE | license is not initialized using mdz_ansi_dyn_init() or invalid |
MDZ_ERROR_DATA | psAnsi is NULL
|
MDZ_ERROR_CAPACITY |
Capacity is 0 or too large |
MDZ_ERROR_BIG_SIZE |
Size > Capacity
|
MDZ_ERROR_ZERO_SIZE |
Size is 0 (string is empty) |
MDZ_ERROR_TERMINATOR | there is no 0-terminator on Data[Size ] position |
MDZ_ERROR_ITEMS |
pcItemsBefore is NULL
|
MDZ_ERROR_ZERO_COUNT |
nCountBefore is 0 |
MDZ_ERROR_BIG_RIGHT |
nRightPos >= Size
|
MDZ_ERROR_BIG_LEFT |
nLeftPos > nRightPos
|
MDZ_ERROR_BIG_COUNT | nCount is bigger than search area (between nLeftPos and nRightPos ) |
MDZ_ERROR_OVERLAP | Data overlaps with pcItemsBefore , or Data overlaps with pcItemsAfter
|
MDZ_ERROR_BIG_REPLACE | new Size after replacement > Capacity
|
MDZ_ERROR_OVERLAP_REPLACE | Data after replacement - overlaps with pcItemsBefore , or Data after replacement - overlaps with pcItemsAfter
|
MDZ_ERROR_ATTACHED | string has not enough capacity for replacements, but is attached (using mdz_ansi_dyn_attach() ), thus cannot be reallocated |
MDZ_ERROR_REALLOC_FUNC | could not realloc string created with mdz_ansi_dyn_create() , because realloc() function is not set (using mdz_ansi_dyn_setAllocFunctions() ) |
MDZ_ERROR_ALLOCATION | string reallocation failed |
MDZ_ERROR_NONE | function succeeded |
mdz_ansi_dyn API Reference is generated using mdzApiRefGenerator.
mdz_ansi_dyn functions
- Init/destroy functions
- Status functions
- Insert/remove functions
- Find functions
- Miscellaneous functions