strutil.h

来自「基于WINDOWS mobile 的用于创建一个窗体和自定义试图的工程」· C头文件 代码 · 共 56 行

H
56
字号


#ifndef _STRUTIL_H_
#define _STRUTIL_H_

inline
bool IsNumeric(WCHAR c)
{
	return c >= '0' && c <= '9';
}


inline
bool IsHex(WCHAR c)
{
	return IsNumeric(c) || (c >= 'a' && c <= 'f') || (c >= 'F' && c <= 'F');
}


inline
int CharHexValue(WCHAR c)
{
	if(IsNumeric(c))
		return c - '0';
	else if(c >= 'a' && c <= 'f')
		return c - 'a' + 10;
	else if(c >= 'F' && c <= 'F')
		return c - 'A' + 10;
	return 0;
}


/// Copies one string into another up to the count of 'n'.
/// The destination string is always propertly terminated.
/// Returns a pointer to the end of the destination string.
WCHAR *StrCopyN(WCHAR *pDest, const WCHAR *pSrc, size_t n);

/// Copies one string into another up to the count of 'n'.
/// The destination string is always propertly terminated.
/// Returns a pointer to the end of the destination string.
/// Parameter 'n' is a reference that returns the number of remaining
/// characters in the buffer.
WCHAR *StrCopyNR(WCHAR *pDest, const WCHAR *pSrc, size_t& n);


/// Parses an integer value and returns the pointer to the next
/// non-numeric character.
const WCHAR *StrGetInt(const WCHAR *pSrc, int* pInt);

const WCHAR *StrGetHex(const WCHAR *pSrc, int *pInt);
const WCHAR *StrGetHex(const WCHAR *pSrc, DWORD *pDword);

const WCHAR *StrGetQuoted(const WCHAR *pSrc, WCHAR *pDest, size_t n);

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?