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


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

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


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

示例1: dotCounter

	Filepath::Filepath(const tstring & full_path)
		: m_Path(EMPTY_STRING)
		, m_File(EMPTY_STRING)
	{
		int32 dotCounter(0);
		for(uint32 i = 0; i < full_path.size(); ++i)
		{
			if(full_path[i] == _T('.'))
			{
				++dotCounter;
			}
		}
		if(dotCounter > 1)
		{
			Logger::GetInstance()->Log(LogLevel::Error, 
				_T("Please don't use . in your filename (except for the file extension)"));
		}

		auto index = full_path.find_last_of('/');
		if(index == tstring::npos)
		{
			index = full_path.find_last_of('\\');
		}
		if(index != tstring::npos)
		{
			index += 1;
			m_Path = full_path.substr(0,index);
			m_File = full_path.substr(index, full_path.length() - index);
		}
		else
		{
			m_File = full_path;
		}
	}
开发者ID:AzureCrab,项目名称:StarEngine,代码行数:34,代码来源:Filepath.cpp

示例2: GetFilePath

tstring GetFilePath(tstring FileName){
	tstring::size_type n = FileName.find_last_of(_T('\\'));
	if(n != tstring::npos){
		return FileName.substr(0,n);
	}
	n = FileName.find_last_of(_T('/'));
	if(n == tstring::npos){
		return FileName;
	}
	return FileName.substr(0,n);
};
开发者ID:GMIS,项目名称:GMIS,代码行数:11,代码来源:Space.cpp

示例3: GetFileNoPathName

tstring GetFileNoPathName(tstring s)
{
	tstring::size_type n = s.find_last_of(_T('\\'));
	if(n != tstring::npos){
		return s.substr(n+1);
	}
	n = s.find_last_of(_T('/'));
	if(n == tstring::npos){
		return s;
	}
	return s.substr(n);
}
开发者ID:GMIS,项目名称:GMIS,代码行数:12,代码来源:Space.cpp

示例4: remove_extension

std::string remove_extension(tstring const& filename)
{
	const size_t last_slash = filename.find_last_of("\\/");
	const size_t last_dot = filename.find_last_of('.');
	if( ( last_slash != tstring::npos && last_dot < last_slash) || 
	    ( last_dot == tstring::npos) ||
		( last_dot == filename.size() - 1 )
		) 
	{
		return filename.str();
	} else {
		tstring result = filename.substr(0, last_dot);
		return result.str();
	}
}
开发者ID:zbigg,项目名称:tinfra,代码行数:15,代码来源:path.cpp

示例5: extension

std::string extension(tstring const& filename)
{
    
    size_t last_dot = filename.find_last_of(".");
    if( last_dot == tstring::npos )
        return "";
    
    size_t last_slash = filename.find_last_of("\\/");
    if( last_slash != tstring::npos && last_slash > last_dot )
        // extension is somewhere in path component
        return "";
        
    return filename.substr(last_dot+1).str();
    
}
开发者ID:zbigg,项目名称:tinfra,代码行数:15,代码来源:path.cpp

示例6:

CRegStdBase::CRegStdBase (const tstring& key, bool force, HKEY base, REGSAM sam)
    : CRegBaseCommon<tstring> (key, force, base, sam)
{
    tstring::size_type pos = key.find_last_of(_T('\\'));
    m_path = key.substr(0, pos);
    m_key = key.substr(pos + 1);
}
开发者ID:fabgithub,项目名称:TortoiseGit,代码行数:7,代码来源:Registry.cpp

示例7: removeFileExtension

tstring FileSystem::removeFileExtension( const tstring& fileName )
{
    size_t pos = fileName.find_last_of('.');
    if (pos != tstring::npos)
    {
        return fileName.substr(0, pos);
    }
    return fileName;
}
开发者ID:cpzhang,项目名称:zen,代码行数:9,代码来源:FileSystem.cpp

示例8: basename

std::string basename(tstring const& name)
{
    std::string::size_type p = name.find_last_of("/\\");
    if( p == tstring::npos ) {
        return name.str();
    } else {
        return std::string(name.data()+p+1, name.size()-p-1);
    }
}
开发者ID:zbigg,项目名称:tinfra,代码行数:9,代码来源:path.cpp

示例9: getFileExtension

tstring FileSystem::getFileExtension( const tstring& fileName )
{
    size_t pos = fileName.find_last_of('.');
    if (pos != tstring::npos)
    {
        return fileName.substr(pos + 1, fileName.size() - pos - 1);
    }
    return TEXT("");
}
开发者ID:cpzhang,项目名称:zen,代码行数:9,代码来源:FileSystem.cpp

示例10: ExtractFileExt

    tstring ExtractFileExt(const tstring& path)
    {
        size_t pos = path.find_last_of(_T("\\/."));

        if (pos != tstring::npos && path[pos] == '.')
        {
            return path.substr(pos + 1);
        }
        return _T("");
    }
开发者ID:yellowbigbird,项目名称:bird-self-lib,代码行数:10,代码来源:UtilsFile.cpp

示例11: ExtractFilePath

    //--------------------------------------------------------------------------------------------
    //  Implementation
    //--------------------------------------------------------------------------------------------
    //return path like="xxx/xxx" , without "/" at last.
    tstring ExtractFilePath(const tstring& path)
    {
        size_t pos = path.find_last_of(_T("\\/"));

        if (pos != tstring::npos)
        {
            return path.substr(0, pos);
        }
        return path;
    }
开发者ID:yellowbigbird,项目名称:bird-self-lib,代码行数:14,代码来源:UtilsFile.cpp

示例12: append

int FileAppender::append(const tstring &logMsg)
{
	if(_fs.is_open())
	{
		// need to create a new file?
		if( _multiFiles && _curSize > _maxSize )
		{
			// close current file
			_fs.close();
			ASSERT(!_fs.is_open());

			// make a new log file name: oldfile{time}_index.xx, eg. "mylog_20101229_235959_1.txt"
			__time64_t t;
			_time64( &t );
			struct tm *tt = _localtime64(&t);
			tchar tmString[TIME_BUF_SZIE + 1] = {0};
			_stprintf(tmString, _T("_%04d%02d%02d_%02d%02d%02d_%d"), tt->tm_year + 1900, tt->tm_mon + 1, tt->tm_mday, tt->tm_hour, tt->tm_min, tt->tm_sec, ++_fileIndex);
			//tstringstream tos;
			//tos << _T("_") << tt->tm_year + 1900 << tt->tm_mon << tt->tm_mday << _T("_") << tt->tm_hour << tt->tm_min << tt->tm_sec;

			tstring newFileName(_fileName);
			tstring::size_type indexDot = _fileName.find_last_of(_T('.'));
			if(tstring::npos == indexDot)
			{
				//newFileName += tos.str();
				newFileName += tmString;
			}
			else
			{
				// newFileName.insert(indexDot, tos.str());
				newFileName.insert(indexDot, tmString);
			}

			// open new log file
			_fs.open(newFileName.c_str(), std::ios::out);
			if(_fs.is_open())
			{
				_fs.imbue(_loc);
				_curSize = 0;
			}
			else
			{
				ASSERT(0);
			}
		}

		// write log message to file
		if(_fs.is_open()) 
		{
			_fs << logMsg << std::flush;
			_curSize = static_cast<unsigned long>(_fs.tellp());
		}
	}
	return 0;
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:55,代码来源:Logger.cpp

示例13:

bool
CLink::IsEqual(
	const tstring&	strLink ) const
{
	bool rc = false;

	switch ( m_urlType )
	{
		case urlType_LocalAbsolute:
		{
			rc = ( strLink == m_strLink );
		} break;

		case urlType_Relative:
		{
			tstring strRel=strLink;
			tstring::size_type p = strLink.find_last_of( _T('/') );
			if ( p != tstring::npos )
			{
				strRel = strLink.substr( p + 1, strLink.length() );
			}
			else
			{
				p = strLink.find_last_of( _T('\\') );
				if ( p != tstring::npos )
				{
					strRel = strLink.substr( p + 1, strLink.length() );
				}
			}
			if ( strRel == m_strLink )
			{
				rc = true;
			}
		} break;

		case urlType_Absolute:
		default:
		{
		} break;
	}
	return rc;
}
开发者ID:georgevreilly,项目名称:sample-ASP-components,代码行数:42,代码来源:link.cpp

示例14: dirname

std::string dirname(tstring const& name)
{
    if( name.size() == 0 ) return ".";
    tstring::size_type p = name.find_last_of("/\\");
    if( p == tstring::npos ) {
        return ".";
    } else if( p == 0 )  {
        return "/";
    } else {
        return std::string(name.data(), p);
    }
}
开发者ID:zbigg,项目名称:tinfra,代码行数:12,代码来源:path.cpp

示例15: has_extension

bool has_extension(tstring const& filename)
{
    size_t find_start = filename.find_last_of("\\/");
    if( find_start == tstring::npos )
        find_start = 0;
    else
        find_start++;
    
    const size_t dot_pos = filename.find_first_of('.', find_start);
    const bool dot_exists =   (dot_pos != tstring::npos);
    const bool not_at_start = (dot_pos > find_start);
    return dot_exists && not_at_start;
}
开发者ID:zbigg,项目名称:tinfra,代码行数:13,代码来源:path.cpp


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