-
Notifications
You must be signed in to change notification settings - Fork 0
mdz_ansi_alg_replace
Maksym Dzyubenko edited this page Oct 8, 2024
·
2 revisions
Replace every occurence of pcItemsBefore
with pcItemsAfter
. There should be enough Capacity
for replacing data.
enum mdz_error mdz_ansi_alg_replace(
char* pcData,
size_t* pnDataSize,
size_t nDataCapacity,
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,
size_t* pnNewSize);
Parameter | Description |
---|---|
pcData |
pointer to string |
pnDataSize |
pointer to current Size . If replacement succeed, new size is returned here |
nDataCapacity |
maximal capacity of pcData buffer. nDataCapacity does not include 0-terminator byte, thus pcData buffer should be at least 1 byte bigger than nDataCapacity
|
nLeftPos |
0-based start position to search for replace from. Use 0 to search from the beginning of string |
nRightPos |
0-based end position to search for replace up to. Use Size-1 or SIZE_MAX to seach till the end of string |
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) |
pnNewSize |
if nCountAfter > nCountBefore and there is not enough Capacity to make all replacements - minimal-necessary size is returned here, if pnNewSize is not NULL
|
Return | Description |
---|---|
MDZ_ERROR_LICENSE | license is not initialized using mdz_ansi_alg_init() or invalid |
MDZ_ERROR_DATA |
pcData is NULL
|
MDZ_ERROR_SIZE |
pnDataSize is NULL
|
MDZ_ERROR_CAPACITY |
nDataCapacity is 0 (no space for insertion) or SIZE_MAX (no space for 0-terminator) |
MDZ_ERROR_BIG_SIZE |
Size > Capacity
|
MDZ_ERROR_ZERO_SIZE |
Size is 0 (string is empty) |
MDZ_ERROR_TERMINATOR | there is no 0-terminator in the end of pcData ([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 |
pcData overlaps with pcItemsBefore , or pcData overlaps with pcItemsAfter
|
MDZ_ERROR_BIG_REPLACE | new Size after replacement > Capacity
|
MDZ_ERROR_OVERLAP_REPLACE |
pcData after replacement - overlaps with pcItemsBefore , or pcData after replacement - overlaps with pcItemsAfter
|
MDZ_ERROR_NONE | function succeeded |
mdz_ansi_alg API Reference is generated using mdzApiRefGenerator.
mdz_ansi_alg functions
- Init functions
- Insert/remove functions
- Find functions
- Miscellaneous functions