bool AnalyticVolume::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); if (stream.getSBMLNamespaces() == NULL) { stream.setSBMLNamespaces(new SBMLNamespaces(getLevel(), getVersion())); } delete mMath; mMath = readMathML(stream, prefix); 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 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; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool InitialAssignment::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } if (mMath != NULL) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <math> element is permitted inside a " "particular containing element."); } else { logError(OneMathElementPerInitialAssign, getLevel(), getVersion(), "The <initialAssignment> with symbol '" + getSymbol() + "' contains more than one <math> element."); } } /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); if (mMath != NULL) mMath->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
/* * Creates a new XMLNode by reading XMLTokens from stream. The stream must * be positioned on a start element (stream.peek().isStart() == true) and * will be read until the matching end element is found. */ XMLNode::XMLNode (XMLInputStream& stream) : XMLToken( stream.next() ) { if ( isEnd() ) return; std::string s; while ( stream.isGood() ) { const XMLToken& next = stream.peek(); if ( next.isStart() ) { addChild( XMLNode(stream) ); } else if ( next.isText() ) { s = trim(next.getCharacters()); if (s != "") addChild( stream.next() ); else stream.skipText(); } else if ( next.isEnd() ) { stream.next(); break; } } }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, PolygonObject. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool ParametricObject::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "PolygonObject") { delete mPolygonObject; mPolygonObject = PolygonObject::readPolygonObject(stream); if (mPolygonObject) mPolygonObject->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * *------------------------------- */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
bool ArraysASTPlugin::readMatrixRow(XMLInputStream& stream, const std::string& reqd_prefix, const XMLToken& currentElement) { bool read = false; stream.skipText(); const XMLToken nextElement = stream.peek(); const string& nextName = nextElement.getName(); unsigned int numChildren = determineNumChildren(stream, "matrixrow"); mVector = new ASTArraysVectorFunctionNode(AST_LINEAR_ALGEBRA_MATRIXROW_CONSTRUCTOR); mVector->setExpectedNumChildren(numChildren); // read attributes on this element here since we have already consumed // the element ExpectedAttributes expectedAttributes; mVector->addExpectedAttributes(expectedAttributes, stream); read = mVector->ASTBase::readAttributes(currentElement.getAttributes(), expectedAttributes, stream, currentElement); if (read == false) { mVector = NULL; } else { read = mVector->read(stream, reqd_prefix); } 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; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool StoichiometryMath::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); if (mMath) mMath->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
bool SedSetValue::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); read = true; } if (SedBase::readOtherXML(stream)) { read = true; } return read; }
bool ASTCnExponentialNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.peek (); const string& name = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (name != "cn") { #if 0 cout << "HELP\n"; #endif return read; } ASTCnBase::read(stream, reqd_prefix); std::string type; element.getAttributes().readInto("type", type); if (type == "e-notation") { double mantissa = 0; long exponent = 0; istringstream ismantissa; istringstream isexponent; ismantissa.str( stream.next().getCharacters() ); ismantissa >> mantissa; if (stream.peek().getName() == "sep") { stream.next(); isexponent.str( stream.next().getCharacters() ); isexponent >> exponent; }
bool Uncertainty::readOtherXML(XMLInputStream& stream) { const string& name = stream.peek().getName(); if (name == "UncertML") { delete mUncertML; XMLNode * xml = new XMLNode(stream); mUncertML = new UncertMLNode(xml); delete xml; return true; } return false; }
bool ASTCnRealNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.peek (); const string& name = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (name != "cn") { #if 0 cout << "HELP\n"; #endif return read; } ASTCnBase::read(stream, reqd_prefix); std::string type = "real"; element.getAttributes().readInto("type", type); if (type == "real") { double value = 0; istringstream isreal; isreal.str( stream.next().getCharacters() ); isreal >> value; setReal(value); ASTBase::setType(AST_REAL); if (isreal.fail() || (util_isInf(getValue()) > 0) || (util_isInf(getValue()) < 0) ) { logError(stream, element, FailedMathMLReadOfDouble); } read = true; }
bool ASTCnIntegerNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.peek (); const string& name = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (name != "cn") { cout << "HELP\n"; return read; } ASTCnBase::read(stream, reqd_prefix); std::string type; element.getAttributes().readInto("type", type); if (type == "integer") { int value = 0; istringstream isint; isint.str( stream.next().getCharacters() ); isint >> value; if (isint.fail()) { logError(stream, element, FailedMathMLReadOfInteger); } else if ( sizeof(int) > 4 && ( (value > SBML_INT_MAX) || (value < SBML_INT_MIN) ) ) { logError(stream, element, FailedMathMLReadOfInteger); } setInteger(value); ASTBase::setType(AST_INTEGER); read = true; }
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; }
/** @cond doxygenLibsbmlInternal */ bool FbcModelPlugin::readOtherXML (SBase* parentObject, XMLInputStream& stream) { #ifndef ANNOATION return false; #else bool readAnnotationFromStream = false; const string& name = stream.peek().getName(); if (!(name.empty()) && name != "annotation") { return readAnnotationFromStream; } try { XMLNode *pAnnotation = parentObject->getAnnotation(); FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion()); if (!pAnnotation) { // // (NOTES) // // annotation element has not been parsed by the parent element // (Model) of this plugin object, thus annotation element is // parsed via the given XMLInputStream object in this block. // const string& name = stream.peek().getName(); if (name == "annotation") { pAnnotation = new XMLNode(stream); parseFbcAnnotation(pAnnotation, mAssociations, fbcns); if (mAssociations.size() > 0) { // // Removes the annotation for layout extension from the annotation // of parent element (pAnnotation) and then set the new annotation // (newAnnotation) to the parent element. // XMLNode *newAnnotation = deleteFbcAnnotation(pAnnotation); parentObject->setAnnotation(newAnnotation); delete newAnnotation; } else { // // No layout annotation is included in the read annotation // (pAnnotation) and thus just set the annotation to the parent // element. // parentObject->setAnnotation(pAnnotation); } delete pAnnotation; readAnnotationFromStream = true; } } else if (mAssociations.size() == 0) { // // (NOTES) // // annotation element has been parsed by the parent element // (Model) of this plugin object, thus the annotation element // set to the above pAnnotation variable is parsed in this block. // parseFbcAnnotation(pAnnotation, mAssociations, fbcns); if (mAssociations.size() > 0) { // // Removes the annotation for layout extension from the annotation // of parent element (pAnnotation) and then set the new annotation // (newAnnotation) to the parent element. // XMLNode *newAnnotation = deleteFbcAnnotation(pAnnotation); parentObject->setAnnotation(newAnnotation); } readAnnotationFromStream = true; } delete fbcns; } catch(...) { // an exception occured, most likely becase a namespace constructor // threw an exception, catching this here, and return false, to indicate // that the annotation wasn't read. readAnnotationFromStream = false; } return readAnnotationFromStream; #endif }
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; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool SpeciesReference::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); // if (name == "stoichiometryMath") // { // const XMLToken wrapperElement = stream.next(); // stream.skipText(); // const XMLToken element = stream.peek(); // bool found = false; // /* The first element must always be 'math'. */ // if (element.getName() != "math") // { // found = true; // } // /* Check this declares the MathML namespace. This may be explicitly // * declared here or implicitly declared on the whole document // */ // if (!found && element.getNamespaces().getLength() != 0) // { // for (int n = 0; n < element.getNamespaces().getLength(); n++) // { // if (!strcmp(element.getNamespaces().getURI(n).c_str(), // "http://www.w3.org/1998/Math/MathML")) // { // found = true; // break; // } // } // } // if (!found && mSBML->getNamespaces() != 0) // { // /* check for implicit declaration */ // for (int n = 0; n < mSBML->getNamespaces()->getLength(); n++) // { //if (!strcmp(mSBML->getNamespaces()->getURI(n).c_str(), // "http://www.w3.org/1998/Math/MathML")) //{ // found = true; // break; //} // } // } // if (! found) // { // static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError(10201); // } // delete mStoichiometryMath; // mStoichiometryMath = readMathML(stream); // read = true; // stream.skipPastEnd(wrapperElement); // if (mStoichiometryMath && mStoichiometryMath->isRational()) // { // mStoichiometry = mStoichiometryMath->getNumerator(); // mDenominator = mStoichiometryMath->getDenominator(); // delete mStoichiometryMath; // mStoichiometryMath = 0; // } // } //else // This has to do additional work for reading annotations, so the code // here is copied and expanded from SBase::readNotes(). if (name == "annotation") { // XMLNode* new_annotation = NULL; /* if annotation already exists then it is an error */ if (mAnnotation != NULL) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <annotation> element is permitted inside a " "particular containing element."); } else { string msg = "An SBML <speciesReference> element "; if (isSetId()) { msg += "with the id '" + getId() + "' "; } msg += "has multiple <annotation> children."; logError(MultipleAnnotations, getLevel(), getVersion(), msg); } } delete mAnnotation; mAnnotation = new XMLNode(stream); checkAnnotation(); if (mCVTerms != NULL) { unsigned int size = mCVTerms->getSize(); while (size--) delete static_cast<CVTerm*>( mCVTerms->remove(0) ); delete mCVTerms; } mCVTerms = new List(); delete mHistory; if (RDFAnnotationParser::hasHistoryRDFAnnotation(mAnnotation)) { mHistory = RDFAnnotationParser::parseRDFAnnotation(mAnnotation, getMetaId().c_str(), &(stream)); if (mHistory != NULL && mHistory->hasRequiredAttributes() == false) { logError(RDFNotCompleteModelHistory, getLevel(), getVersion(), "An invalid ModelHistory element has been stored."); } setModelHistory(mHistory); } else mHistory = NULL; if (RDFAnnotationParser::hasCVTermRDFAnnotation(mAnnotation)) RDFAnnotationParser::parseRDFAnnotation(mAnnotation, mCVTerms, getMetaId().c_str(), &(stream)); // new_annotation = RDFAnnotationParser::deleteRDFAnnotation(mAnnotation); // delete mAnnotation; // mAnnotation = new_annotation; read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool Constraint::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } if (mMath) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <math> element is permitted inside a " "particular containing element."); } else { logError(OneMathElementPerConstraint, getLevel(), getVersion(), "The <constraint> contains more than one <math> element."); } } // If there's a <message>, it's supposed to show up first if (mMessage && getLevel() == 2) logError(IncorrectOrderInConstraint); /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); if (mMath) mMath->setParentSBMLObject(this); read = true; } else if (name == "message") { if (mMessage) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <message> element is permitted inside a " "particular containing element."); } else { logError(OneMessageElementPerConstraint, getLevel(), getVersion()); } } delete mMessage; mMessage = new XMLNode(stream); // // checks if the given default namespace (if any) is a valid // SBML namespace // const XMLNamespaces &xmlns = mMessage->getNamespaces(); checkDefaultNamespace(&xmlns,"message"); if (getSBMLDocument() != NULL) { if (getSBMLDocument()->getNumErrors() == 0) { checkXHTML(mMessage); } } read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool InitialAssignment::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } if (mMath) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <math> element is permitted inside a " "particular containing element."); } else { logError(OneMathElementPerInitialAssign, getLevel(), getVersion()); } } /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); unsigned int match = 0; int n; if (elem.getNamespaces().getLength() != 0) { for (n = 0; n < elem.getNamespaces().getLength(); n++) { if (!strcmp(elem.getNamespaces().getURI(n).c_str(), "http://www.w3.org/1998/Math/MathML")) { match = 1; break; } } } if (match == 0) { if( mSBML->getNamespaces() != NULL) /* check for implicit declaration */ { for (n = 0; n < mSBML->getNamespaces()->getLength(); n++) { if (!strcmp(mSBML->getNamespaces()->getURI(n).c_str(), "http://www.w3.org/1998/Math/MathML")) { match = 1; break; } } } } if (match == 0) { logError(InvalidMathElement); } delete mMath; mMath = readMathML(stream); if (mMath) mMath->setParentSBMLObject(this); read = true; } return read; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool Rule::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } if (mMath != NULL) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <math> element is permitted inside a " "particular containing element."); } else { std::string details; if (isAssignment() == true) { details = "The <assignmentRule> with variable '" + getVariable() +"'"; } else if (isRate() == true) { details = "The <rateRule> with variable '" + getVariable() +"'"; } else { details = "The <algebraicRule>"; } details += " contains more than one <math> element."; logError(OneMathElementPerRule, getLevel(), getVersion(), details); } } delete mMath; /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); mMath = readMathML(stream, prefix); if (mMath != NULL) mMath->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; 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; }
bool LayoutSpeciesReferencePlugin::readOtherXML (SBase* parentObject, XMLInputStream& stream) { if (!parentObject) return false; bool readAnnotationFromStream = false; // // This plugin object is used only for SBML Level 2 Version 1. // if ( getURI() != LayoutExtension::getXmlnsL2() ) return false; if ( parentObject->getVersion() > 1 ) return false; XMLNode *pAnnotation = parentObject->getAnnotation(); if (!pAnnotation) { // // (NOTES) // // annotation element has not been parsed by the parent element // (SpeciesReference) of this plugin object, thus annotation // element is parsed via the given XMLInputStream object in this block. // const string& name = stream.peek().getName(); if (name == "annotation") { pAnnotation = new XMLNode(stream); SpeciesReference *sr = static_cast<SpeciesReference*>(parentObject); parseSpeciesReferenceAnnotation(pAnnotation,*sr); std::string srId = sr->getId(); if (!srId.empty()) { // // Removes the annotation for layout extension from the annotation // of parent element (pAnnotation) and then set the new annotation // (newAnnotation) to the parent element. // XMLNode *newAnnotation = deleteLayoutIdAnnotation(pAnnotation); parentObject->setAnnotation(newAnnotation); delete newAnnotation; } else { // // No layout annotation is included in the read annotation // (pAnnotation) and thus just set the annotation to the parent // element. // parentObject->setAnnotation(pAnnotation); } delete pAnnotation; readAnnotationFromStream = true; } } else if (parentObject->getId().empty()) { // // (NOTES) // // annotation element has been parsed by the parent element // (SpeciesReference) of this plugin object, thus the annotation element // set to the above pAnnotation variable is parsed in this block. // SpeciesReference *sr = static_cast<SpeciesReference*>(parentObject); parseSpeciesReferenceAnnotation(pAnnotation, *sr); std::string srId = sr->getId(); if (!srId.empty()) { // // Removes the annotation for layout extension from the annotation // of parent element (pAnnotation) and then set the new annotation // (newAnnotation) to the parent element. // XMLNode *newAnnotation = deleteLayoutIdAnnotation(pAnnotation); parentObject->setAnnotation(newAnnotation); delete newAnnotation; } readAnnotationFromStream = true; } return readAnnotationFromStream; }