本文整理汇总了C++中ASTNode::setIsChildFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::setIsChildFlag方法的具体用法?C++ ASTNode::setIsChildFlag怎么用?C++ ASTNode::setIsChildFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::setIsChildFlag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int
ASTFunctionBase::insertChild(unsigned int n, ASTBase* newChild)
{
if (newChild == NULL) return LIBSBML_INVALID_OBJECT;
int inserted = LIBSBML_INDEX_EXCEEDS_SIZE;
unsigned int size = ASTFunctionBase::getNumChildren();
if (n == 0)
{
ASTFunctionBase::prependChild(newChild);
inserted = LIBSBML_OPERATION_SUCCESS;
}
else if (n <= size)
{
/* starting at the end take each child in the list and prepend it
* then remove it from the end
* at the insertion point prepend the newChild
* eg list: a, b, c
* inserting d at position 2
* list goes: c, a, b : d, c, a, b : b, d, c, a : a, b, d, c
*/
bool childIsNode = dynamic_cast<ASTNode*>(newChild);
if (childIsNode)
{
mChildren.insert(mChildren.begin() + n, newChild);
newChild->setIsChildFlag(true);
}
else
{
ASTFunction* childAsFunction = dynamic_cast<ASTFunction*>(newChild);
ASTNumber* childAsNumber = dynamic_cast<ASTNumber*>(newChild);
// wrap it
ASTNode* tmp = childAsFunction != NULL ? new ASTNode(childAsFunction) : new ASTNode(childAsNumber);
mChildren.insert(mChildren.begin()+n, tmp);
tmp->setIsChildFlag(true);
}
if (ASTFunctionBase::getNumChildren() == size + 1)
{
inserted = LIBSBML_OPERATION_SUCCESS;
}
}
return inserted;
}
示例2: ASTNode
int
ASTFunctionBase::addChild(ASTBase * child, bool /*inRead = false*/)
{
if (child == NULL)
{
return LIBSBML_INVALID_OBJECT;
}
unsigned int numBefore = ASTFunctionBase::getNumChildren();
bool childIsNode = dynamic_cast<ASTNode*>(child);
if (childIsNode)
{
mChildren.push_back(child);
child->setIsChildFlag(true);
}
else
{
ASTFunction* childAsFunction = dynamic_cast<ASTFunction*>(child);
ASTNumber* childAsNumber = dynamic_cast<ASTNumber*>(child);
// wrap it
ASTNode* tmp = childAsFunction != NULL ? new ASTNode(childAsFunction) : new ASTNode(childAsNumber);
mChildren.push_back(tmp);
tmp->setIsChildFlag(true);
}
if (ASTFunctionBase::getNumChildren() == numBefore + 1)
{
return LIBSBML_OPERATION_SUCCESS;
}
else
{
return LIBSBML_OPERATION_FAILED;
}
}