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


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

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


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

示例1:

	//-----------------------------------------------------------------------
	void UnicodeFileSystemArchive::FileFinder::run(const WString& _wpattern, bool _recursive, bool _dirs,
			StringVector* _simpleList, FileInfoList* _detailList)
	{
		mRecursive = _recursive;
		mDirs = _dirs;
		mSimpleList = _simpleList;
		mDetailList = _detailList;

		// pattern can contain a directory name, separate it from mask
        size_t pos1 = _wpattern.rfind ('/');
        size_t pos2 = _wpattern.rfind ('\\');
        if (pos1 == _wpattern.npos || ((pos2 != _wpattern.npos) && (pos1 < pos2)))
            pos1 = pos2;

		WString wdir, wmask;
		if(pos1 == String::npos)
		{
			wmask = _wpattern;
		}
		else
		{
			wdir = _wpattern.substr(0, pos1 + 1);
			wmask = _wpattern.substr(pos1 + 1);
		}

		if(wmask == L"*")
			wmask.clear();

		String mask = mArchive->toString(wmask);
		String dir = mArchive->toString(wdir);
		WString wFullDir = mArchive->getFullPath(wdir);

		_run(dir, wFullDir);
	}
开发者ID:raduetsya,项目名称:GothOgre,代码行数:35,代码来源:WinUnicodeFileSystem.cpp

示例2: wsplit

		void wsplit( TVectorWString & _outStrings, const WString& _str, bool _trimDelims, const WString& _delims )
		{
			uint32_t numSplits = 0;
			WString::size_type start = 0;
			WString::size_type pos = 0;

			do 
			{
				pos = _str.find_first_of(_delims, start);
			
				if (pos == WString::npos )
				{
					_outStrings.push_back( _str.substr(start) );
					break;
				}
				else
				{
					_outStrings.push_back( _str.substr(start, pos - start) );
					start = pos + 1;
				}

				if( _trimDelims == true )
				{
					start = _str.find_first_not_of(_delims, start);
				}

				++numSplits;

			} while (pos != WString::npos);
		}
开发者ID:irov,项目名称:Mengine,代码行数:30,代码来源:String.cpp

示例3: TrimEnd

//
// Remove szOlds from the end of the string.
//
WString WString::TrimEnd ( const wchar_t* szOld ) const
{
    const size_t uiOldLength = wcslen ( szOld );
    WString strResult = *this;
    while ( strResult.length () >= uiOldLength && strResult.substr ( strResult.length () - uiOldLength ) == szOld )
        strResult = strResult.substr ( 0, strResult.length () - uiOldLength );
    return strResult;
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:11,代码来源:WString.hpp

示例4: TrimStart

//
// Remove szOlds from the start of the string.
//
WString WString::TrimStart ( const wchar_t* szOld ) const
{
    const size_t uiOldLength = wcslen ( szOld );
    WString strResult = *this;
    while ( strResult.substr ( 0, uiOldLength ) == szOld )
        strResult = strResult.substr ( uiOldLength );
    return strResult;
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:11,代码来源:WString.hpp

示例5: setScene

	void GUIStatusBar::setScene(const WString& name, bool modified)
	{
		WStringStream content;
		content << L"Scene: ";

		if (name.size() > 15)
			content << name.substr(0, 15) << L"...";
		else
			content << name;

		if (modified)
			content << L"*";

		mScene->setContent(HString(content.str()));
	}
开发者ID:AlfHub,项目名称:BansheeEngine,代码行数:15,代码来源:BsGUIStatusBar.cpp

示例6: setProject

	void GUIStatusBar::setProject(const WString& name, bool modified)
	{
		WStringStream content;
		content << L"Project: ";

		if (name.size() > 20)
			content << name.substr(0, 20) << L"...";
		else
			content << name;

		if (modified)
			content << L"*";

		mProject->setContent(HString(content.str()));
	}
开发者ID:AlfHub,项目名称:BansheeEngine,代码行数:15,代码来源:BsGUIStatusBar.cpp

示例7: logModified

	void GUIStatusBar::logModified()
	{
		LogEntry entry;
		if(!gDebug().getLog().getLastEntry(entry))
		{
			GUIContent messageContent(HString(L""));
			mMessage->setContent(messageContent);

			return;
		}

		HSpriteTexture iconTexture;
		Color textColor = COLOR_INFO;

		UINT32 logChannel = entry.getChannel();
		switch (logChannel)
		{
		case (UINT32)DebugChannel::Debug:
			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Info, 16, false);
			break;
		case (UINT32)DebugChannel::Warning:
		case (UINT32)DebugChannel::CompilerWarning:
			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Warning, 16, false);
			textColor = COLOR_WARNING;
			break;
		case (UINT32)DebugChannel::Error:
		case (UINT32)DebugChannel::CompilerError:
			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Error, 16, false);
			textColor = COLOR_ERROR;
			break;
		}

		WString message = toWString(entry.getMessage());
		size_t lfPos = message.find_first_of('\n');
		size_t crPos = message.find_first_of('\r');
		size_t newlinePos;

		if (lfPos != WString::npos)
		{
			if (crPos != WString::npos)
				newlinePos = std::min(lfPos, crPos);
			else
				newlinePos = lfPos;
		}
		else if (crPos != WString::npos)
			newlinePos = crPos;
		else
			newlinePos = -1;

		if (newlinePos == -1)
		{
			GUIContent messageContent(HString(message), iconTexture);
			mMessage->setContent(messageContent);
			mMessage->setTint(textColor);
		}
		else
		{
			WString firstLine = message.substr(0, newlinePos);

			GUIContent messageContent(HString(firstLine), iconTexture);
			mMessage->setContent(messageContent);
			mMessage->setTint(textColor);
		}		
	}
开发者ID:AlfHub,项目名称:BansheeEngine,代码行数:64,代码来源:BsGUIStatusBar.cpp

示例8: WStringToString

SharedPtr<FormatBase> FormatBase::loadImport(const String &filename, int architecture)
{
	if(File::isPathExists(filename))
		return ::loadImport(filename, architecture);

	List<String> searchPaths;
	String currentDirectory = WStringToString(Win32NativeHelper::get()->getCurrentDirectory());
	searchPaths.push_back(currentDirectory.substr(0, currentDirectory.length() - 1));
#ifdef _WIN32
	wchar_t *environmentBlock = Win32NativeHelper::get()->getEnvironments();
	WString path;
	while(*environmentBlock)
	{
		size_t equal = 0;
		size_t currentLength = 0;
		wchar_t *start = environmentBlock;
		while(*environmentBlock ++) 
		{
			if(*environmentBlock == L'=')
				equal = currentLength;
			currentLength ++;
		}
		if(equal >= 3 && 
			WString::to_lower(start[0]) == L'p' &&
			WString::to_lower(start[1]) == L'a' &&
			WString::to_lower(start[2]) == L't' &&
			WString::to_lower(start[3]) == L'h' &&
			start[4] == L'=')
		{
			path.assign(start + equal + 2);
			break;
		}
	}
	int s = 0, e = 0;
	while(true)
	{
		e = path.find(L';', e + 1);
		if(e == -1)
			break;
		String currentPath = WStringToString(path.substr(s, e - s));
		searchPaths.push_back(currentPath);
		s = e + 1;
	}
#endif
	for(auto &i : searchPaths)
	{
		String path = File::combinePath(i, filename);
		SharedPtr<FormatBase> result = ::loadImport(path, architecture);
		if(!result)
		{
			if(path.substr(path.length() - 4).icompare(".dll") != 0)
			{
				path.append(".dll");
				result = ::loadImport(path, architecture);
			}
		}
		if(result.get())
			return result;
	}
	return SharedPtr<FormatBase>(nullptr);
}
开发者ID:yzx65,项目名称:Packer,代码行数:61,代码来源:PEFormat.cpp


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