chsvlib
chsv helper source code

◆ AllocateAndFormatStringByTagsIndirectW()

wchar_t* Chusov::String::AllocateAndFormatStringByTagsIndirectW ( const wchar_t *restrict  lpszTagFormat,
unsigned int  cNumberOfTagsPresent,
const TAG_DESCRIPTION_PARAM_W *restrict  pTagsParams 
)

Allocates and initializes a wide string formatted by user-defined tags.

Parameters
[in]lpszTagFormatis a zero-terminated wide string specifying format using tag words placed within brackets, e.g. <tag>. The text outside of tags is copied to the formatted output. To specify brackets for the output use "<<" for '<' and ">>" for '>'.
cNumberOfTagsPresentis a number of different tags specified in the format string which is equal to a number of elements in the pTagsParams array of TAG_DESCRIPTION_PARAM_W structures.
[in]pTagsParamsis an array of TAG_DESCRIPTION_PARAM_W structures containing information for the parser to retrieve strings associated with each tag and to replace the tag in the input by it.
Returns
On success the function returns a pointer to the allocated memory holding the string constructed according to the specified format. The returned string buffer must be freed using one of the free functions defined in the Chusov::Memory or Chusov::String namespace. On failure the function returns NULL. Use GetLastChsvError function to get extended error information.
Remarks
The format sequences "<<" and ">>" produce left and right brackets in the output respectively.
If tags in the format string do not correspond to tags in the pTagsParams vector (comparison is case sensitive), the function fails with the CHSVERROR_INVALID_PARAMETER code.
The Chusov::String namespace provides analogous functions for one-byte ANSI strings for every wide string counterpart. The analogues are declared with an 'A' suffix at the end of the name, e.g. AllocateStringA, FreeStringA, AllocateAndFormatStringByTagsA (but AllocateAndFormatStringVA and AllocateAndFormatStringByTagsVA), etc.
The function itself does not generate exceptions. However, exceptions generated by the callback functions, specified by the pTagsParams, are not handled and passed to the caller.
Warning
User-defined callback functions specified in the pTagsParams elements must return a pointer to memory allocated using functions of this namespace and file, such as AllocateStringW.
See also
AllocateAndFormatStringByTagsW;
AllocateAndFormatStringByTagsVW;
PFNGET_TAG_DESCRIPTION_PROCW;
AllocateStringW;
AllocateUniqueStringW;
AllocateAndFormatStringW;
FreeStringW;
SecureFreeString.