Site Logo

maxdz Software GmbH

Eng | Ger
Home

Team

Products

mdz_ui

mdz_xml

mdz_ansi

mdz_unicode

mdz_vector

Shop

Legals

Contacts

mdz_ansi Overview

mdz_ansi - very lightweight, versatile and speedy C library for handling single-byte (ASCII/ANSI) strings. Source code of library is highly-portable, conforms to ANSI C 89/90 Standard. Builds for Win32/Win64, Linux, FreeBSD, Android, macOS are available.

Please refer to mdz_ansi Wiki for API details.

mdz_ansi Advantages

1. High portability: the whole code conforms to ANSI C 89/90 Standard. Multithreading/asynchronous part is POSIX compatible (under UNIX/Linux).

2. Little dependencies: basically, mdz_ansi functions are only dependent on standard C-library memory-management/access functions. Multithreading part is dependent on POSIX pthreads API (under UNIX/Linux) and old process control/synchronization API (from Windows 2000). It means you can use library in your code without any further dependencies except standard platform libraries/APIs.

3. Fast: comparison tables are coming soon...

4. Flexibilty: nearly all functions contain not only "left position" but also "right position" parameters to limit processed area from right. "ANSI" ansi contains more functions than according STL, boost or glib analogs have.

5. Extended error-checking: all functions preserve internal error-code pointing the problem. It is possible to use strict error-checking (when all preserved error-codes should be MDZ_ERROR_NONE) or "relaxed"-checking - when only returned mdz_false will indicate error.

6. Extended control: library functions do only explicit operations. It means for example, when "insert" function is called - it will return error if there is not enough capacity in string. No implicit reservations will be made.

7. Attached usage: string should not necessarily use dynamically-allocated memory - which may be not available on your embedded system (or if malloc()/free() are forbidden to use in you safety-critical software). Just attach string/data to your statically-allocated memory and use all string functionality.

8. Cache-friendly: it is possible to keep controlling and data parts together in memory using "embedded part".

9. Asynchronous execution: almost all functions can be executed asynchronously.


mdz_ansi API Reference

Asynchronous execution

Many functions of mdz_ansi accept parameters for asynchronous execution.
The only relevant parameter is:

- struct mdz_asyncData* pAsyncData - pointer to shared async data for asynchronous call, or NULL if call should be synchronous

Fields of struct mdz_asyncData* are following:

TypeParameterDescription
void* m_pStringPointer to string instance
mdz_bool m_bFinishedmdz_true if the call is completely finished. Otherwise mdz_false (if interrupted/cancelled)
size_t m_nResultResult of call. Invalid if call is not completely finished (m_bFinished is mdz_false)
void* m_pDataAdditional data returned by call (if any). Invalid if call is not completely finished (m_bFinished is mdz_false)
mdz_bool m_bCancelShould be set by client in mdz_true during call execution, to cancel the call. Otherwise mdz_false
pthread_t / HANDLE m_hThreadHandle to thread on which the call is executed. May be used by client for wait operations


mdz_ansi API Reference is generated using mdzApiRefGenerator.

mdz_ansi General Information and Functions

mdz_ansi is dynamically-sized contiguous single-byte string, containing ASCII (0..127) and "ANSI" (128 - 255) characters.

Capacity - how many bytes of memory is reserved.
Size - how many characters are actually residing in a string, excluding terminating 0.

"reserve" functions allocate/reallocate memory dynamically using malloc()/realloc().
"attach" functionality allows attaching contiguous block of memory to string, for using string functions on it.

Library init functions:

mdz_ansi_init
mdz_ansi_init_attached
mdz_ansi_uninit

Init and destroy functions:

mdz_ansi_create
mdz_ansi_create_attached
mdz_ansi_destroy
mdz_ansi_clear
mdz_ansi_attachData

Reserve capacity functions:

mdz_ansi_reserve
mdz_ansi_reserveAndInit_async
mdz_ansi_capacity
mdz_ansi_size
mdz_ansi_resize
mdz_ansi_offsetFromStart
mdz_ansi_isAttachedData
mdz_ansi_embedSize

Insert/remove functions:

mdz_ansi_insert_async
mdz_ansi_insertDoubleZerowed_async
mdz_ansi_removeFrom_async
mdz_ansi_remove_async
mdz_ansi_trimLeft_async
mdz_ansi_trimRight_async
mdz_ansi_trim_async

Find functions:

mdz_ansi_findSingle_async
mdz_ansi_find_async
mdz_ansi_firstOf_async
mdz_ansi_firstNotOf_async
mdz_ansi_rfindSingle_async
mdz_ansi_rfind_async
mdz_ansi_lastOf_async
mdz_ansi_lastNotOf_async

Miscellaneous functions:

mdz_ansi_compare_async
mdz_ansi_replace_async
mdz_ansi_count_async
mdz_ansi_copySubAnsi_async
mdz_ansi_copySubAnsiFrom_async


mdz_ansi_init

Initializes ansi library. This function should be called before any other function of the library.

mdz_bool mdz_ansi_init(const uint32_t* pFirstNameHash, const uint32_t* pLastNameHash, const uint32_t* pEmailHash, const uint32_t* pLicenseHash);

ParameterDescription
pFirstNameHashuser first name hash code
pLastNameHashuser last name hash code
pEmailHashuser e-mail hash code
pLicenseHashlicense hash code

ReturnDescription
mdz_trueif the initialization has succeed, otherwise false

mdz_ansi Reference

mdz_ansi_init_attached

Initializes ansi library. This function should be caled before any other function of the library.
Memory for license data starts at position pStart. Size of internal initialization structure is returned in pSize.

mdz_bool mdz_ansi_init_attached(const uint32_t* pFirstNameHash, const uint32_t* pLastNameHash, const uint32_t* pEmailHash, const uint32_t* pLicenseHash, const char* pStart, size_t nAreaSize, size_t* pOutSize);

ParameterDescription
pFirstNameHashuser first name hash code
pLastNameHashuser last name hash code
pEmailHashuser e-mail hash code
pLicenseHashlicense hash code
pStartmemory start position of license data
nAreaSizesize of available memory from pStart in bytes. Should be large enough for license data (> 500 bytes)
pOutSizeactual size of placed license data in bytes

ReturnDescription
mdz_trueif the initialization has succeed, otherwise false

mdz_ansi Reference

mdz_ansi_uninit

Un-initializes ansi library and frees corresponding memory allocations.

void mdz_ansi_uninit(void);

mdz_ansi Reference

mdz_ansi_create

Create empty string with Capacity and Size 0.

struct mdz_Ansi* mdz_ansi_create(size_t nEmbedSize);

ParameterDescription
nEmbedSizesize of "embedded part" of string. There is no "embedded part" if 0

ReturnDescription
NULLif library is not initialized with mdz_ansi_init() call
NULLif memory allocation failed
Resultpointer to string for use in other mdz_ansi functions

mdz_ansi Reference

mdz_ansi_create_attached

Create empty string with Capacity and Size 0. Memory for mdz_Ansi structure starts at position pStart. Size of internal ansi structure (it is usually bigger than mdz_Ansi) is returned in pSize.

struct mdz_Ansi* mdz_ansi_create_attached(const void* pStart, size_t nAreaSizeBytes, size_t* pOutSize);

ParameterDescription
pStartmemory start position of mdz_Ansi structure
nAreaSizeBytessize of available memory from pStart in bytes. Should be large enough for internal Ansi structure
pOutSizereturned actual size of placed internal ansi structure in bytes, may be NULL if not needed

ReturnDescription
NULLif library is not initialized with mdz_ansi_init() call
NULLif pStart == NULL or pSize == NULL
NULLif size in nSize is smaller than size of internal ansi structure
Resultpointer to string for use in other mdz_Ansi functions. Normally it equals to pStart

mdz_ansi Reference

mdz_ansi_destroy

Destroy string including underlying data. After destroying, pointer to string is set to NULL.
If string is attached using mdz_ansi_createAttached(), free() will not be called.
If string data is attached using mdz_ansi_attachData(), m_pData will not be destroyed.

void mdz_ansi_destroy(struct mdz_Ansi** const ppAnsi);

ParameterDescription
ppAnsipointer to pointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

mdz_ansi Reference

mdz_ansi_clear

Clear m_pData of string with setting Size in 0.

void mdz_ansi_clear(struct mdz_Ansi* pAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create()

mdz_ansi Reference

mdz_ansi_attachData

Attach pre-allocated data to string, assigning pcData to m_pData. If attached, m_pData will not be destroyed in mdz_ansi_destroy()

mdz_bool mdz_ansi_attachData(struct mdz_Ansi* pAnsi, const char* pData, size_t nOffsetFromStart, size_t nCapacity, enum mdz_attach_type enAttachType);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
pDatapointer to pre-allocated data to attach
nOffsetFromStartposition in pre-allocated data to attach from. Can be > 0
nCapacityfull capacity of pre-allocated data in items
enAttachTypetype of attachment. 0 is expected at position pData[nOffsetFromStart] if MDZ_ATTACH_ZEROSIZE. 0 is expected at position pData[nCapacity - 1] if MDZ_ATTACH_SIZE_TERMINATOR

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif pData == NULL (MDZ_ERROR_DATA), or nOffsetFromStart >= nCapacity (MDZ_ERROR_OFFSET)
mdz_falseif enAttachType is MDZ_ATTACH_ZEROSIZE or MDZ_ATTACH_SIZE_TERMINATOR but 0 is not found at expected position (MDZ_ERROR_ATTACH_TERMINATOR)
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_reserve

Reserve nNewCapacity items for string. String Size does not change. Reservation is not made if m_pData is attached using mdz_ansi_attachData()

mdz_bool mdz_ansi_reserve(struct mdz_Ansi* pAnsi, size_t nNewCapacity);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nNewCapacitynew capacity in items to reserve

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif nNewCapacity > Capacity and m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_trueif nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY)
mdz_true reservation succeeded

mdz_ansi Reference

mdz_ansi_reserveAndInit_async

Reserve nNewCapacity items for string and initializes all items in cItem. May be called only on empty string (with Size == 0). After call, string Size equals to Capacity-1.
Reservation is not made if m_pData is attached using mdz_ansi_attachData() and nNewCapacity > Capacity

mdz_bool mdz_ansi_reserveAndInit_async(struct mdz_Ansi* pAnsi, size_t nNewCapacity, char cItem, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_reserveAndInit(pAnsi, nNewCapacity, cItem);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nNewCapacitycapacity to reserve in items
cItemitem for string initialization
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif Size > 0 (MDZ_ERROR_NONEMPTY)
mdz_falseif nNewCapacity > Capacity and m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_trueif nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY), initialization succeeded
mdz_truereservation and initialization succeeded

mdz_ansi Reference

mdz_ansi_capacity

Return string Capacity in items.

size_t mdz_ansi_capacity(const struct mdz_Ansi* pAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif pAnsi == NULL
Capacityotherwise

mdz_ansi Reference

mdz_ansi_size

Return string Size in items.

size_t mdz_ansi_size(const struct mdz_Ansi* pAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeotherwise

mdz_ansi Reference

mdz_ansi_resize

Set string Size. Size must be < Capacity (because of terminating 0)

mdz_bool mdz_ansi_resize(struct mdz_Ansi* pAnsi, size_t nNewSize);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nNewSizenew Size to set string in

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif nNewSize >= Capacity (MDZ_ERROR_CAPACITY). String Size is not changed
mdz_trueif succeeded

mdz_ansi Reference

mdz_ansi_offsetFromStart

Return string OffsetFromStart in items.

size_t mdz_ansi_offsetFromStart(const struct mdz_Ansi* pAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif pAnsi == NULL
OffsetFromStartotherwise

mdz_ansi Reference

mdz_ansi_isAttachedData

Return if string data is attached.

mdz_bool mdz_ansi_isAttachedData(const struct mdz_Ansi* pAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif string data is not attached
mdz_trueif string data is attached

mdz_ansi Reference

mdz_ansi_embedSize

Return string "embedded part" Size in items.

size_t mdz_ansi_embedSize(const struct mdz_Ansi* pAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif pAnsi == NULL
Result"embedded part" Size otherwise

mdz_ansi Reference

mdz_ansi_insert_async

Insert nCount items in string. String m_pData and pItems cannot overlap, if reservation is allowed. Size grows on nCount.

mdz_bool mdz_ansi_insert_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, const char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_insert(pAnsi, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based position to insert. If nLeftPos == Size or -1, items are appended. nLeftPos > Size is not allowed
pcItemsitems to insert
nCountnumber of items to insert or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Size (MDZ_ERROR_BIGLEFT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No insertion is made
mdz_trueinsertion succeeded

mdz_ansi Reference

mdz_ansi_insertDoubleZerowed_async

Insert items in string until double-zerowed terminator ("\0\0"). String m_pData and pItems cannot overlap, if reservation is allowed. Size grows on inserted string length.

mdz_bool mdz_ansi_insertDoubleZerowed_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, const char* pcItems, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_insertDoubleZerowed(pAnsi, nLeftPos, pcItems, bReserve);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based position to insert. If nLeftPos == Size or -1, items are appended. nLeftPos > Size is not allowed
pcItemsitems to insert
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or pcItems length id 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Size (MDZ_ERROR_BIGLEFT), or pcItems is too long (MDZ_ERROR_BIGCOUNT). No insertion is made
mdz_trueinsertion succeeded

mdz_ansi Reference

mdz_ansi_findSingle_async

Find first occurrence of cItem in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_findSingle_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, char cItem, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_findSingle(pAnsi, nLeftPos, nRightPos, cItem);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or -1 to search till the end of string
cItemcharacter to find
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_find_async

Find first occurrence of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_find_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, enum mdz_find_method enFindMethod, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_find(pAnsi, nLeftPos, nRightPos, pcItems, nCount, enFindMethod);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or -1 to search till the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
enFindMethodfind method to use. See details in mdz_find_method description
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_firstOf_async

Find first occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_firstOf_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_firstOf(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or -1 to search till the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_firstNotOf_async

Find first non-occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_firstNotOf_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_firstNotOf(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or -1 to serch till the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif non-occurence is not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_rfindSingle_async

Find last occurrence of cItem in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_rfindSingle_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, char cItem, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_rfindSingle(pAnsi, nLeftPos, nRightPos, cItem);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to find up to. Use 0 to search till the beginning of string
nRightPos0-based start position to find from right. Use Size-1 or -1 to serch from the end of string
cItemcharacter to find
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_rfind_async

Find last occurrence of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_rfind_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, enum mdz_find_method enFindMethod, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_rfind(pAnsi, nLeftPos, nRightPos, pcItems, nCount, enFindMethod);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to find up to. Use 0 to search till the beginning of string
nRightPos0-based start position to find from right. Use Size-1 or -1 to serch from the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
enFindMethodfind method to use. See details in mdz_find_method description
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_lastOf_async

Find last occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_lastOf_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_lastOf(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to search up to. Use 0 to search till the beginning of string
nRightPos0-based start position to search from right. Use Size-1 or -1 to serch from the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_lastNotOf_async

Find last non-occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_lastNotOf_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_lastNotOf(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to search up to. Use 0 to search till the beginning of string
nRightPos0-based start position to search from right. Use Size-1 or -1 to serch from the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif non-occurence is not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_removeFrom_async

Remove nCount item(s) starting from 0-based nLeftPos position. After the operation, Capacity doesn't change, Size decreases on nCount.

mdz_bool mdz_ansi_removeFrom_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_removeFrom(pAnsi, nLeftPos, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to remove item(s) from. Use 0 to remove from the beginning of string
nCountnumber of item(s) to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_trueif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGLEFT). No removes are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_remove_async

Remove all ocurrences of nCount item(s) matching to pcItems, residing between nLeftPos and nRightPos. After remove(s) Capacity doesn't change, Size decreases on nCount of removed items.

mdz_bool mdz_ansi_remove_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_remove(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to remove item(s) from. Use 0 to search from the beginning of string
nRightPos0-based end position to remove item(s) up to. Use Size-1 or -1 to serch till the end of string
pcItemspointer to items to remove
nCountnumber of item(s) to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No removes are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_trimLeft_async

Remove items which are contained in pcItems from left, until first non-contained in pcItems item is reached.

mdz_bool mdz_ansi_trimLeft_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_trimLeft(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to trim item(s) from left. Use 0 to trim from the beginning of string
nRightPos0-based end position to trim item(s) up to. Use Size-1 or -1 to trim till the end of string
pcItemspointer to items to remove
nCountnumber of items to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_trueif string is empty (MDZ_ERROR_EMPTY), or pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No trims are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_trimRight_async

Remove items which are contained in pcItems from right, until first non-contained in pcItems item is reached.

mdz_bool mdz_ansi_trimRight_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_trimRight(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to trim item(s) up to. Use 0 to trim till the beginning of string
nRightPos0-based start position to trim item(s) from right. Use Size-1 or -1 to trim from the end of string
pcItemspointer to items to remove
nCountnumber of items to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_trueif string is empty (MDZ_ERROR_EMPTY), or pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No removes are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_trim_async

Remove items which are contained in pcItems from left and from right, until first non-contained in pcItems item is reached.

mdz_bool mdz_ansi_trim_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_trim(pAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to trim item(s) from left. Use 0 to trim from the beginning of string
nRightPos0-based start position to trim item(s) from right. Use Size-1 or -1 to trim from the end of string
pcItemspointer to items to remove
nCountnumber of items to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_trueif string is empty (MDZ_ERROR_EMPTY), or pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No removes are made
mdz_trueoperation succeeded, otherwise mdz_false

mdz_ansi Reference

mdz_ansi_compare_async

Compare content of string with pcItems.

enum mdz_compare_result mdz_ansi_compare_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_compare(pAnsi, nLeftPos, pcItems, nCount);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to compare from. Use 0 to compare from the beginning of string
pcItemspointer to items to compare
nCountnumber of items to compare or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
MDZ_COMPARE_ERRORif pAnsi == NULL
MDZ_COMPARE_NONEQUALif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos >= Size (MDZ_ERROR_BIGLEFT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No comparison is made
MDZ_COMPARE_EQUAL or MDZ_COMPARE_NONEQUALResult of comparison

mdz_ansi Reference

mdz_ansi_replace_async

Replace every occurence of pcItemsBefore with pcItemsAfter. There should be enough Capacity for replacing data.

mdz_bool mdz_ansi_replace_async(struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItemsBefore, size_t nCountBefore, const char* pcItemsAfter, size_t nCountAfter, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_replace(pAnsi, nLeftPos, nRightPos, pcItemsBefore, nCountBefore, pcItemsAfter, nCountAfter, bReserve);

ParameterDescription
pAnsipointer to astring returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search for replace from. Use 0 to search from the beginning of string
nRightPos0-based end position to search for replace up to. Use Size-1 or -1 to seach till the end of string
pcItemsBeforepointer to items to replace
nCountBeforenumber of items to replace or 0 if pcItems until 0-terminator should be used
pcItemsAfterpointer to items to replace with
nCountAfternumber of items to replace with or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for replacement, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pAnsi == NULL
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_trueif pcItemsBefore == NULL (MDZ_ERROR_ITEMS), or nCountBefore == 0 and pcItemsBefore[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCountBefore is too big (MDZ_ERROR_BIGCOUNT). No replacements are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_count_async

Counts number of pcItems substring occurences in string.

size_t mdz_ansi_count_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, enum mdz_find_method enFindMethod, mdz_bool bAllowOverlapped, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_count(pAnsi, nLeftPos, nRightPos, pcItems, nCount, enFindMethod, bAllowOverlapped);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to count from. Use 0 to count from the beginning of string
nRightPos0-based end position to count up to. Use Size-1 or -1 to count till the end of string
pcItemsitems/substring to count
nCountSize of substring to count or 0 if pcItems until 0-terminator should be used
enFindMethodfind method to use. See details in mdz_find_method description
bAllowOverlappedmdz_true if overlapped substrings should be counted, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL
0if pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No counting is made
Result0-based count of substring occurences. 0 if not found

mdz_ansi Reference

mdz_ansi_copySubAnsi_async

Fills pSubAnsi with items from pAnsi, starting from nLeftPos and ending with one of pSeparators or nRightPos.

size_t mdz_ansi_copySubAnsi_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nRightPos, const char* pcSeparators, size_t nSeparatorsCount, struct mdz_Ansi* pSubAnsi, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_copySubAnsi(pAnsi, nLeftPos, nRightPos, pcSeparators, nSeparatorsCount, pSubAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to get items from. Use 0 to start from the beginning of string
nRightPos0-based end position to get items up to. Use Size-1 or -1 to proceed till the end of string
pcSeparatorsseparators to get items up to
nSeparatorsCountnumber of separators or 0 if pcSeparators until 0-terminator should be used
pSubAnsipointer to string where items should be copied. Data in pSubAnsi will be re-reserved to appropriate size if necessary
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL, or pSubAnsi == NULL (MDZ_ERROR_SUBCONTAINER), or reallocation of m_pData in pSubAnsi was necessary but failed (MDZ_ERROR_ALLOCATION)
Sizeif pcSeparators == NULL (MDZ_ERROR_ITEMS), or nSeparatorsCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No copying is made
Result0-based position after separator if found, or Size if not found

mdz_ansi Reference

mdz_ansi_copySubAnsiFrom_async

Fills pSubAnsi with items from pAnsi, starting from nLeftPos and containing nCount items.

size_t mdz_ansi_copySubAnsiFrom_async(const struct mdz_Ansi* pAnsi, size_t nLeftPos, size_t nCount, struct mdz_Ansi* pSubAnsi, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_copySubAnsiFrom(pAnsi, nLeftPos, nCount, pSubAnsi);

ParameterDescription
pAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to get items from. Use 0 to start from the beginning of string
nCountnumber of items to copy or 0 if pcItems until 0-terminator should be used
pSubAnsipointer to string where items should be copied. Data in pSubAnsi will be re-reserved to appropriate size if necessary
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif pAnsi == NULL, or pSubAnsi == NULL (MDZ_ERROR_SUBCONTAINER), or reallocation of m_pData in pSubAnsi was necessary but failed (MDZ_ERROR_ALLOCATION)
Sizeif nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGLEFT). No copying is made
Result0-based position after copied data, or Size if copied until the end of pAnsi

mdz_ansi Reference
Software Development. Strive for the Impossible to achieve Excellence.
Copyright Ⓒ 2017 - 2023 maxdz Software GmbH. All rights reserved.
Site content is generated using mdzWebSiteGenerator