Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpiCore)  1.26.2
UtilWchar16
Collaboration diagram for UtilWchar16:

Functions

size_t wcslen16 (const WCHAR16 *src)
 
WCHAR16wcschr16 (const WCHAR16 *src, WCHAR16 character)
 
int wcsncmp16 (const WCHAR16 *src1, const WCHAR16 *src2, size_t len)
 
int wcscmp16 (const WCHAR16 *src1, const WCHAR16 *src2)
 
WCHAR16wcscpy16 (WCHAR16 *dst, const WCHAR16 *src)
 
WCHAR16wcsncpy16 (WCHAR16 *dst, const WCHAR16 *src, size_t len)
 
WCHAR16wcscat16 (WCHAR16 *dst, const WCHAR16 *src)
 
WCHAR16wcsncat16 (WCHAR16 *dst, const WCHAR16 *src, size_t len)
 
WCHAR16wcsdup16 (const WCHAR16 *src)
 
int wcsfind16 (const WCHAR16 *s, const WCHAR16 *t, const int pos=0)
 
int wcsspn16 (const WCHAR16 *src1, const WCHAR16 *src2)
 
WCHAR16wcspbrk16 (const WCHAR16 *src1, const WCHAR16 *src2)
 
WCHAR16wcstok_r16 (WCHAR16 *s1, const WCHAR16 *s2, WCHAR16 **context)
 
WCHAR16wcsstr16 (WCHAR16 *src1, WCHAR16 *src2)
 
const WCHAR16wcsstr16 (const WCHAR16 *src1, const WCHAR16 *src2)
 
int wtoi16 (const WCHAR16 *src)
 
size_t wcstombs16 (char *dst, const WCHAR16 *src, size_t len)
 
size_t mbstowcs16 (WCHAR16 *dst, const char *src, size_t len)
 
char * _wcstombs16 (char *dst, const WCHAR16 *src, size_t len)
 
WCHAR16_mbstowcs16 (WCHAR16 *dst, const char *src, size_t len)
 
template<typename T >
WCHAR16itow16_binary (T src, WCHAR16 *dst, const size_t len)
 

Detailed Description

This module contains some useful functions and macros for handling of WCHAR16 strings. Use these routines on platforms which have no built-in support for <wchar.h> library or when sizeof(wchar_t) != 2.

Please note that this piece of source code is not directly part of the MLPI. You do not need this file to program against the MLPI. Nevertheless, at least parts of this file have been considered to be somewhat useful when using or learning to use MLPI functionality. It is therefore included without any support, but to act as sample code and source of inspiration.

Function Documentation

size_t wcslen16 ( const WCHAR16 src)
inline

Function determines the length of the WCHAR16 string (without the NULL terminator).

Parameters
[in]srcWCHAR16 string.
Returns
The length of the WCHAR16 string.

Definition at line 115 of file wchar16.h.

Referenced by utilParameterParseIdn(), wcsdup16(), and wcsstr16().

Here is the caller graph for this function:

WCHAR16* wcschr16 ( const WCHAR16 src,
WCHAR16  character 
)
inline

Function searches a WCHAR16 character in a WCHAR16 string.

Parameters
[in]srcWCHAR16 string.
[in]characterWCHAR16 character to be located.
Returns
Pointer to the first occurrence of character in src. If character is not found, the function returns a NULL pointer.

Definition at line 133 of file wchar16.h.

Referenced by utilParameterParseIdn().

Here is the caller graph for this function:

int wcsncmp16 ( const WCHAR16 src1,
const WCHAR16 src2,
size_t  len 
)
inline

Function compares two WCHAR16 strings up to a certain length with each other.

Parameters
[in]src1WCHAR16 string to be compared.
[in]src2WCHAR16 string to be compared.
[in]lenMaximum number of characters to compared
Returns
Returns an integral value indicating the relationship between the WCHAR16 strings:
A zero value indicates that the characters compared in both strings form the same string.
A value greater than zero indicates that the first character that does not match has a greater value in src1 than in src2; And a value less than zero indicates the opposite.

Definition at line 158 of file wchar16.h.

int wcscmp16 ( const WCHAR16 src1,
const WCHAR16 src2 
)
inline

Function compares two WCHAR16 strings with each other.

Parameters
[in]src1WCHAR16 sting to be compared.
[in]src2WCHAR16 sting to be compared.
Returns
Returns an integral value indicating the relationship between the WCHAR16 strings:
A zero value indicates that both are considered equal.
A value greater than zero indicates that the first WCHAR16 character that does not match has a greater value in src1 than in src2; And a value less than zero indicates the opposite.

Definition at line 179 of file wchar16.h.

WCHAR16* wcscpy16 ( WCHAR16 dst,
const WCHAR16 src 
)
inline

Function copies a WCHAR16 string.

Parameters
[out]dstPointer to the destination array, where the content is to be copied.
[in]srcWCHAR16 string to be copied.
Returns
Pointer to destination string is returned.

Definition at line 210 of file wchar16.h.

Referenced by utilParameterParseIdn(), and wcsdup16().

Here is the caller graph for this function:

WCHAR16* wcsncpy16 ( WCHAR16 dst,
const WCHAR16 src,
size_t  len 
)
inline

Function copies a specified number of WCHAR16 characters of a WCHAR16 string.

Parameters
[out]dstPointer to the destination array, where the content is to be copied.
[in]srcWCHAR16 string to be copied.
[in]lenMaximum number of characters to be copied from src.
Returns
Pointer to destination string is returned.

Definition at line 224 of file wchar16.h.

WCHAR16* wcscat16 ( WCHAR16 dst,
const WCHAR16 src 
)
inline

Function appends a WCHAR16 string to another.

Parameters
[out]dstPointer to the destination array, which should contain a WCHAR16 string, and be large enough to contain the concatenated resulting string, including the additional NULL terminator.
[in]srcWCHAR16 string to be appended. This should not overlap dst.
Returns
Pointer to destination string is returned.

Definition at line 246 of file wchar16.h.

Referenced by utilParameterParseIdn().

Here is the caller graph for this function:

WCHAR16* wcsncat16 ( WCHAR16 dst,
const WCHAR16 src,
size_t  len 
)
inline

Function appends a WCHAR16 string with a certain length to another.

Parameters
[out]dstPointer to the destination array, which should contain a WCHAR16 string, and be large enough to contain the concatenated resulting string, including the additional NULL terminator.
[in]srcWCHAR16 string to be appended.
[in]lenMaximum number of characters to be appendend.
Returns
Pointer to destination string is returned.

Definition at line 265 of file wchar16.h.

WCHAR16* wcsdup16 ( const WCHAR16 src)
inline

Function appends a WCHAR16 string with a certain length to another.

Parameters
[in]srcWCHAR16 string.
Returns
Pointer to the storage location for the copied string or NULL if storage cannot be allocated.

Definition at line 285 of file wchar16.h.

References wcscpy16(), and wcslen16().

Here is the call graph for this function:

int wcsfind16 ( const WCHAR16 s,
const WCHAR16 t,
const int  pos = 0 
)
inline

Function to determine the positon of one string in another.

Parameters
[in]sWCHAR16 string to be scanned.
[in]tWCHAR16 string to be searched in s.
[in]posPosition in s where the search should start.
Returns
The position of the first character of the first match of t in s after the startpositon. If a string is empty or the startpositon is smaller than zero, -2 is returned. If the function call failed, -1 is returned.

Definition at line 301 of file wchar16.h.

int wcsspn16 ( const WCHAR16 src1,
const WCHAR16 src2 
)
inline

Function to determine the length of the matching WCHAR16 string.

Parameters
[in]src1WCHAR16 string to be scanned.
[in]src2WCHAR16 string containing the characters to match.
Returns
The length of the initial portion of src1 containing only WCHAR16 charactes that appear in src2. Therefore, if all of the WCHAR16 characters in src1 are in src2, the function returns the length of the entire src1 WCHAR16 string, and if the first WCHAR16 in src1 is not in src2, the function returns zero.

Definition at line 328 of file wchar16.h.

Referenced by wcstok_r16().

Here is the caller graph for this function:

WCHAR16* wcspbrk16 ( const WCHAR16 src1,
const WCHAR16 src2 
)
inline

Function scans WCHAR16 strings for characters in specified character sets.

Parameters
[in]src1WCHAR16 string to be scanned.
[in]src2WCHAR16 string containing the characters to match.
Returns
Pointer to the first occurrence of any character from src2 in src1, or a NULL pointer if the two string arguments have no characters in common.

Definition at line 350 of file wchar16.h.

Referenced by wcstok_r16().

Here is the caller graph for this function:

WCHAR16* wcstok_r16 ( WCHAR16 s1,
const WCHAR16 s2,
WCHAR16 **  context 
)
inline

Function to disassemble a WCHAR16 string for certain WCHAR16 characters. A sequence of calls to this function split s1 into tokens, which are sequences of contiguous WCHAR16 characters separated by any of the WCHAR16 characters that are part of the delimiter.

Parameters
[in]s1WCHAR16 string containing token or tokens.
[in]s2Set of delimiter characters.
[out]contextUsed to store position information.
Returns
Pointer to the next Token found in s1. NULL is returned when no more tokens are found. Each call modifies s1 by substituting a NULL character for the first delimiter that occurs after the returned token.

Definition at line 375 of file wchar16.h.

References wcspbrk16(), and wcsspn16().

Referenced by utilLogicGetSymbolList().

Here is the call graph for this function:

Here is the caller graph for this function:

WCHAR16* wcsstr16 ( WCHAR16 src1,
WCHAR16 src2 
)
inline

Function searches for a specific WCHAR16 string sequence in a WCHAR16 string.

Parameters
[in]src1WCHAR16 string to be scanned.
[in]src2WCHAR16 string containing the characters to match.
Returns
Pointer to the first occurrence in src1 of the entire sequence of characters specified in src2, or NULL if the sequence is not present in src1.

Definition at line 403 of file wchar16.h.

References wcslen16().

Here is the call graph for this function:

const WCHAR16* wcsstr16 ( const WCHAR16 src1,
const WCHAR16 src2 
)
inline

Function searches for a specific WCHAR16 string sequence in a WCHAR16 string.

Parameters
[in]src1WCHAR16 string to be scanned.
[in]src2WCHAR16 string containing the characters to match.
Returns
Pointer to the first occurrence in src1 of the entire sequence of characters specified in src2, or NULL if the sequence is not present in src1.

Definition at line 418 of file wchar16.h.

References wcslen16().

Here is the call graph for this function:

int wtoi16 ( const WCHAR16 src)
inline

Function converts a WCHAR16 string to integer.

Parameters
[in]srcWCHAR16 string to be converted.
Returns
Integer value produced by interpreting the input characters as a number. The return value is 0, if the input cannot be converted to integer.

Definition at line 432 of file wchar16.h.

Referenced by utilParameterParseIdn().

Here is the caller graph for this function:

size_t wcstombs16 ( char *  dst,
const WCHAR16 src,
size_t  len 
)
inline

Function translates WCHAR16 characters from the sequence pointed by src to the multibyte equivalent sequence (which is stored at the array pointed by dst), up until either len bytes have been translated or until a WCHAR16 character translates into a NULL character.

Parameters
[out]dstPointer to an array of char elements long enough to contain the resulting sequence.
[in]srcWCHAR16 string to be translated.
[in]lenMaximum number of bytes to be written to dst.
Returns
The number of bytes written to dst, not including the eventual ending NULL-character. If a WCHAR16 character that does not correspond to a valid multibyte character is encountered, a -1 value is returned.

Definition at line 449 of file wchar16.h.

Referenced by _wcstombs16().

Here is the caller graph for this function:

size_t mbstowcs16 ( WCHAR16 dst,
const char *  src,
size_t  len 
)
inline

Function converts a sequence of multibyte characters to a corresponding sequence of WCHAR16 characters.

Parameters
[out]dstPointer to the address of a sequence of WCHAR16 characters.
[in]srcPointer to the address of a sequence of mulitybyte characters.
[in]lenThe number of multibyte characters to convert.
Returns
The number of converted multibyte characters. If the dst argument is NULL, the function returns the required size of the destination string. If an invalid multibyte character is encountered, it returns -1.

Definition at line 473 of file wchar16.h.

Referenced by _mbstowcs16(), utilParameterParseIdn(), and utilParameterParseSercosTimeToString().

Here is the caller graph for this function:

char* _wcstombs16 ( char *  dst,
const WCHAR16 src,
size_t  len 
)
inline

Function translates WCHAR16 characters from the sequence pointed by src to the multibyte equivalent sequence (which is stored at the array pointed by dst), up until either len bytes have been translated or until a WCHAR16 character translates into a NULL character.

Parameters
[out]dstPointer to an array of char elements long enough to contain the resulting sequence.
[in]srcWCHAR16 string to be translated.
[in]lenMaximum number of bytes to be written to dst.
Returns
Pointer to dst.

Definition at line 497 of file wchar16.h.

References wcstombs16().

Here is the call graph for this function:

WCHAR16* _mbstowcs16 ( WCHAR16 dst,
const char *  src,
size_t  len 
)
inline

Function converts a sequence of multibyte characters to a corresponding sequence of WCHAR16 characters.

Parameters
[out]dstPointer to the address of a sequence of WCHAR16 characters.
[in]srcPointer to the address of a sequence of mulitybyte characters.
[in]lenThe number of multibyte characters to convert.
Returns
Pointer to dst.

Definition at line 510 of file wchar16.h.

References mbstowcs16().

Here is the call graph for this function:

template<typename T >
WCHAR16* itow16_binary ( src,
WCHAR16 dst,
const size_t  len 
)

Function to convert a data type to a binary string. (UCHAR) 0xC => "1010".

Parameters
[in]srcThis data (of type T) will be converted to a binary string.
[out]dstDestination to store string (must be greater than the number of bits src has).
[in]lenSize of available storage.
Returns
Pointer to the destination string.

Definition at line 524 of file wchar16.h.