chsvlib
chsv helper source code

◆ ConstructPlatformException() [3/4]

void ConstructPlatformException ( platform_code_t  nPlatformCode,
GetDescriptionFn &&  fnGetDescription,
const CharType *restrict  pszDescription,
DescriptionFormatParams ...  formatting_params 
)
protectednoexcept

A template function performing a construction of the class template instantiation.

Template Parameters
CharTypeis a type of the description to be set which is either char or wchar_t.
GetDescriptionFnis a type of the function object mapping the specified platform error code to the corresponding description. The default-constructed objects of the type should support the parentheses operator receiving a numeric error code of the GetDescriptionFn type as its only parameter and mapping it to the corresponding zero-terminated wide string description. The description string is owned by the instantiation of the class template and is freed by a call to the Chusov::String::FreeStringW function. Therefore, the operator of the function object must allocated the returned description using one of the functions defined is the Chusov::Memory namespace. Also, the function object may return NULL on failure causing generation of unspecified description saying that the description is absent.
DescriptionFormatParamsDeduced types of additional arguments passed to the function to format the message.
Parameters
[in]nPlatformCodeis a numeric value of the platform specific error code to be handled by the constructed object.
[in]fnGetDescriptionis a universal reference to a function object of the GetDescriptionFn type, which is used to map the error code to the corresponding wide string description.
[in]pszDescriptionis a wide-string defining the format of the description to be associated with the error code. At first, the formatting is performed according to the rules defined for the Chusov::String::Printf function. The result of this operation is also processed to replace the tags in angle brackets with the corresponding text, as specified for the PlatformException class template.
formatting_paramsis a set of additional parameters, which are specified with respect to the pszDescription string as specified for the Chusov::String::Printf function.