本文整理汇总了C++中ASTBase::read方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTBase::read方法的具体用法?C++ ASTBase::read怎么用?C++ ASTBase::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTBase
的用法示例。
在下文中一共展示了ASTBase::read方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNumPiece
bool
ASTPiecewiseFunctionNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
ASTBase * child = NULL;
unsigned int numPiece = getNumPiece();
unsigned int numChildrenAdded = 0;
// read in piece
// these are functions as they will be created as ASTQualifierNodes
while(numChildrenAdded < numPiece)
{
child = new ASTFunction();
read = child->read(stream, reqd_prefix);
if (read == true && addChild(child, true) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
}
else
{
read = false;
break;
}
}
// if there were no piece statements mark read true so we can continue
if (numPiece == 0)
{
read = true;
}
if (read == true && getHasOtherwise() == true)
{
child = new ASTFunction();
read = child->read(stream, reqd_prefix);
if (read == true && addChild(child, true) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
}
else
{
read = false;
}
}
return read;
}
示例2: setType
bool
ASTUnaryFunctionNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
ASTBase * child = NULL;
const XMLToken element = stream.peek ();
ASTBase::checkPrefix(stream, reqd_prefix, element);
const char* name = element.getName().c_str();
setType(getTypeFromName(name));
ASTBase::read(stream, reqd_prefix);
unsigned int numChildrenAdded = 0;
if (getExpectedNumChildren() > 0)
{
while (stream.isGood() && numChildrenAdded < getExpectedNumChildren())
{
stream.skipText();
name = stream.peek().getName().c_str();
if (representsNumber(ASTBase::getTypeFromName(name)) == true)
{
child = new ASTNumber();
}
else
{
child = new ASTFunction();
}
read = child->read(stream, reqd_prefix);
stream.skipText();
if (read == true && addChild(child) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
}
else
{
delete child;
child = NULL;
read = false;
break;
}
}
}
else
{
stream.skipPastEnd(element);
read = true;
}
return read;
}
示例3: ASTNumber
bool
ASTSemanticsNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
ASTBase * child = NULL;
const XMLToken element = stream.peek ();
ASTBase::checkPrefix(stream, reqd_prefix, element);
const char* name;// = element.getName().c_str();
if (stream.isGood())// && stream.peek().isEndFor(element) == false)
{
stream.skipText();
name = stream.peek().getName().c_str();
if (representsNumber(ASTBase::getTypeFromName(name)) == true)
{
child = new ASTNumber();
}
else
{
child = new ASTFunction();
}
read = child->read(stream, reqd_prefix);
stream.skipText();
if (read == false || addChild(child) != LIBSBML_OPERATION_SUCCESS)
{
delete child;
child = NULL;
read = false;
}
}
unsigned int i = 0;
while ( i < getNumAnnotations())
{
if (stream.peek().getName() == "annotation"
|| stream.peek().getName() == "annotation-xml")
{
XMLNode semanticAnnotation = XMLNode(stream);
addSemanticsAnnotation(semanticAnnotation.clone());
i++;
}
else
{
stream.next();
}
}
return true;
}
示例4: getTypeFromName
bool
ASTNaryFunctionNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
ASTBase * child = NULL;
const XMLToken element = stream.peek ();
ASTBase::checkPrefix(stream, reqd_prefix, element);
const char* name = element.getName().c_str();
int type = getTypeFromName(name);
setType(type);
ASTBase::read(stream, reqd_prefix);
unsigned int numChildrenAdded = 0;
if (getExpectedNumChildren() > 0)
{
while (stream.isGood() && numChildrenAdded < getExpectedNumChildren())
{
stream.skipText();
name = stream.peek().getName().c_str();
if (representsNumber(ASTBase::getTypeFromName(name)) == true)
{
child = new ASTNumber();
}
else
{
child = new ASTFunction();
}
read = child->read(stream, reqd_prefix);
stream.skipText();
if (read == true && addChild(child) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
}
else
{
delete child;
child = NULL;
read = false;
break;
}
}
}
else
{
stream.skipPastEnd(element);
read = true;
}
if (read == true && type == AST_FUNCTION_ROOT
&& getExpectedNumChildren() == 1
&& ASTFunctionBase::getChild(0)->getType() != AST_QUALIFIER_DEGREE)
{
/* HACK TO REPLICATE OLD BEHAVIOUR */
/* we need to add the qualifier child for the degree 2 */
ASTFunction * degree = new ASTFunction(AST_QUALIFIER_DEGREE);
ASTNumber * int2 = new ASTNumber(AST_INTEGER);
int2->setInteger(2);
degree->addChild(int2->deepCopy());
this->prependChild(degree->deepCopy());
delete int2;
delete degree;
}
//if (read == false)
//{
// stream.skipPastEnd(element);
//}
return read;
}
示例5: trim
bool
ASTCSymbolDelayNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
XMLToken element = stream.peek ();
const string& nameE = element.getName();
if (nameE != "csymbol")
{
#if 0
cout << "HELP\n";
#endif
return read;
}
ASTBase::read(stream, reqd_prefix);
const string nameDelay = trim( stream.next().getCharacters() );
setName((nameDelay));
ASTBase::setType(AST_FUNCTION_DELAY);
stream.skipPastEnd(element);
const char * name;
ASTBase * child = NULL;
unsigned int numChildrenAdded = 0;
// catch if we do not have two children
if (getExpectedNumChildren() > 0)
{
while (stream.isGood() && numChildrenAdded < getExpectedNumChildren())
{
stream.skipText();
name = stream.peek().getName().c_str();
if (representsNumber(ASTBase::getTypeFromName(name)) == true)
{
child = new ASTNumber();
}
else
{
child = new ASTFunction();
}
read = child->read(stream, reqd_prefix);
stream.skipText();
if (read == true && addChild(child) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
}
else
{
read = false;
break;
}
}
}
else
{
stream.skipPastEnd(element);
read = true;
}
return read;
}
示例6: getNumBvars
bool
ASTLambdaFunctionNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
ASTBase * child = NULL;
const char* name;
unsigned int numBvars = getNumBvars();
unsigned int numChildrenAdded = 0;
// read in bvars
// these are functions as they will be created as ASTQualifierNodes
while(numChildrenAdded < numBvars)
{
child = new ASTFunction();
read = child->read(stream, reqd_prefix);
if (read == true && addChild(child, true) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
}
else
{
delete child;
child = NULL;
read = false;
break;
}
}
// if we had no bvars to read mark read as true so we will continue
if (numBvars == 0)
{
read = true;
}
while (read == true && stream.isGood()
&& numChildrenAdded < getExpectedNumChildren())
{
stream.skipText();
name = stream.peek().getName().c_str();
if (representsNumber(ASTBase::getTypeFromName(name)) == true)
{
child = new ASTNumber();
}
else
{
child = new ASTFunction();
}
/* read = */ child->read(stream, reqd_prefix);
stream.skipText();
if (addChild(child) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
read = true;
}
else
{
delete child;
child = NULL;
read = false;
break;
}
}
return read;
}