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


C++ CGUIString::empty方法代码示例

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


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

示例1:

	//------------------------------------------------------------------------------
	void CGUIWgtParticle2D::SetParticle2D( const CGUIString& rParticle2DName )
	{
		GUI_TRACE( GUI_FORMAT( "[CGUIWgtParticle2D::SetParticle2D]: play particle %s", rParticle2DName.c_str()));

		if( rParticle2DName.empty() )
		{
			//clear
			SetParticle2D( NULL );
		}
		else
		{
			CGUIParticle2DSystem* pParticle2D = CGUIParticle2DManager::Instance()->AllocateResource( rParticle2DName );
			SetParticle2D( pParticle2D );
			pParticle2D->RefRelease();
		}
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:17,代码来源:guiwgtparticle2d.cpp

示例2: CGUIException

	//------------------------------------------------------------------------------
	int IGUIStringConv_iconv::Utf8ToWChar( const CGUIString& rSrc, CGUIStringW& rDst )
	{
		if( rSrc.empty())
		{
			rDst.clear();
			return 0;
		}

		//open iconv
		iconv_t cd = iconv_open ("UTF-16LE", "UTF-8");
		if( cd == (iconv_t)-1 )
		{
			throw CGUIException(
				"[MultiByteToWideChar]: failed to open iconv, errno is %d",
				errno);
			return -1;
		}

		//convert
		size_t	buf_size = rSrc.size()+1;
		size_t	inbytesleft = rSrc.size();
		size_t	outbytesleft = buf_size;
		char*	dst = (char*)(new wchar[buf_size]);
		char*	pOutBuf = NULL;
		char*	pInBuf = (char*)(rSrc.c_str());

		bool	bError = false;

		while(inbytesleft > 0) 
		{
			pOutBuf = dst;
			outbytesleft = buf_size*sizeof(wchar);

			size_t retbytes = iconv(cd, &pInBuf, &inbytesleft, &pOutBuf, &outbytesleft);

			if (dst != pOutBuf)  
			{
				// wchar is 4byte in mac, but iconv return a "utf-16" buff which is 2byte per code
				if (sizeof(wchar) == 4) 
				{
					for (int iChar = 0; iChar < (pOutBuf-dst)/2; iChar++)
					{
						unsigned short* pU16Char = (unsigned short*)&dst[2*iChar];
						rDst.push_back((wchar)*pU16Char);
					}
				}
				else if (sizeof(wchar) == 2) 
				{
					rDst.append((wchar*)dst, (pOutBuf-dst)/sizeof(wchar));
				}
			} 

			//check ret
			if( retbytes == size_t(-1) )
			{
				if( errno == E2BIG )
				{
					continue;
				}
				else
				{
					bError = true;
					break;
				}
			}
			else
			{
				//success
				break;
			}
		}

		delete[] dst;
		if( bError)
		{
			switch(errno)
			{
			case EILSEQ:
				throw CGUIException(
					"[MultiByteToWideChar]: failed to iconv, errno is EILSEQ");
				return -1;
			case EINVAL:
				throw CGUIException(
					"[MultiByteToWideChar]: failed to iconv, errno is EINVAL");
				return -1;
			default:
				throw CGUIException(
					"[MultiByteToWideChar]: failed to iconv, errno is %d",
					errno);
				return -1;
			}
		}

		//close iconv
		int ret = iconv_close(cd);
		if( ret == -1 )
		{
			throw CGUIException(
				"[MultiByteToWideChar]: failed to close iconv, errno is %d",
//.........这里部分代码省略.........
开发者ID:Abyss116,项目名称:libguiex,代码行数:101,代码来源:guistringconv_iconv.cpp


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