当前位置: 首页>>代码示例>>C++>>正文


C++ _tstring::size方法代码示例

本文整理汇总了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;
}
开发者ID:Bia10,项目名称:clrn,代码行数:28,代码来源:UserInfo.cpp

示例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);
	}
}
开发者ID:Bia10,项目名称:clrn,代码行数:25,代码来源:XmlParser.cpp

示例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
}
开发者ID:myd7349,项目名称:Ongoing-Study,代码行数:62,代码来源:main.cpp

示例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;
}
开发者ID:mosunovpa,项目名称:Projects,代码行数:18,代码来源:fileutils.cpp

示例5: AppendContent

void CHttpData::AppendContent(const _tstring & sContent)
{
	SCOPED_LOG_FUNCTION

	AppendContent(sContent.c_str(), sContent.size());
}
开发者ID:Bia10,项目名称:clrn,代码行数:6,代码来源:HttpData.cpp


注:本文中的_tstring::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。