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


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

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


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

示例1: TokenizeQuery

///////////////////////////////////////////////////////////////////////////////
// The query->m_Search is filled out when provided.
//
bool TokenizeQuery( const tstring& queryString, std::vector< tstring >& tokens )
{
    const tregex parseTokens( s_TokenizeQueryString, std::tr1::regex::icase );

    // parse once to tokenize then match again
    tsregex_iterator parseItr( queryString.begin(), queryString.end(), parseTokens );
    tsregex_iterator parseEnd;

    tstring curToken;
    for ( ; parseItr != parseEnd; ++parseItr )
    {
        const std::tr1::match_results<tstring::const_iterator>& tokenizeResults = *parseItr;
        curToken = tokenizeResults[1].matched ? Helium::MatchResultAsString( tokenizeResults, 1 ) : TXT( "" );
        if ( !curToken.empty() )
        {
            tokens.push_back( curToken );
        }
    }

    return !tokens.empty();
}
开发者ID:euler0,项目名称:Helium,代码行数:24,代码来源:VaultSearchQuery.cpp

示例2: UnRegister

bool CRegisterMenu::UnRegister(tstring strAppName, tstring strExt, tstring strMenu)
{
  if (   strAppName.empty()
    || strExt.empty() 
    || strMenu.empty())
    return false;

  if (!UnRegisterExtKey(strExt, strMenu))
  {
    return false;
  }

  // remove '.'
  strExt.erase(std::remove(strExt.begin(), strExt.end(), _T('.')), strExt.end());

  // Uppercase extension
  CStringUtil::MakeUpper(strExt);
  tstring strAppExt = strAppName + _T(".") + strExt;

  return UnRegisterMenu(strAppExt);	
}
开发者ID:envi,项目名称:imagepitcher,代码行数:21,代码来源:registermenu.cpp

示例3: is_fixed_width

 bool is_fixed_width(const tstring & font_name) {
   if (font_name.length() > 31) return false;
 
   HDC dc = GetDC(NULL);
   if (!dc) WIN_EXCEPT("Failed call to GetDC(NULL).");
   
   LOGFONT lf = {};
   lf.lfCharSet = DEFAULT_CHARSET;
   lf.lfPitchAndFamily = 0;
   // already checked length
   TCHAR * ptr = std::copy(font_name.begin(), font_name.end(), lf.lfFaceName); 
   ASSERT(ptr <= (lf.lfFaceName + 32)); (void)ptr;
   
   bool is = false;
   EnumFontFamiliesEx(dc, 
                      &lf, 
                      reinterpret_cast<FONTENUMPROC>(EnumFontFamExProc), 
                      reinterpret_cast<LPARAM>(&is), 
                      0);
   
   ReleaseDC(NULL, dc);
   return is;
 }
开发者ID:HowardJeng,项目名称:conrep,代码行数:23,代码来源:font_util.cpp

示例4: tstring

tstring::size_type
tstring::find(char_type const* s, size_type pos, size_type n) const
{    
	if( size() == 0 ) {
		if( n == 0 )
			return 0;
		else
			return npos;
	}

	TINFRA_ASSERT(pos == npos || pos <= this->size() );

    tstring const other = tstring(s, n, false);
    const_iterator result = std::search(
        begin()+pos,
        end(),
        other.begin(),
        other.end());
    if( result == end() )
        return npos;
    else
        return result - begin(); 
}
开发者ID:icasimpan,项目名称:tinfra,代码行数:23,代码来源:tstring.cpp

示例5: ConvertTString

	std::string ConvertTString(const tstring & value)
	{
		return string(value.begin(), value.end());
	}
开发者ID:GlenDC,项目名称:Lemmings3D,代码行数:4,代码来源:XMLConverter.cpp

示例6: lowercase

tstring lowercase(const tstring &str) {
    tstring result = str;
    transform(str.begin(), str.end(), result.begin(), ToLower());
    return result;
}
开发者ID:151706061,项目名称:nsis-chinese,代码行数:5,代码来源:util.cpp

示例7: matches

bool dir_reader::matches(const tstring& name, const tstring& spec) {
  tstring::const_iterator name_itr = name.begin();
  tstring::const_iterator name_end = name.end();

  tstring::const_iterator spec_itr = spec.begin();
  tstring::const_iterator spec_end = spec.end();

  tstring::const_iterator last_good_spec = spec_end;
  tstring::const_iterator last_good_name = name_end;

  while (name_itr != name_end && spec_itr != spec_end) {
    switch (*spec_itr) {
      case _T('?'):
        // question mark mathes one char
        name_itr++;
        spec_itr++;
        break;

      case _T('*'):
        // double asterisk is the same as a single asterisk
        while (*spec_itr == _T('*')) {
          spec_itr++;
          // asterisk at the end of the spec matches the end of the name
          if (spec_itr == spec_end)
            return true;
        }

        // remember last good name and spec for prematurely stopped asterisk
        last_good_spec = spec_itr;
        last_good_name = name_itr;

        break;

      default:
        // Jim Park: This should work since tolower is templated with Chartype.
        if (::tolower(*name_itr) != ::tolower(*spec_itr)) {
          if (last_good_spec != spec_end) {
            // matched wrong part of the name, try again
            spec_itr = last_good_spec;
            name_itr = ++last_good_name;
          } else {
            // no match and no asterisk to use
            return false;
          }
        } else {
          // remember last good name for prematurely stopped asterisk
          last_good_name = name_itr;

          spec_itr++;
          name_itr++;

          if (spec_itr == spec_end && name_itr != name_end && last_good_spec != spec_end) {
            // asterisk hasn't matched enough, keep matching
            spec_itr = last_good_spec;
          }
        }
        break;
    }
  }

  // skip any redundant asterisks and periods at the end of the name
  while (spec_itr != spec_end) {
    if (*spec_itr != _T('.') && *spec_itr != _T('*')) {
      break;
    }
    spec_itr++;
  }

  // return true only if managed to match everything
  return name_itr == name_end && spec_itr == spec_end;
}
开发者ID:kichik,项目名称:nsis,代码行数:71,代码来源:dirreader.cpp

示例8: Load

bool CPicture::Load(tstring sFilePathName)
{
	bool bResult = false;
	bIsIcon = false;
	lpIcons = NULL;
	//CFile PictureFile;
	//CFileException e;
	FreePictureData(); // Important - Avoid Leaks...

	// No-op if no file specified
	if (sFilePathName.empty())
		return true;

	// Load & initialize the GDI+ library if available
	HMODULE hGdiPlusLib = AtlLoadSystemLibraryUsingFullPath(_T("gdiplus.dll"));
	if (hGdiPlusLib && GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) == Ok)
	{
		bHaveGDIPlus = true;
	}
	// Since we loaded the gdiplus.dll only to check if it's available, we
	// can safely free the library here again - GdiplusStartup() loaded it too
	// and reference counting will make sure that it stays loaded until GdiplusShutdown()
	// is called.
	FreeLibrary(hGdiPlusLib);

	// Attempt to load using GDI+ if available
	if (bHaveGDIPlus)
	{
		pBitmap = new Bitmap(sFilePathName.c_str(), FALSE);
		GUID guid;
		pBitmap->GetRawFormat(&guid);

		if (pBitmap->GetLastStatus() != Ok)
		{
			delete pBitmap;
			pBitmap = NULL;
		}

		// gdiplus only loads the first icon found in an icon file
		// so we have to handle icon files ourselves :(

		// Even though gdiplus can load icons, it can't load the new
		// icons from Vista - in Vista, the icon format changed slightly.
		// But the LoadIcon/LoadImage API still can load those icons,
		// at least those dimensions which are also used on pre-Vista
		// systems.
		// For that reason, we don't rely on gdiplus telling us if
		// the image format is "icon" or not, we also check the
		// file extension for ".ico".
		std::transform(sFilePathName.begin(), sFilePathName.end(), sFilePathName.begin(), ::tolower);
		bIsIcon = (guid == ImageFormatIcon) || (wcsstr(sFilePathName.c_str(), L".ico") != NULL) || (wcsstr(sFilePathName.c_str(), L".cur") != NULL);
		bIsTiff = (guid == ImageFormatTIFF) || (_tcsstr(sFilePathName.c_str(), _T(".tiff")) != NULL);
		m_Name = sFilePathName;

		if (bIsIcon)
		{
			// Icon file, get special treatment...
			if (pBitmap)
			{
				// Cleanup first...
				delete (pBitmap);
				pBitmap = NULL;
				bIsIcon = true;
			}

			CAutoFile hFile = CreateFile(sFilePathName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
			if (hFile)
			{
				BY_HANDLE_FILE_INFORMATION fileinfo;
				if (GetFileInformationByHandle(hFile, &fileinfo))
				{
					lpIcons = new BYTE[fileinfo.nFileSizeLow];
					DWORD readbytes;
					if (ReadFile(hFile, lpIcons, fileinfo.nFileSizeLow, &readbytes, NULL))
					{
						// we have the icon. Now gather the information we need later
						if (readbytes >= sizeof(ICONDIR))
						{
							// we are going to open same file second time so we have to close the file now
							hFile.CloseHandle();

							LPICONDIR lpIconDir = (LPICONDIR)lpIcons;
							if ((lpIconDir->idCount) && ((lpIconDir->idCount * sizeof(ICONDIR)) <= fileinfo.nFileSizeLow))
							{
								try
								{
									bResult = false;
									nCurrentIcon = 0;
									hIcons = new HICON[lpIconDir->idCount];
									// check that the pointers point to data that we just loaded
									if (((BYTE*)lpIconDir->idEntries > (BYTE*)lpIconDir) && 
										(((BYTE*)lpIconDir->idEntries) + (lpIconDir->idCount * sizeof(ICONDIRENTRY)) < ((BYTE*)lpIconDir) + fileinfo.nFileSizeLow))
									{
										m_Width = lpIconDir->idEntries[0].bWidth;
										m_Height = lpIconDir->idEntries[0].bHeight;
										bResult = true;
										for (int i=0; i<lpIconDir->idCount; ++i)
										{
											hIcons[i] = (HICON)LoadImage(NULL, sFilePathName.c_str(), IMAGE_ICON,
																		 lpIconDir->idEntries[i].bWidth,
//.........这里部分代码省略.........
开发者ID:15375514460,项目名称:TortoiseGit,代码行数:101,代码来源:Picture.cpp

示例9: MakeNative

void Path::MakeNative( tstring& path )
{
    std::replace( path.begin(), path.end(), s_InternalPathSeparator, Helium::PathSeparator );
}
开发者ID:andyburke,项目名称:Replicant,代码行数:4,代码来源:Path.cpp

示例10: TCharToOem

std::string TCharToOem(const tstring& tText)
{
  std::string result(tText.begin(), tText.end());
  ::CharToOem(tText.c_str(), &(result[0]));
  return result;
}
开发者ID:chiptuneXT,项目名称:OpenMyTank,代码行数:6,代码来源:tstring.cpp

示例11: wCertName

    StoreCertificate::StoreCertificate(
        Win32CertificateLocation certStoreLocation, 
        Win32CertificateStore certStore,
        const tstring & certName) :
            mStore(0)
    {
        std::wstring wStoreName;
        switch (certStore)
        {
        case Cs_AddressBook:            wStoreName = L"AddressBook";      break;
        case Cs_AuthRoot:               wStoreName = L"AuthRoot";         break;
        case Cs_CertificateAuthority:   wStoreName = L"CA";               break;
        case Cs_Disallowed:             wStoreName = L"Disallowed";       break;
        case Cs_My:                     wStoreName = L"MY";               break;
        case Cs_Root:                   wStoreName = L"Root";             break;
        case Cs_TrustedPeople:          wStoreName = L"TrustedPeople";    break;
        case Cs_TrustedPublisher:       wStoreName = L"TrustedPublisher"; break;
        default:
            RCF_ASSERT(0 && "Invalid certificate store value.");
        }

        DWORD dwFlags = 0;
        switch (certStoreLocation)
        {
        case Cl_CurrentUser:            dwFlags = CERT_SYSTEM_STORE_CURRENT_USER;   break;
        case Cl_LocalMachine:           dwFlags = CERT_SYSTEM_STORE_LOCAL_MACHINE;  break;
        default:
            RCF_ASSERT(0 && "Invalid certificate store location value.");
        }

        mStore = CertOpenStore(
            (LPCSTR) CERT_STORE_PROV_SYSTEM,
            X509_ASN_ENCODING,
            0,
            dwFlags,
            &wStoreName[0]);

        DWORD dwErr = GetLastError();

        RCF_VERIFY(
            mStore, 
            RCF::Exception(
                _RcfError_CryptoApiError("CertOpenStore()"), 
                dwErr, 
                RCF::RcfSubsystem_Os));

        std::wstring wCertName(certName.begin(), certName.end());

        DWORD dwFindType = CERT_FIND_SUBJECT_STR;

        PCCERT_CONTEXT pStoreCert = CertFindCertificateInStore(
            mStore, 
            X509_ASN_ENCODING, 
            0,
            dwFindType,
            wCertName.c_str(),
            NULL);

        dwErr = GetLastError();

        RCF_VERIFY(
            pStoreCert, 
            RCF::Exception(
            _RcfError_CryptoApiError("CertFindCertificateInStore()"), 
            dwErr, 
            RCF::RcfSubsystem_Os));

        mpCert = pStoreCert;
    }
开发者ID:rajkosto,项目名称:deps-rcf,代码行数:69,代码来源:Win32Certificate.cpp

示例12: is_number

bool is_number(const tstring &s)
{
    return !s.empty() && std::find_if(s.begin(),
        s.end(), [](TCHAR c) { return !_istdigit(c); }) == s.end();
}
开发者ID:olsonpm,项目名称:FileSwitcher,代码行数:5,代码来源:FileSwitcher.cpp

示例13: makeUpper

void makeUpper(tstring& str)
{
	transform(str.begin(), str.end(), str.begin(), toupper);
}
开发者ID:5loyd,项目名称:Oh-My-Lovely-Toy,代码行数:4,代码来源:tstring.cpp

示例14: RetrieveText

int32 CBrainMemory::RetrieveText(int64 MeaningID,tstring& Text,bool Nest){

	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = MeaningID;

	//首先得到意义空间的信息
	if(!GetRoomInfo(MeaningID,CurrentRoomValue,RoomType))return 0;

	if(!Nest){
		//首次外部调用时检查MeaningID代表记忆是否为可读的文字信息,嵌套调用则忽略
		if(UnReadable(CurrentRoomValue))return 0;
	}

	//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
    CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
	if(Result.eof())return 0;
    
	CurrentID = Result.getInt64Field(0);
  	if(CurrentID == ROOT_SPACE)return 0;
	CurrentRoomValue = Result.getInt64Field(1);  //总是其他空间的空间识别ID
	
    
	//如果是字符,则可以确定所取文本应该是token
	int ch = IDToChar(CurrentRoomValue);
    if(isascii(ch)){
		TCHAR buf[100]; //暂存token,一个单词99字符应该足够了
		int p = 0;
		buf[p++] = ch;
        
		//继续向上漫游,应该全部都是字符
		for(;;){
			//根据本空间的ID和逻辑明文,找到父空间空间的ID和逻辑明文,
			CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
			if(Result.eof())return 0;
			
			CurrentID = Result.getInt64Field(0);
			//如果得到的空间ID为根空间,则表示找到顶了。
			if(CurrentID == ROOT_SPACE){
				buf[p]='\0';
				_tcsrev(buf);
				
				Text = buf;
				//如果是形容词则加上引号
				if(RoomType == MEMORY_REFERENCE){
					Text.insert(Text.begin(),1,_T('\"'));
					Text+=_T('\"');
				}
				return 1;  //表示得到一个token
			}
			CurrentRoomValue = Result.getInt64Field(1);   
			
			if(p<100) buf[p++]  = IDToChar(CurrentRoomValue);
		}
	}
		
    //不是字符,则需要嵌套处理,然后根据返回值添加标点符号
	int32 n = 0;

	vector<tstring> StrList;
	for(;;){
		
		tstring s;
		n = RetrieveText(CurrentRoomValue,s,false);
		
		StrList.push_back(s);
		
		//继续向上漫游,根据本空间的ID和逻辑明文,找到父空间空间的ID和逻辑明文,
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return 0;
		
		CurrentID = Result.getInt64Field(0);
		//如果得到的空间ID为根空间,则表示找到顶了。
		if(CurrentID == ROOT_SPACE)break;
		
		CurrentRoomValue = Result.getInt64Field(1);   		
	}

	TCHAR flag=_T(' ');
	if(n==1){ //子句,token之间应该有空格
			flag  = _T(' ');
	}
	else if(n==2){ //句子,子句之间有逗号
			flag = _T(',');
	}
	else if(n ==3){ //段落,句子之间有句号
			flag = _T('.');
	} 
    else if(n== 4){//文本,段落之间要分行
            flag = _T('\n');			
	}
	assert(n<5);
	

	vector<tstring>::reverse_iterator It = StrList.rbegin();
	while(It != StrList.rend()){
		Text += *It;
		if(Text.size()){ 
			TCHAR& ch =  Text[Text.size()-1];
            if(!ispunct(ch)){
				Text += flag;
//.........这里部分代码省略.........
开发者ID:GMIS,项目名称:GMIS,代码行数:101,代码来源:BrainMemory.cpp

示例15: FormatEmoticonsAndLinks

void ChatCtrl::FormatEmoticonsAndLinks(tstring& sMsg, tstring& sMsgLower, LONG lSelBegin, bool bUseEmo) {
	if(!sMsg.size())
		return;
	LONG lSelEnd = lSelBegin + sMsg.size();

	// hightlight all URLs and make them clickable
	for(size_t i = 0; i < (sizeof(protocols) / sizeof(protocols[0])); ++i) {
		size_t linkStart = sMsgLower.find(protocols[i]);
		bool isMagnet = (protocols[i] == _T("magnet:?"));
		while(linkStart != tstring::npos) {
			size_t linkEnd = linkStart + protocols[i].size();
			
			try {
				// TODO: complete regexp for URLs
				std::tr1::wregex reg;
//[+]PPA Исправил регулярное выражение для коррктного поиска урлов в VC++ 2010 (пример урла - magnet:?xt=urn:tree:tiger:V3LVT4CSASPLNHRG6DOORAD2SDSBBANIKEI7XHI&xl=260524251&dn=cstrike_full_v.35_(4156).exe  )
				if(isMagnet) // magnet links have totally indifferent structure than classic URL // -/?%&=~#'\\w\\.\\+\\*\\(\\)
					reg.assign(_T("^(\\w)+=[:\\w]+(&(\\w)+=[\\S]*)*[^\\s<>{}\"']+"), std::tr1::regex_constants::icase);
				else
					reg.assign(_T("^([@\\w-]+(\\.)*)+(:[\\d]+)?(/[\\S]*)*[^\\s<>{}\"']+"), std::tr1::regex_constants::icase);
					
				tstring::const_iterator start = sMsg.begin();
				tstring::const_iterator end = sMsg.end();
				std::tr1::match_results<tstring::const_iterator> result;

				if(std::tr1::regex_search(start + linkEnd, end, result, reg, std::tr1::regex_constants::match_default)) {
					dcassert(!result.empty());
					
					 linkEnd += result.length(0);
					 SetSel(lSelBegin + linkStart, lSelBegin + linkEnd);
					if(isMagnet) {
						tstring cURL = ((tstring)(result[0]));
						tstring::size_type dn = cURL.find(_T("dn="));
						if(dn != tstring::npos) {
							string sFileName = Util::encodeURI(Text::fromT(cURL).substr(dn + 3), true);
							int64_t filesize = Util::toInt64(Text::fromT(cURL.substr(cURL.find(_T("xl=")) + 3, cURL.find(_T("&")) - cURL.find(_T("xl=")))));
							tstring shortLink = Text::toT(sFileName) + _T(" (") + Util::formatBytesW(filesize) + _T(")");

							sMsg.replace(linkStart, linkEnd - linkStart, shortLink.c_str());
							std::transform(&sMsgLower.replace(linkStart, linkEnd - linkStart, shortLink.c_str())[linkStart], &sMsgLower[linkEnd], &sMsgLower[linkStart], _totlower);

							setText(shortLink);
							linkEnd = linkStart + shortLink.size();
							SetSel(lSelBegin + linkStart, lSelBegin + linkEnd);
							magnets[shortLink] = _T("magnet:?") + cURL;
					}
				}
					SetSelectionCharFormat(WinUtil::m_TextStyleURL);
				}
			} catch(...) {
			}
			
			linkStart = sMsgLower.find(protocols[i], linkEnd);			
		}
	}

	// insert emoticons
	if(bUseEmo && emoticonsManager->getUseEmoticons()) {
		const Emoticon::List& emoticonsList = emoticonsManager->getEmoticonsList();
		tstring::size_type lastReplace = 0;
		uint8_t smiles = 0;

		while(true) {
			tstring::size_type curReplace = tstring::npos;
			Emoticon* foundEmoticon = NULL;

			for(Emoticon::Iter emoticon = emoticonsList.begin(); emoticon != emoticonsList.end(); ++emoticon) {
				tstring::size_type idxFound = sMsg.find((*emoticon)->getEmoticonText(), lastReplace);
				if(idxFound < curReplace || curReplace == tstring::npos) {
					curReplace = idxFound;
					foundEmoticon = (*emoticon);
				}
			}

			if(curReplace != tstring::npos && smiles < MAX_EMOTICONS) {
				CHARFORMAT2 cfSel;
				cfSel.cbSize = sizeof(cfSel);

				lSelBegin += (curReplace - lastReplace);
				lSelEnd = lSelBegin + foundEmoticon->getEmoticonText().size();
				SetSel(lSelBegin, lSelEnd);

				GetSelectionCharFormat(cfSel);
				if(!(cfSel.dwEffects & CFE_LINK)) {
					CImageDataObject::InsertBitmap(GetOleInterface(), foundEmoticon->getEmoticonBmp(cfSel.crBackColor));

					++smiles;
					++lSelBegin;
				} else lSelBegin = lSelEnd;
				lastReplace = curReplace + foundEmoticon->getEmoticonText().size();
			} else break;
		}
	}

}
开发者ID:Dimetro83,项目名称:DC_DDD,代码行数:95,代码来源:ChatCtrl.cpp


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