bool ASTCiNumberNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.next (); const string& nameE = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (nameE != "ci") { #if 0 cout << "HELP\n"; #endif return read; } ExpectedAttributes expectedAttributes; addExpectedAttributes(expectedAttributes, stream); read = readAttributes(element.getAttributes(), expectedAttributes, stream, element); const string name = trim( stream.next().getCharacters() ); setName((name)); ASTBase::setType(AST_NAME); if (read == true) stream.skipPastEnd(element); return read; }
/* * Reads other XML such as math/notes etc. */ bool Uncertainty::readOtherXML(XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "UncertML") { const XMLToken& token = stream.next(); stream.skipText(); delete mUncertML; XMLNode* xml = new XMLNode(stream); mUncertML = new UncertMLNode(xml); stream.skipPastEnd(token); delete xml; read = true; } if (SBase::readOtherXML(stream)) { read = true; } return read; }
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; }
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; }
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; }