本文整理汇总了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 );
}
示例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 );
}
示例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 );
}
示例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 );
}
示例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 );
}