void ASTBase::logError (XMLInputStream& stream, const XMLToken& element, SBMLErrorCode_t code, const std::string& msg) { SBMLNamespaces* ns = stream.getSBMLNamespaces(); if (ns != NULL) { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError( code, ns->getLevel(), ns->getVersion(), msg, element.getLine(), element.getColumn()); } else { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError( code, SBML_DEFAULT_LEVEL, SBML_DEFAULT_VERSION, msg, element.getLine(), element.getColumn()); } }
/** * Sets the type of an ASTNode based on the given MathML <cn> element. * Errors will be logged in the stream's SBMLErrorLog object. */ static void setTypeCN (ASTNode& node, const XMLToken& element, XMLInputStream& stream) { string type = "real"; element.getAttributes().readInto("type", type); // here is the only place we might encounter the sbml:units attribute string units = ""; element.getAttributes().readInto("units", units); if (type == "real") { double value = 0; istringstream isreal; isreal.str( stream.next().getCharacters() ); isreal >> value; node.setValue(value); if (isreal.fail() || node.isInfinity() || node.isNegInfinity() ) { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError(FailedMathMLReadOfDouble, stream.getSBMLNamespaces()->getLevel(), stream.getSBMLNamespaces()->getVersion()); } }
/** * Sets the type of an ASTNode based on the given MathML <ci> element. * Errors will be logged in the stream's SBMLErrorLog object. */ static void setTypeCI (ASTNode& node, const XMLToken& element, XMLInputStream& stream) { if (element.getName() == "csymbol") { string url; element.getAttributes().readInto("definitionURL", url); if ( url == URL_DELAY ) node.setType(AST_FUNCTION_DELAY); else if ( url == URL_TIME ) node.setType(AST_NAME_TIME); else if ( url == URL_AVOGADRO ) node.setType(AST_NAME_AVOGADRO); else { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError(BadCsymbolDefinitionURLValue, stream.getSBMLNamespaces()->getLevel(), stream.getSBMLNamespaces()->getVersion()); } } else if (element.getName() == "ci") { node.setDefinitionURL(element.getAttributes()); } const string name = trim( stream.next().getCharacters() ); node.setName( name.c_str() ); }