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


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

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


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

示例1: ParseSingleMetaClass

//-----------------------------------------------------------------------------
// Parse a single metaclass
//-----------------------------------------------------------------------------
bool CPanelMetaClassMgrImp::ParseSingleMetaClass( const char* pFileName,
	const char* pMetaClassName, KeyValues* pMetaClassValues, int keyValueIndex )
{
	// Complain about duplicately defined metaclass names...
	if ( m_MetaClassDict.Find( pMetaClassName ) != m_MetaClassDict.InvalidIndex() )
	{
		Warning( "Meta class %s duplicately defined (file %s)\n", pMetaClassName, pFileName );
		return false;
	}

	// find the type...
	const char* pPanelType = pMetaClassValues->GetString( "type" );
	if (!pPanelType || !pPanelType[0])
	{
		Warning( "Unable to find type of meta class %s in file %s\n", pMetaClassName, pFileName );
		return false;
	}

	unsigned short i = m_PanelTypeDict.Find( pPanelType );
	if (i == m_PanelTypeDict.InvalidIndex())
	{
		Warning( "Type %s of meta class %s undefined!\n", pPanelType, pMetaClassName );
		stackfree(pLwrMetaClass);
		return false;
	}

	// Add it to the metaclass dictionary
	MetaClassDict_t element;
	element.m_TypeIndex = i;
	element.m_KeyValueIndex = keyValueIndex;
	element.m_pKeyValues = pMetaClassValues;
	m_MetaClassDict.Insert( pMetaClassName, element );

	return true;
}
开发者ID:newroob,项目名称:bg2-2007,代码行数:38,代码来源:panelmetaclassmgr.cpp

示例2:

//-----------------------------------------------------------------------------
// Create, destroy panel...
//-----------------------------------------------------------------------------
vgui::Panel *CPanelMetaClassMgrImp::CreatePanelMetaClass( const char* pMetaClassName,
	int sortorder, void *pInitData, vgui::Panel *pParent, const char *pChainName )
{
	// Search for the metaclass name
	int i = m_MetaClassDict.Find( pMetaClassName );
	if (i == m_MetaClassDict.InvalidIndex())
		return NULL; 

	// Now that we've got the metaclass, we can figure out what kind of
	// panel to instantiate...
	MetaClassDict_t &metaClass = m_MetaClassDict[i];
	IPanelFactory* pFactory = m_PanelTypeDict[metaClass.m_TypeIndex];

	// Set up the key values for use in initialization
	if (pChainName)
	{
		KeyValueChainRecursive( metaClass.m_pKeyValues, pChainName );
	}

	// Create and initialize the panel
	vgui::Panel *pPanel = pFactory->Create( pMetaClassName, metaClass.m_pKeyValues, pInitData, pParent );
	if ( pPanel )
	{
		pPanel->SetZPos( sortorder );
	}

	return pPanel;
}
开发者ID:newroob,项目名称:bg2-2007,代码行数:31,代码来源:panelmetaclassmgr.cpp

示例3: RegisterScriptedWeapon

void RegisterScriptedWeapon( const char *className )
{
#ifdef CLIENT_DLL
	if ( GetClassMap().FindFactory( className ) )
	{
		return;
	}

	GetClassMap().Add( className, "CHL2MPScriptedWeapon", sizeof( CHL2MPScriptedWeapon ),
		&CCHL2MPScriptedWeaponFactory, true );
#else
	if ( EntityFactoryDictionary()->FindFactory( className ) )
	{
		return;
	}

	unsigned short lookup = m_WeaponFactoryDatabase.Find( className );
	if ( lookup != m_WeaponFactoryDatabase.InvalidIndex() )
	{
		return;
	}

	// Andrew; This fixes months worth of pain and anguish.
	CEntityFactory<CHL2MPScriptedWeapon> *pFactory = new CEntityFactory<CHL2MPScriptedWeapon>( className );

	lookup = m_WeaponFactoryDatabase.Insert( className, pFactory );
	Assert( lookup != m_WeaponFactoryDatabase.InvalidIndex() );
#endif
	// BUGBUG: When attempting to precache weapons registered during runtime,
	// they don't appear as valid registered entities.
	// static CPrecacheRegister precache_weapon_(&CPrecacheRegister::PrecacheFn_Other, className);
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:32,代码来源:weapon_hl2mpbase_scriptedweapon.cpp

示例4: AllocateUniqueDataTableName

char* AllocateUniqueDataTableName( bool bSendTable, const char *pFormat, ... )
{
	// Setup the string.
	va_list marker;
	va_start( marker, pFormat );
	char *pRet = AllocateStringHelper2( pFormat, marker );
	va_end( marker );

	// Make sure it's unique.
#ifdef _DEBUG
	// Have to allocate them here because if they're declared as straight global variables,
	// their constructors won't have been called yet by the time we get in here.
	if ( !g_STDict )
	{
		g_STDict = new CUtlDict<int,int>;
		g_RTDict = new CUtlDict<int,int>;
	}

	CUtlDict<int,int> *pDict = bSendTable ? g_STDict : g_RTDict;
	if ( pDict->Find( pRet ) != pDict->InvalidIndex() )
	{
		// If it hits this, then they have 2 utlvectors in different data tables with the same name and the
		// same size limit. The names of 
		Assert( false );
	}
	pDict->Insert( pRet, 0 );
#endif

	return pRet;
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:30,代码来源:dt_utlvector_common.cpp

示例5:

//-----------------------------------------------------------------------------
// Finds a widget factory by name
//-----------------------------------------------------------------------------
IAttributeWidgetFactory *CAttributeWidgetFactoryList::FindWidgetFactory( const char *pWidgetName )
{
	unsigned short i = m_Factories.Find( pWidgetName );
	if ( i != m_Factories.InvalidIndex() )
		return m_Factories[i];
	return NULL;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:10,代码来源:AttributeWidgetFactory.cpp

示例6: strdup

//-----------------------------------------------------------------------------
// Purpose: Find a free PyServerClass and claim it
//			Send a message to the clients to claim a client class and set it to
//			the right type.
//-----------------------------------------------------------------------------
NetworkedClass::NetworkedClass( 
							   const char *pNetworkName, boost::python::object cls_type, 
							   const char *pClientModuleName )
{
	m_pClientClass = NULL;
	m_pNetworkName = strdup( pNetworkName );
	m_pyClass = cls_type;
	
	unsigned short lookup = m_NetworkClassDatabase.Find( m_pNetworkName );
	if ( lookup != m_NetworkClassDatabase.InvalidIndex() )
	{
		Warning("NetworkedClass: %s already added, replacing contents...\n", pNetworkName);
		m_pClientClass = m_NetworkClassDatabase[lookup]->m_pClientClass;
		m_NetworkClassDatabase[lookup] = this;
		if( m_pClientClass )
		{
			AttachClientClass( m_pClientClass );
		}
	}
	else
	{
		// New entry, add to database and find if there is an existing ClientClass
		m_NetworkClassDatabase.Insert( m_pNetworkName, this );

		m_pClientClass = FindPyClientClassToNetworkClass( m_pNetworkName );
	}
}
开发者ID:Sandern,项目名称:py-source-sdk-2013,代码行数:32,代码来源:srcpy_client_class.cpp

示例7: RegisterScriptedEntity

void RegisterScriptedEntity( const char *className )
{
#ifdef CLIENT_DLL
	if ( GetClassMap().FindFactory( className ) )
	{
		return;
	}

	GetClassMap().Add( className, "CBaseScripted", sizeof( CBaseScripted ),
		&CCBaseScriptedFactory, true );
#else
	if ( EntityFactoryDictionary()->FindFactory( className ) )
	{
		return;
	}

	unsigned short lookup = m_EntityFactoryDatabase.Find( className );
	if ( lookup != m_EntityFactoryDatabase.InvalidIndex() )
	{
		return;
	}

	CEntityFactory<CBaseScripted> *pFactory = new CEntityFactory<CBaseScripted>( className );

	lookup = m_EntityFactoryDatabase.Insert( className, pFactory );
	Assert( lookup != m_EntityFactoryDatabase.InvalidIndex() );
#endif
}
开发者ID:WorldGamers,项目名称:Mobile-Forces-Source,代码行数:28,代码来源:basescripted.cpp

示例8: AddModelNameFromSource

bool AddModelNameFromSource( CUtlDict< ModelFile, int >& models, char const *filename, char const *modelname, int offset )
{
	int idx = models.Find( modelname );
	if ( idx != models.InvalidIndex() )
	{
		char shortname[ MAX_PATH ];
		char shortname2[ MAX_PATH ];
		strcpy( shortname, &filename[ offset ] );
		strcpy( shortname2, &models[ idx ].qcfile[ offset ] );

		vprint( 0, "multiple .qc's build %s\n  %s\n  %s\n",
			modelname,
			shortname, 
			shortname2 );
		return false;
	}

	ModelFile mf;
	strcpy( mf.qcfile, filename );
	_strlwr( mf.qcfile );
	mf.version = 0;

	models.Insert( modelname, mf );
	return true;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:25,代码来源:mdlcheck.cpp

示例9: DiscoverMacroTextures

void DiscoverMacroTextures()
{
    CUtlDict<int,int> tempDict;

    g_FaceMacroTextureInfos.SetSize( numfaces );
    for ( int iFace=0; iFace < numfaces; iFace++ )
    {
        texinfo_t *pTexInfo = &texinfo[dfaces[iFace].texinfo];
        if ( pTexInfo->texdata < 0 )
            continue;

        dtexdata_t *pTexData = &dtexdata[pTexInfo->texdata];
        const char *pMaterialName = &g_TexDataStringData[ g_TexDataStringTable[pTexData->nameStringTableID] ];

        MaterialSystemMaterial_t hMaterial = FindMaterial( pMaterialName, NULL, false );

        const char *pMacroTextureName = GetMaterialVar( hMaterial, "$macro_texture" );
        if ( pMacroTextureName )
        {
            if ( tempDict.Find( pMacroTextureName ) == tempDict.InvalidIndex() )
            {
                Msg( "-- DiscoverMacroTextures: %s\n", pMacroTextureName );
                tempDict.Insert( pMacroTextureName, 0 );
            }

            int stringID = TexDataStringTable_AddOrFindString( pMacroTextureName );
            g_FaceMacroTextureInfos[iFace].m_MacroTextureNameID = (unsigned short)stringID;
        }
        else
        {
            g_FaceMacroTextureInfos[iFace].m_MacroTextureNameID = 0xFFFF;
        }
    }
}
开发者ID:Filip98,项目名称:source-sdk-2013,代码行数:34,代码来源:writebsp.cpp

示例10: Draw_DecalIndexFromName

// called from cl_parse.cpp
// find the server side decal id given it's name.
// used for save/restore
int Draw_DecalIndexFromName( char *name )
{
	int lookup = g_DecalDictionary.Find( name );
	if ( lookup == g_DecalDictionary.InvalidIndex() )
		return 0;

	return g_DecalDictionary[ lookup ].index;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:11,代码来源:decals.cpp

示例11: FindMacroTexture

CMacroTextureData* FindMacroTexture( const char *pFilename )
{
	int index = g_MacroTextureLookup.Find( pFilename );
	if ( g_MacroTextureLookup.IsValidIndex( index ) )
		return g_MacroTextureLookup[index];
	else
		return NULL;
}
开发者ID:chrizonix,项目名称:RCBot2,代码行数:8,代码来源:macro_texture.cpp

示例12: StripNamespace

//-----------------------------------------------------------------------------
// Purpose: Find but don't add mapping
//-----------------------------------------------------------------------------
PanelAnimationMap *CPanelAnimationDictionary::FindPanelAnimationMap( char const *className )
{
	int lookup = m_AnimationMaps.Find( StripNamespace( className ) );
	if ( lookup != m_AnimationMaps.InvalidIndex() )
	{
		return m_AnimationMaps[ lookup ].map;
	}
	return NULL;
}
开发者ID:TrentSterling,项目名称:D0G,代码行数:12,代码来源:AnimationController.cpp

示例13: FindTexture

ITextureInternal *CTextureManager::FindTexture( const char *pTextureName )
{
	if ( !pTextureName || pTextureName[0] == 0 )
		return NULL;
	
	char szCleanName[MAX_PATH];
	NormalizeTextureName( pTextureName, szCleanName, sizeof( szCleanName ) );

	int i = m_TextureList.Find( szCleanName );
	if ( i != m_TextureList.InvalidIndex() )
	{
		return m_TextureList[i];
	}

	i = m_TextureAliases.Find( szCleanName );
	if ( i != m_TextureAliases.InvalidIndex() )
	{
		return FindTexture( m_TextureAliases[i] );
	}

	// Special handling: lightmaps
	if ( char const *szLightMapNum = StringAfterPrefix( szCleanName, "[lightmap" ) )
	{
		int iLightMapNum = atoi( szLightMapNum );
		extern CMaterialSystem g_MaterialSystem;
		CMatLightmaps *plm = g_MaterialSystem.GetLightmaps();
		if ( iLightMapNum >= 0 &&
			 iLightMapNum < plm->GetNumLightmapPages() )
		{
			ShaderAPITextureHandle_t hTex = plm->GetLightmapPageTextureHandle( iLightMapNum );
			if ( hTex != INVALID_SHADERAPI_TEXTURE_HANDLE )
			{
				// Establish the lookup linking in the dictionary
				ITextureInternal *pTxInt = ITextureInternal::CreateReferenceTextureFromHandle( pTextureName, TEXTURE_GROUP_LIGHTMAP, hTex );
				m_TextureList.Insert( pTextureName, pTxInt );
				return pTxInt;
			}
		}
	}

	return NULL;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:42,代码来源:texturemanager.cpp

示例14:

const char *CClassMap::Lookup( const char *classname )
{
	unsigned short index;
	static classentry_t lookup; 

	index = m_ClassDict.Find( classname );
	if ( index == m_ClassDict.InvalidIndex() )
		return NULL;

	lookup = m_ClassDict.Element( index );
	return lookup.GetMapName();
}
开发者ID:WorldGamers,项目名称:Mobile-Forces-Source,代码行数:12,代码来源:classmap.cpp

示例15:

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : gamematerial - 
// Output : char const
//-----------------------------------------------------------------------------
char const *CDecalEmitterSystem::ImpactDecalForGameMaterial( int gamematerial )
{
	char gm[ 2 ];
	gm[0] = (char)gamematerial;
	gm[1] = 0;

	int idx = m_GameMaterialTranslation.Find( gm );
	if ( idx == m_GameMaterialTranslation.InvalidIndex() )
		return NULL;

	return m_Decals.GetElementName( m_GameMaterialTranslation.Element(idx) );
}
开发者ID:KyleGospo,项目名称:City-17-Episode-One-Source,代码行数:17,代码来源:decals.cpp


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