本文整理汇总了C++中TopologyNode::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ TopologyNode::setName方法的具体用法?C++ TopologyNode::setName怎么用?C++ TopologyNode::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopologyNode
的用法示例。
在下文中一共展示了TopologyNode::setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNode
TopologyNode* NewickConverter::createNode(const std::string &n, std::vector<TopologyNode*> &nodes, std::vector<double> &brlens) {
// create a string-stream and throw the string into it
std::stringstream ss (std::stringstream::in | std::stringstream::out);
ss << n;
char c;
ss.get(c);
// the initial character has to be '('
if ( c != '(') {
throw Exception("Error while converting Newick tree. We expected an opening parenthesis, but didn't get one.");
}
TopologyNode *node = new TopologyNode();
while ( ss.good() && ss.peek() != ')' ) {
TopologyNode *childNode;
if (ss.peek() == '(' ) {
// we received an internal node
int depth = 0;
std::string child = "";
do {
ss.get(c);
child += c;
if ( c == '(' ) {
depth++;
}
else if ( c == ')' ) {
depth--;
}
} while ( ss.good() && depth > 0 );
// construct the child node
childNode = createNode( child, nodes, brlens );
}
else {
// construct the node
childNode = new TopologyNode();
}
// set the parent child relationship
node->addChild( childNode );
childNode->setParent( node );
// read the optional label
std::string lbl = "";
while ( ss.good() && (c = ss.peek()) != ':' && c != '[' && c != ';' && c != ',' && c != ')') {
lbl += ss.get();
}
childNode->setName( lbl );
// read the optional node parameters
if ( ss.peek() == '[' ) {
ss.ignore();
do {
// ignore the '&' before parameter name
if ( ss.peek() == '&')
{
ss.ignore();
}
// read the parameter name
std::string paramName = "";
while ( ss.good() && (c = ss.peek()) != '=' && c != ',')
{
paramName += ss.get();
}
// ignore the equal sign between parameter name and value
if ( ss.peek() == '=')
{
ss.ignore();
}
// read the parameter name
std::string paramValue = "";
while ( ss.good() && (c = ss.peek()) != ']' && c != ',')
{
paramValue += ss.get();
}
// \todo: Needs implementation
// childNode->addNodeParameter(paramName, paramValue);
if(paramName == "index")
childNode->setIndex(atoi(paramValue.c_str()));
} while ( (c = ss.peek()) == ',' );
// ignore the final ']'
if ( (c = ss.peek()) == ']' )
{
ss.ignore();
}
}
// read the optional branch length
//.........这里部分代码省略.........