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


C++ CStr::Find方法代码示例

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


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

示例1: Decode_GetNextLine

bool COrgOp::Decode_GetNextLine( CStr &roDst, CStr &roSrc ) const
{
	int j;

	j = roSrc.Find( 0, ORG_OP_DELIM );
	if( j < 0 )
		return false;
	roSrc.Del( 0, ++j );

	j = roSrc.Find( 0, ORG_OP_NEWLINE );
	if( j < 0 )
		return false;
	roDst = roSrc.GetSub( 0, j );
	roSrc.Del( 0, j+sizeof( ORG_OP_NEWLINE ) );
	ORG_OP_LOG( "line: %s\n", roDst.GetData() );
	return true;
}
开发者ID:eriser,项目名称:es,代码行数:17,代码来源:OrgOp.cpp

示例2: Decode_GetNextToken

bool COrgOp::Decode_GetNextToken( CStr &roDst, CStr &roSrc ) const
{
	int j = roSrc.Find( 0, ORG_OP_DELIM );
	if( j < 0 )
		return false;
	roDst = roSrc.GetSub( 0, j );
	roSrc.Del( 0, j+1 ); // ORG_OP_DELIM auch löschen
	ORG_OP_LOG( "token: %s\n", roDst.GetData() );
	return true;
}
开发者ID:eriser,项目名称:es,代码行数:10,代码来源:OrgOp.cpp

示例3: wcslen

int
CIniFile::Split( const CStr &source, LPCTSTR sep, CStrArray &dest, BOOL trim /* = TRUE */ )
{
	int pos = source.Find( sep );
	int startPos = 0;
	CStr elem;
	int sepLen = wcslen( sep );

	dest.RemoveAll();
	while( pos != -1 )
	{
		elem = source.Mid( startPos, pos-startPos );
        if ( trim ) { elem.TrimLeft(); elem.TrimRight(); }
		dest.Add( elem );

		startPos = pos+sepLen;
		pos      = source.Find( sep, startPos );
	}
	elem = source.Mid( startPos );
    if ( trim ) { elem.TrimLeft(); elem.TrimRight(); }
	dest.Add( elem );

	return dest.GetSize();
}
开发者ID:grainrigi,项目名称:jscripts,代码行数:24,代码来源:IniFile.cpp

示例4:

void CCurvePathBezier3::Load( const CStr &roData )
{
	Clear();
	
	int i = 0;
	while( true )
	{
		const int j = roData.Find( i, DELIM );
		if( j < 0 )
			break;
		CCurveBezier3 *poC = new CCurveBezier3;
		poC->Load( roData.GetSub( i, j-i ) );
		m_oLstCurve.Append( poC );
		i = j + 1;
	}
}
开发者ID:0rel,项目名称:okkuplektor,代码行数:16,代码来源:Curve.cpp

示例5: Parse

bool CPrsBDF::Parse( const char *pcFont )
{
#define TOK(T) TPairTokenNameID( #T, PBDF_TOKEN_##T )
	static const TPairTokenNameID m_aoToken_[] = 
	{
		TOK( STARTFONT ),
		TOK( COMMENT ),
		TOK( CONTENTVERSION ),
		TOK( FONT ),
		TOK( SIZE ),
		TOK( FONTBOUNDINGBOX ),
		TOK( METRICSSET ),
		TOK( SWIDTH ),
		TOK( DWIDTH ),
		TOK( SWIDTH1 ),
		TOK( DWIDTH1 ),
		TOK( VVECTOR ),
		TOK( STARTPROPERTIES ),
		TOK( ENDPROPERTIES ),
		TOK( CHARS ),
		TOK( STARTCHAR ),
		TOK( ENCODING ),
		TOK( BBX ),
		TOK( BITMAP ),
		TOK( ENDCHAR ),
		TOK( ENDFONT )
	};
	static const unsigned int uiTokenNum = sizeof( m_aoToken_ ) / sizeof( TPairTokenNameID );
	CStr oStrFontFile( pcFont );
	const int iFontSize = oStrFontFile.GetSize();
	int iPropertiesStartPos = -1;
	CGlyph oGylphNew;
	CGlyph *poGlyph = &m_oGlyphDefault;
	bool bIsReadingChar = false;
	
	Reset();
	
	PBDF_LOG( "parse: start\n" );
	
	int iPos = 0;
	while( iPos < iFontSize )
	{
		int iEndOfLine = oStrFontFile.Find( iPos, PBDF_NEWLINE );
		if( iEndOfLine < 0 )
			iEndOfLine = iFontSize;
		
		CStr oStrLine = oStrFontFile.GetSub( iPos, iEndOfLine - iPos );
		RemoveLeadingSpace( oStrLine );
		
		//PBDF_LOG( "line: %s", oStrLine.GetData() );
		//PBDF_LOG( "line_size: %s", oStrLine.GetSize() );
		
		unsigned int uiTokenNext = PBDF_TOKEN_NONE;
		
		for( unsigned int t=0; t<uiTokenNum; ++t )
		{
			CStr oStrToken = m_aoToken_[t].GetFirst() ;
			const unsigned int uiTokenSize = oStrToken.GetSize();
			
			//PBDF_LOG( "token: %s", oStrToken.GetData() );
			
			int iPosToken = oStrLine.Find( 0, oStrToken );
			if( iPosToken != 0 ) 
				continue;
			
			// Danach müssen Leerzeichen oder das Ende folgen!
			const unsigned int uiPosNext = iPosToken + uiTokenSize;
			if( uiPosNext < oStrLine.GetSize() )
			{
				const char cNext = oStrLine[ uiPosNext ];
				if( !( cNext == ' ' || cNext == '\t' ) )
					continue;
			}
			
			if( iPosToken >= 0 )
			{
				oStrLine.Del( 0, uiTokenSize );
				RemoveLeadingSpace( oStrLine );
				uiTokenNext = m_aoToken_[t].GetSecond();
				PBDF_LOG( "token: %s\n", oStrToken.GetData() );
				break;
			}
		}
		
		if( uiTokenNext != PBDF_TOKEN_NONE )
		{
			switch( uiTokenNext )
			{
			case PBDF_TOKEN_STARTFONT:
				ReadValue( oStrLine, &m_dVersion );
				PBDF_LOG( "version: %g\n", m_dVersion );
			break;
			case PBDF_TOKEN_COMMENT:
			break;
			case PBDF_TOKEN_CONTENTVERSION: // optional
				ReadValue( oStrLine, &m_iContentVersion );
				PBDF_LOG( "content_version: %d\n", m_iContentVersion );
			break;
			case PBDF_TOKEN_FONT:
				ReadValue( oStrLine, &m_oStrFont );
//.........这里部分代码省略.........
开发者ID:0rel,项目名称:okkuplektor,代码行数:101,代码来源:PrsBDF.cpp

示例6: UpdateDrawCallCache

void GUIRenderer::UpdateDrawCallCache(DrawCalls& Calls, const CStr& SpriteName, const CRect& Size, int CellID, std::map<CStr, CGUISprite*>& Sprites)
{
	// This is called only when something has changed (like the size of the
	// sprite), so it doesn't need to be particularly efficient.

	// Clean up the old data
	Calls.clear();

	// If this object has zero size, there's nothing to render. (This happens
	// with e.g. tooltips that have zero size before they're first drawn, so
	// it isn't necessarily an error.)
	if (Size.left == Size.right && Size.top == Size.bottom)
		return;


	std::map<CStr, CGUISprite*>::iterator it(Sprites.find(SpriteName));
	if (it == Sprites.end())
	{
		/*
		 * Sprite not found. Check whether this a special sprite,
		 * and if so create a new sprite:
		 * "stretched:filename.ext" - stretched image
		 * "stretched:grayscale:filename.ext" - stretched grayscale image.
		 * "cropped:0.5, 0.25"    - stretch this ratio (x,y) of the top left of the image
		 * "color:r g b a"        - solid color
		 *     > "textureAsMask"  - when using color, use the (optional) texture alpha channel as mask.
		 * These can be combined, but they must be separated by a ":"
		 * so you can have a white overlay over an stretched grayscale image with:
		 * "grayscale:color:255 255 255 100:stretched:filename.ext"
		 */
		// Check that this can be a special sprite.
		if (SpriteName.ReverseFind(":") == -1 && SpriteName.Find("color(") == -1)
		{
			LOGERROR("Trying to use a sprite that doesn't exist (\"%s\").", SpriteName.c_str());
			return;
		}
		CGUISprite* Sprite = new CGUISprite;
		VfsPath TextureName = VfsPath("art/textures/ui") / wstring_from_utf8(SpriteName.AfterLast(":"));
		if (SpriteName.Find("stretched:") != -1)
		{
			// TODO: Should check (nicely) that this is a valid file?
			SGUIImage* Image = new SGUIImage;

			Image->m_TextureName = TextureName;
			// Allow grayscale images for disabled portraits
			if (SpriteName.Find("grayscale:") != -1)
			{
				Image->m_Effects = new SGUIImageEffects;
				Image->m_Effects->m_Greyscale = true;
			}

			CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100));
			Image->m_Size = ca;
			Image->m_TextureSize = ca;

			Sprite->AddImage(Image);

			Sprites[SpriteName] = Sprite;
		}
		else if (SpriteName.Find("cropped:") != -1)
		{
			// TODO: Should check (nicely) that this is a valid file?
			SGUIImage* Image = new SGUIImage;

			CStr info = SpriteName.AfterLast("cropped:").BeforeFirst(":");
			double xRatio = info.BeforeFirst(",").ToDouble();
			double yRatio = info.AfterLast(",").ToDouble();

			Image->m_TextureName = TextureName;

			CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100));
			CClientArea cb(CRect(0, 0, 0, 0), CRect(0, 0, 100/xRatio, 100/yRatio));
			Image->m_Size = ca;
			Image->m_TextureSize = cb;

			Sprite->AddImage(Image);

			Sprites[SpriteName] = Sprite;
		}
		if (SpriteName.Find("color:") != -1)
		{
			CStrW value = wstring_from_utf8(SpriteName.AfterLast("color:").BeforeFirst(":"));
			CColor color;

			// Check color is valid
			if (!GUI<CColor>::ParseString(value, color))
			{
				LOGERROR("GUI: Error parsing sprite 'color' (\"%s\")", utf8_from_wstring(value));
				return;
			}

			SGUIImage* Image = new SGUIImage;

			// If we are using a mask, this is an effect.
			// Otherwise we can fallback to the "back color" attribute
			// TODO: we are assuming there is a filename here.
			if (SpriteName.Find("textureAsMask:") != -1)
			{
				Image->m_TextureName = TextureName;
				Image->m_Effects = new SGUIImageEffects;
//.........这里部分代码省略.........
开发者ID:krichter722,项目名称:0ad,代码行数:101,代码来源:GUIRenderer.cpp

示例7: CMapStrToString

void
CIniFile::Parse( LPCTSTR cont )
{
	CStr content = cont;
	CStr sectionName, key, value;
    CMapStrToString *section = NULL;
	BOOL hasEmptySection = FALSE;

	Sections.RemoveAll();

	while ( content.GetLength() > 0 )
	{
		CStr line;
		int pos = content.Find( _T("\n") );
		if ( pos != -1 )
		{
			line    = content.Left( pos );
			content = content.Mid( pos+1 );
		}
		else
		{
			line = content;
			content = _T("");
		}
		line.TrimLeft(); line.TrimRight();

		if ( line.GetLength() > 0 && line.GetAt(0) != '#' && line.GetAt(0) != ';' )
		{
			if ( line.GetAt(0) == '[' && line.Right(1) == L"]" )
			{
				sectionName = line.Mid( 1, line.GetLength()-2 );
                sectionName.MakeLower();
                section = new CMapStrToString();
                Sections.SetAt( sectionName, section );
			}
			else
			{
				int eqPos = line.Find( '=' );
				if ( eqPos != -1 )
				{
					key   = line.Left( eqPos );
					key.TrimLeft(); key.TrimRight();
					value = line.Mid( eqPos+1 );
					value.TrimLeft(); value.TrimRight();
					if ( value.Left(1) == L"\"" && value.Right(1) == L"\"" )
					{
						value = value.Mid( 1, value.GetLength()-2 );
					}
					key.MakeLower();
					if ( section == NULL && hasEmptySection == FALSE )
					{
						section = new CMapStrToString();
						Sections.SetAt( L"", section );
						hasEmptySection = TRUE;
					}
					section->SetAt( key, value );
				}
			}
		}
	}
}
开发者ID:grainrigi,项目名称:jscripts,代码行数:61,代码来源:IniFile.cpp

示例8: SetActor

void ActorViewer::SetActor(const CStrW& name, const CStrW& animation, player_id_t playerID)
{
	bool needsAnimReload = false;

	CStrW id = name;

	// Recreate the entity, if we don't have one or if the new one is different
	if (m.Entity == INVALID_ENTITY || id != m.CurrentUnitID)
	{
		// Delete the old entity (if any)
		if (m.Entity != INVALID_ENTITY)
		{
			m.Simulation2.DestroyEntity(m.Entity);
			m.Simulation2.FlushDestroyedEntities();
			m.Entity = INVALID_ENTITY;
		}

		// Clear particles associated with deleted entity
		g_Renderer.GetParticleManager().ClearUnattachedEmitters();

		// If there's no actor to display, return with nothing loaded
		if (id.empty())
			return;

		m.Entity = m.Simulation2.AddEntity(L"preview|" + id);
		if (m.Entity == INVALID_ENTITY)
			return;

		CmpPtr<ICmpPosition> cmpPosition(m.Simulation2, m.Entity);
		if (cmpPosition)
		{
			ssize_t c = TERRAIN_TILE_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;
			cmpPosition->JumpTo(entity_pos_t::FromInt(c), entity_pos_t::FromInt(c));
			cmpPosition->SetYRotation(entity_angle_t::Pi());
		}

		CmpPtr<ICmpOwnership> cmpOwnership(m.Simulation2, m.Entity);
		if (cmpOwnership)
			cmpOwnership->SetOwner(playerID);

		needsAnimReload = true;
	}

	if (animation != m.CurrentUnitAnim)
		needsAnimReload = true;

	if (needsAnimReload)
	{
		CStr anim = animation.ToUTF8().LowerCase();

		// Emulate the typical simulation animation behaviour
		float speed;
		float repeattime = 0.f;
		if (anim == "walk")
		{
			CmpPtr<ICmpUnitMotion> cmpUnitMotion(m.Simulation2, m.Entity);
			if (cmpUnitMotion)
				speed = cmpUnitMotion->GetWalkSpeed().ToFloat();
			else
				speed = 7.f; // typical unit speed

			m.CurrentSpeed = speed;
		}
		else if (anim == "run")
		{
			CmpPtr<ICmpUnitMotion> cmpUnitMotion(m.Simulation2, m.Entity);
			if (cmpUnitMotion)
				speed = cmpUnitMotion->GetRunSpeed().ToFloat();
			else
				speed = 12.f; // typical unit speed

			m.CurrentSpeed = speed;
		}
		else if (anim == "melee")
		{
			speed = 1.f; // speed will be ignored if we have a repeattime
			m.CurrentSpeed = 0.f;

			CStr code = "var cmp = Engine.QueryInterface("+CStr::FromUInt(m.Entity)+", IID_Attack); " +
				"if (cmp) cmp.GetTimers(cmp.GetBestAttack()).repeat; else 0;";
			m.Simulation2.GetScriptInterface().Eval(code.c_str(), repeattime);
		}
		else
		{
			// Play the animation at normal speed, but movement speed is zero
			speed = 1.f;
			m.CurrentSpeed = 0.f;
		}

		CStr sound;
		if (anim == "melee")
			sound = "attack";
		else if (anim == "build")
			sound = "build";
		else if (anim.Find("gather_") == 0)
			sound = anim;

		std::wstring soundgroup;
		if (!sound.empty())
		{
//.........这里部分代码省略.........
开发者ID:TiriliPiitPiit,项目名称:0ad,代码行数:101,代码来源:ActorViewer.cpp


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