本文整理汇总了C++中Namespace::addType方法的典型用法代码示例。如果您正苦于以下问题:C++ Namespace::addType方法的具体用法?C++ Namespace::addType怎么用?C++ Namespace::addType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Namespace
的用法示例。
在下文中一共展示了Namespace::addType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defineBuiltInTypes
void TypeManager::defineBuiltInTypes()
{
Namespace* rootNS = _rootNS.get();
// register all basic types in the root namespace:
for( uint8 k = 0; k < TK_COUNT; ++k )
{
TypeComponent* type = static_cast<TypeComponent*>( BASIC_TYPES[k].get() );
if( !type ) continue;
type->setNamespace( rootNS );
rootNS->addType( type );
}
// pre-load the 'co.IService' type and all its dependencies
Namespace* coNS = static_cast<Namespace*>( rootNS->defineChildNamespace( "co" ) );
assert( coNS );
RefPtr<Interface> serviceType = new Interface;
serviceType->setType( TK_INTERFACE, "IService", coNS );
coNS->addType( serviceType.get() );
loadTypeOrThrow( "co.IService" );
}
示例2: getArrayOf
IArray* TypeManager::getArrayOf( IType* elementType )
{
if( !elementType )
CORAL_THROW( IllegalArgumentException, "null element type" );
const std::string& elementTypeName = elementType->getName();
std::string arrayName;
arrayName.reserve( elementTypeName.length() + 2 );
arrayName.append( elementTypeName );
arrayName.append( "[]" );
Namespace* ns = static_cast<Namespace*>( elementType->getNamespace() );
// try to locate an existing array of this type
IType* existingArrayType = ns->getType( arrayName );
if( existingArrayType )
{
assert( existingArrayType->getKind() == TK_ARRAY );
return static_cast<IArray*>( existingArrayType );
}
// otherwise, try to create it
TypeKind kind = elementType->getKind();
if( kind == TK_ARRAY )
CORAL_THROW( IllegalArgumentException, "arrays of arrays are illegal" );
if( !isData( kind ) )
CORAL_THROW( IllegalArgumentException, "arrays of " << kind << "s are illegal" );
RefPtr<ArrayType> arrayType = new ArrayType;
arrayType->setType( TK_ARRAY, elementType->getName() + "[]", ns );
arrayType->setElementType( elementType );
ns->addType( arrayType.get() );
return arrayType.get();
}