本文整理汇总了C++中_tstring::size方法的典型用法代码示例。如果您正苦于以下问题:C++ _tstring::size方法的具体用法?C++ _tstring::size怎么用?C++ _tstring::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_tstring
的用法示例。
在下文中一共展示了_tstring::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsUserCredentialsValid
const bool CUserInfo::IsUserCredentialsValid(const _tstring & sLogin, const _tstring & sPassword, _tstring& sPasswordHash) const
{
if (sLogin.empty() || sPassword.empty())
return false;
// Get user password hash
std::vector< unsigned char > vecCredentials;
vecCredentials.reserve(sLogin.size() + sPassword.size());
std::copy(sLogin.begin(), sLogin.end(), std::back_inserter(vecCredentials));
std::copy(sPassword.begin(), sPassword.end(), std::back_inserter(vecCredentials));
sPasswordHash = cmn::CCrypto::CalcMD5(&vecCredentials.front(), vecCredentials.size());
boost::mutex::scoped_lock Lock(m_mxData);
for (const auto& User : m_vecUsers)
{
if (!boost::algorithm::iequals(User.sLogin, sLogin))
continue;
if (!boost::algorithm::iequals(User.sPasswordHash, sPasswordHash))
continue;
return true;
}
return false;
}
示例2: GetTagAttributes
void CXmlParser::GetTagAttributes(CXmlNode& Node, const _tstring& sTag)
{
// У узла нет атрибутов
if (sTag.find('=') == _tstring::npos)
return;
TCHAR * itStart = const_cast< TCHAR * > (&sTag[0]);
const TCHAR * itEnd = &sTag[sTag.size()];
while (itStart < itEnd)
{
// Ищем начало имени
const TCHAR * itNameStart = std::find(static_cast< const TCHAR * > (itStart), itEnd, ' ') + 1;
// Ищем разделитель "="
const TCHAR * itSplitter = std::find(static_cast< const TCHAR * > (itStart), itEnd, '=');
// Ищем окончание значения
const TCHAR * itValueEnd = std::find(itSplitter + 2, itEnd, '\"');
Node.Data[_tstring(itNameStart, itSplitter)] = _tstring(itSplitter + 2, itValueEnd);
itStart = const_cast< TCHAR * > (itValueEnd + 1);
}
}
示例3: dump
/*
In python:
>>> '海阔天空'.encode('utf-16')
b'\xff\xfewm\x14\x96)Yzz'
>>> '海阔天空'.encode('utf-16-le')
b'wm\x14\x96)Yzz'
>>> '海阔天空'.encode('utf-16-be')
b'mw\x96\x14Y)zz'
>>> chr(0x7a)
'z'
>>> chr(0x59)
'Y'
Output of this program: (Unicode mode)
GB2312: 海阔天空
77 6d 14 96 29 59 7a 7a
UTF-8 without BOM: 娴烽様澶╃┖
34 5a fd 70 d8 69 b6 6f 43 25 16 25
UTF-8 with BOM: 海阔天空
77 6d 14 96 29 59 7a 7a
UTF-16 BE: 海阔天空
77 6d 14 96 29 59 7a 7a
UTF-16 LE: 海阔天空
77 6d 14 96 29 59 7a 7a
So, windows uses UTF-16-LE to represent a string in UNICODE mode.
In non-unicode mode, cp936 is used.
*/
void dump(const _tstring &str)
{
std::size_t wpos = str.rfind(_T(' '));
if (_tstring::npos == wpos)
{
return;
}
const byte *beg = reinterpret_cast<const byte *>(str.c_str() + wpos + 1);
const byte *end = reinterpret_cast<const byte *>(str.c_str() + str.size());
#if 0
_tcout << std::hex;
std::ostream_iterator<byte, _TCHAR> oit(_tcout, _T(" ")); // Caution
std::copy(beg, end, oit);
_tcout << std::dec << std::endl;
#else
_tcout << std::setfill(_T('0')) << std::hex;
for (const byte *p = beg; p != end; ++p)
{
if (*p <= 0x7f && std::isprint(static_cast<char>(*p)))
{
_tcout << static_cast<char>(*p);
}
else
{
// In non-unicode mode, if we want to print the value of '*p'
// in hexadecimal format, we have to cast it into an integer.
_tcout << _T("\\x") << std::setw(2) << static_cast<int>(*p);
}
}
_tcout << std::setfill(_T(' ')) << std::dec << std::endl;
#endif
}
示例4: Write
BOOL fileutils::Write(LPCTSTR szFilepath, _tstring s)
{
BOOL res = 0;
if(szFilepath != NULL)
{
HANDLE hFile = ::CreateFile(szFilepath, GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
::SetFilePointer(hFile,0,0,FILE_END);
DWORD written;
std::string ns = strutils::toNarrowString(s.c_str(), (int)s.size());
res = ::WriteFile(hFile, ns.c_str(), (DWORD)ns.size(), &written, NULL);
::CloseHandle(hFile);
}
}
return res;
}
示例5: AppendContent
void CHttpData::AppendContent(const _tstring & sContent)
{
SCOPED_LOG_FUNCTION
AppendContent(sContent.c_str(), sContent.size());
}