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


C++ ClassList::getRef方法代码示例

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


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

示例1: addSingleChain

void NerveTool::addSingleChain( StringList& fibersinfo , String type , ClassList<StringList>& chain , int from , int to ) {
	StringList mids;
	for( int k = from + 1; k < to; k++ )
		mids.add( chain.getRef( k ).get( 0 ) );

	addFiberItem( fibersinfo , type , chain.getRef( from ).get( 0 ) , chain.getRef( to ).get( 0 ) , mids );
}
开发者ID:AbhishekGhosh,项目名称:Artificial-Human,代码行数:7,代码来源:nervetool.cpp

示例2: output_nerve

void NerveTool::output_nerve( FILE *sout , ClassList<Nerve>& nn , int k ) {
	Nerve& n = nn.getRef( k );

	bool hasChilds = false;
	int upLevelCount = 0;
	if( nn.count() > ( k + 1 ) ) {
		Nerve& nx = nn.getRef( k + 1 );
		if( nx.level > n.level )
			hasChilds = true;
		else
			upLevelCount = n.level - nx.level;
	}
	else
		upLevelCount = n.level;

	String tabs = String( "\t" ).replicate( 2 + n.level );
	String s = tabs + "<element name=\"" + n.name + "\"";
	if( !n.synonyms.isEmpty() )
		s += "\n" + tabs + "\tsynonyms=\"" + n.synonyms + "\"";
	if( !n.origin.isEmpty() )
		s += "\n" + tabs + "\torigin=\"" + n.origin + "\"";
	if( !n.distribution.isEmpty() )
		s += "\n" + tabs + "\tdistribution=\"" + n.distribution + "\"";
	if( !n.imginfo.isEmpty() )
		s += "\n" + tabs + "\t" + n.imginfo;
	if( !n.modality.isEmpty() )
		s += "\n" + tabs + "\tmodality=\"" + n.modality + "\"";

	if( n.fibers.isEmpty() ) {
		if( hasChilds )
			s +="\n" + tabs + "\t>\n";
		else
			s +="\n" + tabs + "\t/>\n";
	}
	else {
		s += "\n" + tabs + "\t>";

		String fibersinfo;
		for( int z = 0; z < n.fibersinfo.count(); z++ )
			fibersinfo += tabs + "\t" + n.fibersinfo.get( z ) + "\n";

		s += "\n" + fibersinfo;
		if( !hasChilds )
			s += tabs + "</element>\n";
	}

	for( int z = 1; z <= upLevelCount; z++ ) {
		tabs = String( "\t" ).replicate( 2 + n.level - z );
		s += tabs + "</element>\n";
	}

	if( ( n.level == 0 && hasChilds == false ) || ( n.level > 0 && ( n.level - upLevelCount ) == 0 ) )
		s += "\n";

	fprintf( sout , "%s" , ( const char * )s );
}
开发者ID:AbhishekGhosh,项目名称:Artificial-Human,代码行数:56,代码来源:nervetool.cpp

示例3: getNerveDivision_fibers

String WikiNerveSpecPages::getNerveDivision_fibers( ClassList<XmlNerveFiberInfo>& fibers ) {
	String s;
	for( int k = 0; k < fibers.count(); k++ ) {
		XmlNerveFiberInfo& fiber = fibers.getRef( k );
		if( k > 0 )
			s += "; ";
		s += fiber.type + ":" + getNerveDivision_fiberchain( fiber );
	}
	return( s );
}
开发者ID:AbhishekGhosh,项目名称:Artificial-Human,代码行数:10,代码来源:wikinervespecpages.cpp

示例4: execute_img

int NerveTool::execute_img( String& s , FILE *sout , int level , ClassList<Nerve>& nn ) {
	// extract
	if( !s.startsFrom( "<img src=\"" ) )
		return( 101 );

	s.remove( 0 , strlen( "<img src=\"" ) );

	int idx = s.find( "\"" );
	if( idx < 0 )
		return( 102 );

	String s1 = s.getMid( 0 , idx );
	s.remove( 0 , idx + 1 );
	s.trim();

	s.trimTrailing( '>' );
	String height;
	if( s.startsFrom( "height=" ) )
		height = s.getMid( strlen( "height=" ) );

	// create string
	String img = "imgsrc=\"" + s1 + "\"";
	if( !height.isEmpty() )
		img += " imgheight=\"" + height + "\"";

	// find nerve to add to - upper with level - 1
	for( int k = nn.count() - 1; k >= 0; k-- ) {
		Nerve& n = nn.getRef( k );
		if( n.level < level ) {
			if( !n.imginfo.isEmpty() )
				return( false );

			n.imginfo = img;
			return( 0 );
		}
	}

	return( 100 );
}
开发者ID:AbhishekGhosh,项目名称:Artificial-Human,代码行数:39,代码来源:nervetool.cpp

示例5: extract_fiberitems

bool NerveTool::extract_fiberitems( FILE *sout , StringList& fibersinfo , String type , String& value ) {
	// parse value: x,y -> x,y -> x,y ...
	ClassList<StringList> chain;

	value.trim();
	while( !value.isEmpty() ) {
		String part;
		int idx = value.find( "->" );
		if( idx < 0 ) {
			if( chain.count() == 0 )
				return( false );

			part = value;
			value.clear();
		}
		else {
			part = value.getMid( 0 , idx );
			value.remove( 0 , idx + 2 );
			value.trim();

			if( value.isEmpty() )
				return( false );
		}

		// parse part
		StringList *z = new StringList;
		chain.add( z );
		if( !extract_codes( part , z ) ) {
			fprintf( sout , "wrong part=%s\n" , ( const char * )part );
			return( false );
		}

		// prohibit many-to-many		
		if( z -> count() > 1 && chain.count() > 1 ) {
			StringList& zp = chain.getRef( chain.count() - 2 );
			if( zp.count() > 1 )
				return( false );
		}
	}

	// chain of more than one
	if( chain.count() < 2 )
		return( false );

	// split chain
	int startChain = 0;
	int startChainCount = 0;
	for( int k = 0; k < chain.count(); k++ ) {
		StringList& z = chain.getRef( k );
		int zn = z.count();

		// starter
		if( k == 0 ) {
			startChainCount = zn;
			continue;
		}

		// many to one - split
		if( startChainCount > 1 ) {
			if( zn != 1 )
				return( false );

			addManyToOne( fibersinfo , type , chain.getRef( startChainCount ) , z.get( 0 ) );
			startChain = k;
			startChainCount = zn;
			continue;
		}

		// allow x -> y -> z as is
		if( zn == 1 ) {
			if( k == chain.count() - 1 ) {
				addSingleChain( fibersinfo , type , chain , startChain , k );
				break;
			}

			continue;
		}

		// x -> y -> x,y - split to x -> y and y -> x,y
		if( ( k - 1 ) > startChain ) {
			addSingleChain( fibersinfo , type , chain , startChain , k - 1 );
			startChain = k - 1;
			startChainCount = 1;
		}

		addOneToMany( fibersinfo , type , chain.getRef( startChain ).get( 0 ) , z );
		startChain = k;
		startChainCount = zn;
	}

	chain.destroy();

	return( true );
}
开发者ID:AbhishekGhosh,项目名称:Artificial-Human,代码行数:94,代码来源:nervetool.cpp


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