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


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

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


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

示例1: ConcatPaths

/**
	@param sFolder Folder to combine
	@param sPathname Path to combine (probably relative to sFolder)
	@param bAllowAbsoluteOverride true to allow sPathname to have an absolute path, false to make sure it's relative
	@return The combined path
*/
std::tstring ConcatPaths(const std::tstring& sFolder, const std::tstring& sPathname, bool bAllowAbsoluteOverride /* = true */)
{
	// Do we have a folder?
	if (sFolder.empty())
		// No, return the second part alone
		return sPathname;
	// Do we have a path?
	if (sPathname.empty())
		// No, return the first part alone
		return sFolder;

	// Allow overriding paths by using a drive letter and colon (c:) or a UNC path (\\)
	if (bAllowAbsoluteOverride)
		if ((sPathname.size() > 2) && (sPathname[1] == ':') || ((sPathname[0] == '\\') && (sPathname[1] == '\\')))
			return sPathname;

	std::tstring sRet = sFolder;

	// Make sure we have a slash at the end of the folder part
	CHAR c = sFolder[sFolder.size()-1];
	if ((c != '\\') && (c != '/'))
		sRet += _T("\\");

	// Make sure we don't have a slash at the beginning of the path part:
	c = sPathname[0];
	if ((c == '\\') || (c == '/'))
		// We do, jump over it
		sRet += sPathname.substr(1);
	else
		// Just add them
		sRet += sPathname;

	return sRet;
}
开发者ID:syzh120,项目名称:CCPDFConverter,代码行数:40,代码来源:PrinterInstall.cpp

示例2: save_url

bool save_url(HANDLE hNetlib,const std::string &url,const std::tstring &filename)
{
	NETLIBHTTPREQUEST req = {sizeof(req)};
	req.requestType = REQUEST_GET;
	req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
	req.szUrl = const_cast<char*>(url.c_str());

	NETLIBHTTPREQUEST *resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
		reinterpret_cast<WPARAM>(hNetlib), reinterpret_cast<LPARAM>(&req)));

	if (resp)
	{
		bool success = (resp->resultCode == 200);
		if (success)
		{
			// Create folder if necessary
			std::tstring dir = filename.substr(0,filename.rfind('\\'));
			if( _taccess(dir.c_str(),0))
				CreateDirectoryTreeT(dir.c_str());

			// Write to file
			FILE *f = _tfopen(filename.c_str(), _T("wb"));
			fwrite(resp->pData,1,resp->dataLength,f);
			fclose(f);
		}

		CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)resp);
		return success;
	}
	else
		return false;
}
开发者ID:MrtsComputers,项目名称:miranda-ng,代码行数:32,代码来源:utility.cpp

示例3: FindLinkedEmail

IDispatchPtr FindLinkedEmail(IDispatchPtr spDispOutlook, IDispatchPtr spDispNameSpace, Workshare::Mail::Mapi::MapiSession& session, const std::tstring& sMessageId)
{
   if(spDispOutlook == 0)
      throw Workshare::ArgumentNullException(_T("spDispOutlook"), _T("Outlook Application pointer is null."));

   if(spDispNameSpace == 0)
      throw Workshare::ArgumentNullException(_T("spDispNameSpace"), _T("MAPI NameSpace pointer is null."));

   if(sMessageId.empty())
      throw Workshare::ArgumentException(_T("sMessageId"), _T("The message ID of the email to find was not specified."));

   size_t pos = sMessageId.find(_T(';'));
   if(-1 == pos)
      throw Workshare::ArgumentException(_T("sMessageId"), _T("Invalid message ID (should be in format EntryId;SearchKey[;InternetId])"));

   std::tstring sEntryId = sMessageId.substr(0, pos);
   std::tstring sSearchKeyAndInternetId = sMessageId.substr(pos + 1);
   std::tstring sSearchKey;
   std::tstring sInternetId;

   pos = sSearchKeyAndInternetId.find(_T(';'));
   if(-1 != pos)
   {
      sSearchKey = sSearchKeyAndInternetId.substr(0, pos);
      sInternetId = sSearchKeyAndInternetId.substr(pos + 1);
   }
   else
      sSearchKey = sSearchKeyAndInternetId;

   Outlook::_ApplicationPtr spOutlook = spDispOutlook;
   Outlook::_NameSpacePtr spNameSpace = spDispNameSpace;
   IDispatchPtr spLinkedEmail;
   HRESULT hr = spNameSpace->raw_GetItemFromID(_bstr_t(sEntryId.c_str()), vtMissing, &spLinkedEmail);
   if(FAILED(hr))
   {
      std::tstring sStoreId;

      Workshare::Mail::Mapi::FindItemBySearchKey(session, sSearchKey, sEntryId, sStoreId);

      _variant_t vtStoreId(sStoreId.c_str());
      hr = spNameSpace->raw_GetItemFromID(_bstr_t(sEntryId.c_str()), vtStoreId, &spLinkedEmail);
      if(FAILED(hr))
         throw Workshare::Com::ComException(_T("Outlook failed to open email"), hr, spNameSpace);
         //If this fails we could create a function FindItemByInternetId(session, sInternetId, sEntryId, sStoreId);
   }
   return spLinkedEmail;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:47,代码来源:GlobalFunctions.cpp

示例4: GetFileExtension

std::tstring GetFileExtension(const std::tstring& fileName)
{
    size_t extensionPosition = fileName.rfind(_T('.'));	
    if(0 < extensionPosition)
        return fileName.substr(extensionPosition + 1);

    return _T("");
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:8,代码来源:ExtractEmail.cpp

示例5: GetFilenameWithoutExtension

std::tstring GetFilenameWithoutExtension(const std::tstring& fileName)
{
    size_t extensionPosition = fileName.rfind(_T('.'));	
    if(0 < extensionPosition)
        return fileName.substr(0, extensionPosition);

    return fileName;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:8,代码来源:ExtractEmail.cpp

示例6: NormalizedSubject

std::tstring NormalizedSubject(const std::tstring& subject)
{
#pragma warning(disable:4996)
    if(0 == _tcsnicmp(subject.c_str(), _T("Re: "), 4))
        return subject.substr(4);
#pragma warning(default:4996)

    return subject;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:9,代码来源:ExtractEmail.cpp

示例7: save_url

bool facebook_client::save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc)
{
	NETLIBHTTPREQUEST req = {sizeof(req)};
	NETLIBHTTPREQUEST *resp;
	req.requestType = REQUEST_GET;
	req.szUrl = const_cast<char*>(url.c_str());
	req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT | NLHRF_NODUMP;
	req.nlc = nlc;

	resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
		reinterpret_cast<WPARAM>(this->parent->m_hNetlibUser), reinterpret_cast<LPARAM>(&req)));

	bool ret = false;

	if (resp) {
		nlc = resp->nlc;
		parent->debugLogA("@@@@@ Saving avatar URL %s to path %s", url.c_str(), _T2A(filename.c_str()));

		// Create folder if necessary
		std::tstring dir = filename.substr(0,filename.rfind('\\'));
		if (_taccess(dir.c_str(), 0))
			CreateDirectoryTreeT(dir.c_str());

		// Write to file
		FILE *f = _tfopen(filename.c_str(), _T("wb"));
		if (f != NULL) {
			fwrite(resp->pData,1,resp->dataLength,f);
			fclose(f);

			ret = _taccess(filename.c_str(), 0) == 0;
		}

		CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
	} else {
		nlc = NULL;
	}

	return ret;
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:39,代码来源:communication.cpp

示例8: TstringToString

ScriptComponent::ScriptComponent(const std::tstring& filename)												
{
	m_pScript = MyServiceLocator::GetInstance()->GetService<ResourceService>()->Load<LuaScript>(filename);
	auto slashIdx = filename.find_last_of(_T('/'));
	m_ShortFilename = TstringToString(filename.substr(slashIdx+1, filename.find_last_of(_T('.')) - slashIdx - 1));
}
开发者ID:GlenDC,项目名称:tt--Engine,代码行数:6,代码来源:ScriptComponent.cpp


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