本文整理汇总了C++中hm::String::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ String::GetLength方法的具体用法?C++ String::GetLength怎么用?C++ String::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hm::String
的用法示例。
在下文中一共展示了String::GetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: put_VacationMessageExpiresDate
STDMETHODIMP InterfaceAccount::put_VacationMessageExpiresDate(BSTR newVal)
{
try
{
if (!m_pObject)
return GetAccessDenied();
HM::String string = newVal;
// Validate input date.
if (string.Left(4) == _T("0000"))
string = "";
if (string.GetLength() == 0)
string = Time::GetCurrentDate();
else if (string.GetLength() != 10 || !Time::IsValidSystemDate(string))
return COMError::GenerateError("Invalid auto-reply expiry date");
m_pObject->SetVacationExpiresDate(string);
return S_OK;
}
catch (...)
{
return COMError::GenerateGenericMessage();
}
}
示例2: _GetHashRaw
AnsiString HashCreator::_GetHashRaw(const unsigned char *input, int inputLength, HashCreator::RequestedEncoding encoding)
{
int digestLength = 0;
switch (_hashType)
{
case SHA1:
digestLength = SHA_DIGEST_LENGTH;
break;
case SHA256:
digestLength = SHA256_DIGEST_LENGTH;
break;
case MD5:
digestLength = MD5_DIGEST_LENGTH;
break;
}
unsigned char *results = new unsigned char[digestLength];
switch (_hashType)
{
case SHA1:
{
SHA_CTX context;
SHA1_Init(&context);
SHA1_Update(&context, input, inputLength);
SHA1_Final(results, &context);
break;
}
case MD5:
{
MD5_CTX context;
MD5_Init(&context);
MD5_Update(&context, input, inputLength);
MD5_Final(results, &context);
break;
}
case SHA256:
{
SHA256_CTX context;
SHA256_Init(&context);
SHA256_Update(&context, input, inputLength);
SHA256_Final(results, &context);
break;
}
}
HM::String retVal;
if (encoding == hex)
{
char *s = new char[digestLength*2+1];
for (int i=0; i<digestLength; i++)
sprintf(s+i*2, "%02x", results[i]);
s[digestLength*2]='\0';
retVal = s;
delete [] s;
}
else if (encoding == base64)
{
MimeCodeBase64 encoder;
encoder.SetInput((const char*) results, digestLength, true);
AnsiString sEncodedValue;
encoder.GetOutput(sEncodedValue);
retVal = sEncodedValue;
retVal = retVal.Mid(0, retVal.GetLength()-2);
}
delete [] results;
return retVal;
}