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


C++ tstring::length方法代码示例

本文整理汇总了C++中tstring::length方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::length方法的具体用法?C++ tstring::length怎么用?C++ tstring::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tstring的用法示例。


在下文中一共展示了tstring::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: formatIntegerValue

static tstring formatIntegerValue(uint64 value)
{
	typedef tstring::reverse_iterator rev_iter;
	typedef tstring::const_reverse_iterator c_rev_iter;

	const tstring rawResult = Core::format<uint64>(value);

	const size_t  numDigits = (rawResult[0] != TXT('-')) ? rawResult.length() : (rawResult.length()-1);
	const tstring separator = getGroupSeparator();
	const size_t  numSeps = (numDigits-1) / 3;
	const size_t  total = rawResult.length() + (numSeps * separator.length());

	tstring result = tstring(total, TXT(' '));

	c_rev_iter it = rawResult.rbegin();
	c_rev_iter end = rawResult.rend();

	size_t   digits = 0;
	size_t   seps = 0;
	rev_iter output = result.rbegin();

	while (it != end)
	{
		*output++ = *it++;

		if ( ((++digits % 3) == 0) && (seps++ != numSeps) )
			output = std::copy(separator.rbegin(), separator.rend(), output);
	}

	return result;
}
开发者ID:chrisoldwood,项目名称:FarmMonitor,代码行数:31,代码来源:QueryRunner.cpp

示例2: ParseLink

bool CDDELink::ParseLink(const tstring& link, tstring& service, tstring& topic, tstring& item)
{
	size_t serviceBegin = 0;
	size_t serviceEnd = link.find_first_of('|', serviceBegin);

	if ( (serviceEnd == tstring::npos) || (serviceEnd == serviceBegin) )
		return false;

	size_t topicBegin = serviceEnd + 1;
	size_t topicEnd = link.find_first_of('!', topicBegin);

	if ( (topicEnd == tstring::npos) || (topicEnd == topicBegin) )
		return false;

	size_t itemBegin = topicEnd + 1;
	size_t itemEnd = link.length();

	if (itemEnd == itemBegin)
		return false;

	service = link.substr(serviceBegin, serviceEnd - serviceBegin);
	topic   = link.substr(topicBegin,   topicEnd   - topicBegin);
	item    = link.substr(itemBegin,    itemEnd    - itemBegin);

	ASSERT(service.length() != 0);
	ASSERT(topic.length() != 0);
	ASSERT(item.length() != 0);

	return true;
}
开发者ID:chrisoldwood,项目名称:NCL,代码行数:30,代码来源:DDELink.cpp

示例3: PaintHintText

void CGrottoHUD::PaintHintText(const tstring& sHint)
{
	float flTextWidth = glgui::CLabel::GetTextWidth(sHint, sHint.length(), "sans-serif", 18);
	float flFontHeight = glgui::CLabel::GetFontHeight("sans-serif", 18);
	glgui::CBaseControl::PaintRect(GetWidth()/2+200 - 5, GetHeight()/2 - 5, flTextWidth + 10, flFontHeight + 10, Color(50, 50, 50, 150), 2);
	glgui::CLabel::PaintText(sHint, sHint.length(), "sans-serif", 18, GetWidth()/2+200, GetHeight()/2);
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:7,代码来源:hud.cpp

示例4: WideCharToMultiByte

	void tstring2string(const tstring& src, std::string& dst)
	{
#ifdef UNICODE
		{
			char* newStr = "";
			int _len = 0;
			if (!src.empty()) {
				_len = WideCharToMultiByte(CP_UTF8, 0, src.c_str(),
					src.length(), NULL,
					0, NULL, NULL);
				newStr = new char[_len + 1];

				WideCharToMultiByte(CP_UTF8, 0, src.c_str(),
					src.length(), newStr,
					_len, NULL, NULL);

				newStr[_len] = 0; //Null terminator
			}
			dst = newStr;
			delete newStr;
		}
#else
		dst = src;
#endif
	}
开发者ID:oulrich1,项目名称:ConvertStrings,代码行数:25,代码来源:StringConversion.cpp

示例5: ClearDevNames

//
/// Sets the values for the DEVNAMES structure.
//
void
TPrintDialog::TData::SetDevNames(const tstring& driver, const tstring& device, const tstring& output)
{
  ClearDevNames();

  // Calculate the required buffer size, as the number of characters incl. null-terminators,
  // and the resulting total size, in bytes, of the DEVNAMES structure including trailing strings.
  // Then allocate and lock the required amount of global memory.
  //
  const int n = driver.length() + 1 + device.length() + 1 + output.length() + 1; 
  const int size = sizeof(DEVNAMES) + (n * sizeof(tchar));
  HDevNames = ::GlobalAlloc(GHND, size); 
  DevNames = static_cast<DEVNAMES*>(::GlobalLock(HDevNames));
  DevNames->wDefault = false;

  // Calculate the offsets to the strings within DEVNAMES.
  // Then copy the given names into DEVNAMES (actually, behind the fixed part of DEVNAMES).
  //
  // NB! Offsets are in character counts. Here we assume the size of the fixed part of DEVNAMES is divisible 
  // by the character size. Otherwise the driver name will overwrite the last byte of the fixed part.
  // But DEVNAMES is divisible and forever set in stone, so we don't need to consider an odd struct size.
  //
  CHECK(sizeof(DEVNAMES) % sizeof(tchar) == 0); 
  const LPTSTR base = reinterpret_cast<LPTSTR>(DevNames);
  const LPTSTR pDriver = reinterpret_cast<LPTSTR>(DevNames + 1); // Jump past the the fixed part, assuming even struct size.
  const LPTSTR pDevice = pDriver + driver.length() + 1; // Jump past the preceding string, including null-terminator.
  const LPTSTR pOutput = pDevice + device.length() + 1;
  DevNames->wDriverOffset = static_cast<WORD>(pDriver - base);
  DevNames->wDeviceOffset = static_cast<WORD>(pDevice - base);
  DevNames->wOutputOffset = static_cast<WORD>(pOutput - base);
  _tcscpy(pDriver, driver.c_str());
  _tcscpy(pDevice, device.c_str());
  _tcscpy(pOutput, output.c_str());
}
开发者ID:GarMeridian3,项目名称:Meridian59,代码行数:37,代码来源:printdia.cpp

示例6: PostProcessSummary

void XmlTreeView::PostProcessSummary(tstring& str)
{
	// Replace empty strings.
	if (str.empty())
	{
		str = TXT("(empty)");
		return;
	}

	bool bWhitespaceOnly = true;

	// Find if only whitespace characters.
	for (tstring::const_iterator it = str.begin(); ((it != str.end()) && bWhitespaceOnly); ++it)
	{
		if (!tisspace(static_cast<utchar>(*it)))
			bWhitespaceOnly = false;
	}

	// Replace "invisible" strings.
	if (bWhitespaceOnly)
	{
		str = TXT("(whitespace)");
		return;
	}

	// Trim string.
	if (str.length() > App.m_nDefMaxItemLen)
	{
		str.erase(App.m_nDefMaxItemLen, str.length()-App.m_nDefMaxItemLen);

		str += TXT("...");
	}
}
开发者ID:chrisoldwood,项目名称:XMLEdit,代码行数:33,代码来源:XmlTreeView.cpp

示例7: OnSendCommand

void CFTPProtocolOutput::OnSendCommand(const tstring& strCommand)
{
   if( strCommand.length()==0 )
      return;

   if( strCommand.length()>4 && strCommand.substr(5)==_T("PASS ") )
      WriteLine(_T("< PASS **********\n"), RGB(0, 0, 255));
   else
      WriteLine(_T("> ") + CString(strCommand.c_str()) + _T("\n"), RGB(0, 0, 255));
}
开发者ID:Omgan,项目名称:RealFTP.net,代码行数:10,代码来源:FTPProtocolOutput.cpp

示例8: clientDC

//
/// Sets the maximum horizontal extent for the list view window.
//
void
TListBoxView::SetExtent(const tstring& str)
{
  if (str.length() == 0)
    return;

  TClientDC  clientDC(*this);
  TSize extent = clientDC.GetTextExtent(str, str.length());
  extent.cx += 2; // room for focus rectangle

  if (extent.cx > MaxWidth)
    SetHorizontalExtent(MaxWidth = extent.cx);
}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:16,代码来源:listboxview.cpp

示例9: FormatChatLine

void ChatCtrl::FormatChatLine(const tstring& sMyNick, tstring& sText, CHARFORMAT2& cf, bool isMyMessage, const tstring& sAuthor, LONG lSelBegin, bool bUseEmo) {
	// Set text format
	tstring sMsgLower(sText.length(), NULL);
	std::transform(sText.begin(), sText.end(), sMsgLower.begin(), _totlower);

	LONG lSelEnd = lSelBegin + sText.size();
	SetSel(lSelBegin, lSelEnd);
	SetSelectionCharFormat(isMyMessage ? WinUtil::m_ChatTextMyOwn : cf);
	
	// highlight all occurences of my nick
	long lMyNickStart = -1, lMyNickEnd = -1;
	size_t lSearchFrom = 0;	
	tstring sNick(sMyNick.length(), NULL);
	std::transform(sMyNick.begin(), sMyNick.end(), sNick.begin(), _totlower);

	bool found = false;
	while((lMyNickStart = sMsgLower.find(sNick, lSearchFrom)) != tstring::npos) {
		lMyNickEnd = lMyNickStart + (long)sNick.size();
		SetSel(lSelBegin + lMyNickStart, lSelBegin + lMyNickEnd);
		SetSelectionCharFormat(WinUtil::m_TextStyleMyNick);
		lSearchFrom = lMyNickEnd;
		found = true;
	}
	
	if(found) {
		if(	!SETTING(CHATNAMEFILE).empty() && !BOOLSETTING(SOUNDS_DISABLED) &&
			!sAuthor.empty() && (stricmp(sAuthor.c_str(), sNick) != 0)) {
				::PlaySound(Text::toT(SETTING(CHATNAMEFILE)).c_str(), NULL, SND_FILENAME | SND_ASYNC);	 	
        }	
	}

	// highlight all occurences of favourite users' nicks
	FavoriteManager::FavoriteMap ul = FavoriteManager::getInstance()->getFavoriteUsers();
	for(FavoriteManager::FavoriteMap::const_iterator i = ul.begin(); i != ul.end(); ++i) {
		const FavoriteUser& pUser = i->second;

		lSearchFrom = 0;
		sNick = Text::toT(pUser.getNick());
		std::transform(sNick.begin(), sNick.end(), sNick.begin(), _totlower);

		while((lMyNickStart = sMsgLower.find(sNick, lSearchFrom)) != tstring::npos) {
			lMyNickEnd = lMyNickStart + (long)sNick.size();
			SetSel(lSelBegin + lMyNickStart, lSelBegin + lMyNickEnd);
			SetSelectionCharFormat(WinUtil::m_TextStyleFavUsers);
			lSearchFrom = lMyNickEnd;
		}
	}

	// Links and smilies
	FormatEmoticonsAndLinks(sText, sMsgLower, lSelBegin, bUseEmo);
}
开发者ID:Dimetro83,项目名称:DC_DDD,代码行数:51,代码来源:ChatCtrl.cpp

示例10: Execute

bool OdbcCommand::Execute(const tstring & szSQL)
{
	if (!Open())
		return false;

#ifdef USE_SQL_TRACE
	TRACE((szSQL + _T("\n")).c_str());
#endif

	if (!BindParameters())
		return false;

	SQLRETURN result = SQLExecDirect(m_hStmt, (SQLTCHAR *)szSQL.c_str(), szSQL.length());
	if (!(result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO || result == SQL_NO_DATA))
	{
		if (m_odbcConnection != nullptr)
			m_szError = m_odbcConnection->ReportSQLError(SQL_HANDLE_STMT, m_hStmt, (TCHAR *)szSQL.c_str(), _T("Failed to execute statement."));
		else
			m_szError = OdbcConnection::GetSQLError(SQL_HANDLE_STMT, m_hStmt);

		Close();
		return false;
	}

	if (!MoveNext())
		MoveNextSet();

	return true;
}
开发者ID:sailei1,项目名称:knightonline,代码行数:29,代码来源:OdbcCommand.cpp

示例11: Execute

bool OdbcCommand::Execute(const tstring & szSQL)
{
	if (!Open())
		return false;

#ifdef _DEBUG
	OutputDebugString((szSQL + _T("\n")).c_str());
#endif

	if (!BindParameters())
		return false;

	if (!SQL_SUCCEEDED(SQLExecDirect(m_hStmt, (SQLTCHAR *)szSQL.c_str(), szSQL.length())))
	{
		if (m_odbcConnection != NULL)
			m_szError = m_odbcConnection->ReportSQLError(SQL_HANDLE_STMT, m_hStmt, (TCHAR *)szSQL.c_str(), _T("Failed to execute statement."));
		else
			m_szError = OdbcConnection::GetSQLError(SQL_HANDLE_STMT, m_hStmt);

		Close();
		return false;
	}

	if (!MoveNext())
		MoveNextSet();

	return true;
}
开发者ID:66gs,项目名称:snoxd-koserver,代码行数:28,代码来源:OdbcCommand.cpp

示例12: RegisterMenu

bool CRegisterMenu::RegisterMenu(const tstring& strSubKey, const tstring& strValue)
{
  HKEY hKey;
  DWORD strValueSize = strValue.empty() ? 0 : (strValue.length() + 1) * sizeof(TCHAR);

  if (RegOpenKeyEx(HKEY_CLASSES_ROOT, strSubKey.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS )
  {
    if (!strValue.empty())
      RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE*)strValue.c_str(), strValueSize);

    RegCloseKey(hKey);
  }
  else
  {
    DWORD disp = REG_CREATED_NEW_KEY;
    if (RegCreateKeyEx(HKEY_CLASSES_ROOT, strSubKey.c_str(), 
      NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, 
      &hKey, &disp) == ERROR_SUCCESS )
    {
      if (!strValue.empty())
        RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE*)strValue.c_str(), strValueSize);

      RegCloseKey(hKey);
    }
  }

  return true;
}
开发者ID:envi,项目名称:imagepitcher,代码行数:28,代码来源:registermenu.cpp

示例13:

CTokenizer::CTokenizer(const tstring& p_Str, const tstring& p_Delimiters)
{
	const tstring::size_type len = p_Str.length();
	tstring::size_type i = 0;

	while(i < len)
	{
		// eat leading whitespace
		i = p_Str.find_first_not_of(p_Delimiters, i);
		if(i == tstring::npos)
			return;   // nothing left but white space

		// find the end of the token
		tstring::size_type j = p_Str.find_first_of(p_Delimiters, i);

		// push token
		if(j == tstring::npos) 
		{
			m_Tokens.push_back(p_Str.substr(i));
			return;
		} else
			m_Tokens.push_back(p_Str.substr(i, j - i));

		// set up for next loop
		i = j + 1;
	}
}
开发者ID:Ocerus,项目名称:Ocerus,代码行数:27,代码来源:Utils.cpp

示例14: OpenEnv

HRESULT WINAPI GameEnv::OpenEnv(const tstring whichPath)
{
	if (NULL != pInstance) //检查是否已经初始化
	{
		mainEnv = pInstance;
		return E_HANDLE;
	}
	if (_T('\\') == whichPath[whichPath.length() - 1]) //检查结尾反斜杠符
	{
		ErrorHandler(ERROR_RES_Unknown, _T(__FUNCTION__));
		return E_FAIL;
	}
	if (!IsFolderExist(whichPath)) //检查路径是否存在
	{
		ErrorHandler(ERROR_RES_MissingPath, _T(__FUNCTION__));
		return E_FAIL;
	}
	PGameRes pRes = OpenResFiles(whichPath);
	if (NULL != pRes) //检查资源文件完整性
	{
		pInstance = new GameEnv(pRes);
		mainEnv = pInstance;
		return S_OK;
	}
	return E_FAIL;
}
开发者ID:FP-GAME-DEV-TEAM,项目名称:FP_Game,代码行数:26,代码来源:FPEnv.cpp

示例15: inputSlotTime

uint64_t UserInfoSimple::inputSlotTime()
{
	static tstring deftext = _T("00:30");
	
	LineDlg dlg;
	dlg.description = TSTRING(EXTRA_SLOT_TIME_FORMAT);
	dlg.title = TSTRING(EXTRA_SLOT_TIMEOUT);
	dlg.line = deftext;
	
	if (dlg.DoModal() == IDOK)
	{
		deftext = dlg.line;
		unsigned int n = 0;
		for (size_t i = 0; i < deftext.length(); i++) // TODO: cleanup.
		{
			if (deftext[i] == L':') n++;
		}
		unsigned int d, h, m;
		switch (n)
		{
			case 1:
				if (swscanf(deftext.c_str(), L"%u:%u", &h, &m) == 2)
					return (h * 3600 + m * 60);
					
				break;
			case 2:
				if (swscanf(deftext.c_str(), L"%u:%u:%u", &d, &h, &m) == 3)
					return (d * 3600 * 24 + h * 3600 + m * 60);
					
				break;
		}
		::MessageBox(GetForegroundWindow(), CTSTRING(INVALID_TIME_FORMAT), CTSTRING(ERRORS), MB_OK | MB_ICONERROR);
	}
	return 0;
}
开发者ID:craxycat,项目名称:flylinkdc-r5xx,代码行数:35,代码来源:UserInfoSimple.cpp


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