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


C++ Name::Set方法代码示例

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


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

示例1: if

bool Helium::AssetIdentifier::Identify( Reflect::Object* object, Name& identity )
{
	Asset *pAsset = Reflect::SafeCast<Asset>(object);

	if ( pAsset )
	{
		identity.Set(pAsset->GetPath().ToString());
		HELIUM_TRACE( TraceLevels::Info, TXT( "Identifying object [%s]\n" ), identity.Get() );
		return true;
	}
	else if ( object )
	{
		HELIUM_TRACE( TraceLevels::Info, TXT( "Deferring identification of object of type [%s]\n" ), object->GetMetaClass()->m_Name );
	}

	return false;
}
开发者ID:kevindqc,项目名称:Helium,代码行数:17,代码来源:AssetLoader.cpp

示例2: Create

/// Create a type object.
///
/// @param[in] name          Type name.
/// @param[in] pTypePackage  Package in which the template object should be stored.
/// @param[in] pParent       Parent type.
/// @param[in] pTemplate     Template object.
/// @param[in] flags         Type flags.
///
/// @return  Pointer to the type object if created successfully, null if not.
///
/// @see Unregister()
// PMD: Removing const because:
// - Objects must be able to have properties of the same type as the outer type (i.e. Asset has reference to Asset that is the template)
// - So, s_MetaClass must be set before calling PopulateMetaType
// - So, this function must return a pointer that PopulateMetaType can work on, rather than calling PopulateMetaType directly
//   - If not for this restriction, I'd want to see if we could call MetaClass::Create and Composite::Create, rather than doing duplicate set-up work here
// - To prevent un-consting parameter to PopulateMetaType, making AssetType return non-const
AssetType* AssetType::Create(
	const Reflect::MetaClass* pClass,
	Package* pTypePackage,
	const AssetType* pParent,
	Asset* pTemplate,
	uint32_t flags )
{
	HELIUM_ASSERT( pClass );
	HELIUM_ASSERT( pTypePackage );
	HELIUM_ASSERT( pTemplate );

	Name name;
	name.Set( pClass->m_Name );
	HELIUM_ASSERT( !name.IsEmpty() );

	// Register the template object with the object system.
	if( !Asset::RegisterObject( pTemplate ) )
	{
		HELIUM_TRACE(
			TraceLevels::Error,
			TXT( "AssetType::Initialize(): Failed to register type \"%s\" template object.\n" ),
			*name );

		return NULL;
	}

	// Set up the template object name, and set this object as its parent.
	Asset::RenameParameters nameParameters;
	nameParameters.name = name;
	nameParameters.spOwner = pTypePackage;
	if( !pTemplate->Rename( nameParameters ) )
	{
		HELIUM_TRACE(
			TraceLevels::Error,
			TXT( "AssetType::Initialize(): Failed to set type \"%s\" template object name and owner.\n" ),
			*name );

		Asset::UnregisterObject( pTemplate );

		return NULL;
	}

	// Flag the object as the default template object for the type being created.
	pTemplate->SetFlags( 
		Asset::FLAG_DEFAULT_TEMPLATE | 
		Asset::FLAG_TRANSIENT | 
		Asset::FLAG_PRELOADED | 
		Asset::FLAG_LINKED |
		Asset::FLAG_PRECACHED |
		Asset::FLAG_LOADED);

	// Create the type object and store its parameters.
	AssetType* pType = new AssetType;
	HELIUM_ASSERT( pType );
	pType->m_class = pClass;
	pClass->m_Tag = pType;
	const_cast< Reflect::MetaClass* >( pType->m_class )->m_Default = pTemplate;
	const_cast< Reflect::MetaClass* >( pType->m_class )->MetaStruct::m_Default = pTemplate;
	pType->m_name = name;
	pType->m_flags = flags;

	// Lazily initialize the lookup map.  Note that this is not inherently thread-safe, but there should always be
	// at least one type registered before any sub-threads are spawned.
	if( !sm_pLookupMap )
	{
		sm_pLookupMap = new LookupMap;
		HELIUM_ASSERT( sm_pLookupMap );
	}

	// Register the type (note that a type with the same name should not already exist in the lookup map).
	LookupMap::Iterator typeIterator;
	HELIUM_VERIFY( sm_pLookupMap->Insert( typeIterator, KeyValue< Name, AssetTypePtr >( pType->GetName(), pType ) ) );

	return pType;
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:92,代码来源:Asset.cpp

示例3: Parse


//.........这里部分代码省略.........

	char* pTempNameString = static_cast< char* >( rStackHeap.Allocate(
		sizeof( char ) * ( nameLengthMax + 1 ) ) );
	HELIUM_ASSERT( pTempNameString );
	char* pTempNameCharacter = pTempNameString;

	Name* pTargetName = &rpNames[ nameCount - 1 ];
	uint32_t* pTargetIndex = &rpInstanceIndices[ nameCount - 1 ];

	bool bParsingName = true;

	pTestCharacter = pString + 1;
	for( ; ; )
	{
		char character = *pTestCharacter;
		if( character != HELIUM_PACKAGE_PATH_CHAR && character != HELIUM_OBJECT_PATH_CHAR && character != TXT( '\0' ) )
		{
			// Make sure the character is a valid number when parsing the instance index.
			if( !bParsingName && ( character < TXT( '0' ) || character > TXT( '9' ) ) )
			{
				HELIUM_TRACE(
					TraceLevels::Error,
					TXT( "AssetPath: Encountered non-numeric instance index value in path string \"%s\".\n" ),
					*pString );

				return false;
			}

			if( bParsingName && character == HELIUM_INSTANCE_PATH_CHAR )
			{
				// Encountered a separator for the instance index, so begin parsing it.
				*pTempNameCharacter = TXT( '\0' );

				pTargetName->Set( pTempNameString );
				--pTargetName;

				pTempNameCharacter = pTempNameString;
				bParsingName = false;
			}
			else
			{
				HELIUM_ASSERT( static_cast< size_t >( pTempNameCharacter - pTempNameString ) < nameLengthMax );
				*pTempNameCharacter = character;
				++pTempNameCharacter;
			}
		}
		else
		{
			*pTempNameCharacter = TXT( '\0' );

			if( bParsingName )
			{
				pTargetName->Set( pTempNameString );
				--pTargetName;

				SetInvalid( *pTargetIndex );
				--pTargetIndex;
			}
			else
			{
				if( pTempNameCharacter == pTempNameString )
				{
					HELIUM_TRACE(
						TraceLevels::Error,
						TXT( "AssetPath: Empty instance index encountered in path string \"%s\".\n" ),
						pString );
开发者ID:KETMGaming,项目名称:Helium,代码行数:67,代码来源:AssetPath.cpp


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