libSBML C++ API  5.20.4
ASTNode Class Reference

Detailed Description

Abstract Syntax Tree (AST) representation of a mathematical expression.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

Abstract Syntax Trees (ASTs) are a simple kind of data structure used in libSBML for storing mathematical expressions. The ASTNode is the cornerstone of libSBML's AST representation. An AST "node" represents the most basic, indivisible part of a mathematical formula and come in many types. For instance, there are node types to represent numbers (with subtypes to distinguish integer, real, and rational numbers), names (e.g., constants or variables), simple mathematical operators, logical or relational operators and functions. LibSBML ASTs provide a canonical, in-memory representation for all mathematical formulas regardless of their original format (which might be MathML or might be text strings).

An AST node in libSBML is a recursive tree structure; each node has a type, a pointer to a value, and a list of children nodes. Each ASTNode node may have none, one, two, or more children depending on its type. There are node types to represent numbers (with subtypes to distinguish integer, real, and rational numbers), names (e.g., constants or variables), simple mathematical operators, logical or relational operators and functions. The following diagram illustrates an example of how the mathematical expression "1 + 2" is represented as an AST with one plus node having two integer children nodes for the numbers 1 and 2. The figure also shows the corresponding MathML representation:
Example AST representation of a mathematical expression.
Infix AST MathML
1 + 2 <math xmlns="http://www.w3.org/1998/Math/MathML">
  <apply>
    <plus/>
    <cn type="integer"> 1 </cn>
    <cn type="integer"> 2 </cn>
  </apply>
</math>

The following are other noteworthy points about the AST representation in libSBML:

  • A numerical value represented in MathML as a real number with an exponent is preserved as such in the AST node representation, even if the number could be stored in a double data type. This is done so that when an SBML model is read in and then written out again, the amount of change introduced by libSBML to the SBML during the round-trip activity is minimized.
  • The children of an ASTNode are other ASTNode objects. The list of children is empty for nodes that are leaf elements, such as numbers. For nodes that are actually roots of expression subtrees, the list of children points to the parsed objects that make up the rest of the expression.

For many applications, the details of ASTs are irrelevant because libSBML provides text-string based translation functions such as SBML_formulaToL3String() and SBML_parseL3Formula(). If you find the complexity of using the AST representation of expressions too high for your purposes, perhaps the string-based functions will be more suitable.

ASTNodeType_t

Every ASTNode has an associated type code to indicate whether, for example, it holds a number or stands for an arithmetic operator. The type is recorded as a value drawn from the enumeration ASTNodeType_t. The list of possible types is quite long, because it covers all the mathematical functions that are permitted in SBML. The values are shown in the following table:
AST_CONSTANT_E AST_FUNCTION_CSC AST_LOGICAL_AND
AST_CONSTANT_FALSE AST_FUNCTION_CSCH AST_LOGICAL_IMPLIES2
AST_CONSTANT_PI AST_FUNCTION_DELAY AST_LOGICAL_NOT
AST_CONSTANT_TRUE AST_FUNCTION_EXP AST_LOGICAL_OR
AST_DIVIDE AST_FUNCTION_FACTORIAL AST_LOGICAL_XOR
AST_FUNCTION AST_FUNCTION_FLOOR AST_MINUS
AST_FUNCTION_ABS AST_FUNCTION_LN AST_NAME
AST_FUNCTION_ARCCOS AST_FUNCTION_LOG AST_NAME_AVOGADRO1
AST_FUNCTION_ARCCOSH AST_FUNCTION_MAX2 AST_NAME_TIME
AST_FUNCTION_ARCCOT AST_FUNCTION_MIN2 AST_ORIGINATES_IN_PACKAGE2
AST_FUNCTION_ARCCOTH AST_FUNCTION_PIECEWISE AST_PLUS
AST_FUNCTION_ARCCSC AST_FUNCTION_POWER AST_POWER
AST_FUNCTION_ARCCSCH AST_FUNCTION_QUOTIENT2 AST_RATIONAL
AST_FUNCTION_ARCSEC AST_FUNCTION_RATE_OF2 AST_REAL
AST_FUNCTION_ARCSECH AST_FUNCTION_REM2 AST_REAL_E
AST_FUNCTION_ARCSIN AST_FUNCTION_ROOT AST_RELATIONAL_EQ
AST_FUNCTION_ARCSINH AST_FUNCTION_SEC AST_RELATIONAL_GEQ
AST_FUNCTION_ARCTAN AST_FUNCTION_SECH AST_RELATIONAL_GT
AST_FUNCTION_ARCTANH AST_FUNCTION_SIN AST_RELATIONAL_LEQ
AST_FUNCTION_CEILING AST_FUNCTION_SINH AST_RELATIONAL_LT
AST_FUNCTION_COS AST_FUNCTION_TAN AST_RELATIONAL_NEQ
AST_FUNCTION_COSH AST_FUNCTION_TANH AST_TIMES
AST_FUNCTION_COT AST_INTEGER AST_UNKNOWN
AST_FUNCTION_COTH AST_LAMBDA
1 (Level 3 only)
2 (Level 3 Version 2+ only)

The types have the following meanings:

  • If the node is a predefined function or operator from SBML Level 1 (in the string-based formula syntax used in Level 1) or SBML Level 2 and 3 (in the subset of MathML used in SBML Levels 2 and 3), then the node's type will be either AST_FUNCTION_X, AST_LOGICAL_X, or AST_RELATIONAL_X, as appropriate. (Examples: AST_FUNCTION_LOG, AST_RELATIONAL_LEQ.)
  • If the node refers to a user-defined function, the node's type will be AST_FUNCTION (because it holds the name of the function).
  • If the node is a lambda expression, its type will be AST_LAMBDA.
  • (Levels 2 and 3 only) If the node is the special MathML csymbol time, the value of the node will be AST_NAME_TIME. (Note, however, that the MathML csymbol delay is translated into a node of type AST_FUNCTION_DELAY. The difference is due to the fact that time is a single variable, whereas delay is actually a function taking arguments.)
  • (Level 3 only) If the node is the special MathML csymbol avogadro, the value of the node will be AST_NAME_AVOGADRO.
  • (Level 3 Version 2+ only) If the node is the special MathML csymbol rateOf, the value of the node will be AST_FUNCTION_RATE_OF.
  • (Level 3 Version 2+ only) If the node is a MathML operator that originates in a package, it is included in the ASTNodeType_t list, but may not be legally used in an SBML document that does not include that package. This includes the node types from the 'Distributions' package (AST_DISTRIB_FUNCTION_NORMAL, AST_DISTRIB_FUNCTION_UNIFORM, etc.), and elements from MathML that were not included in core.

Converting between ASTs and text strings

The text-string form of mathematical formulas produced by SBML_formulaToString() and SBML_formulaToL3String(), and read by SBML_parseFormula() and SBML_parseL3Formula() are in a simple C-inspired infix notation. A formula in this text-string form can be handed to a program that understands SBML mathematical expressions, or used as part of a translation system. The libSBML distribution comes with an example program in the "examples" subdirectory called translateMath that implements an interactive command-line demonstration of translating infix formulas into MathML and vice-versa.

The formula strings may contain operators, function calls, symbols, and white space characters. The allowable white space characters are tab and space. The following are illustrative examples of formulas expressed in the syntax:

0.10 * k4^2
(vm * s1)/(km + s1)

The following table shows the precedence rules in this syntax. In the Class column, operand implies the construct is an operand, prefix implies the operation is applied to the following arguments, unary implies there is one argument, and binary implies there are two arguments. The values in the Precedence column show how the order of different types of operation are determined. For example, the expression a * b + c is evaluated as (a * b) + c because the * operator has higher precedence. The Associates column shows how the order of similar precedence operations is determined; for example, a - b + c is evaluated as (a - b) + c because the + and - operators are left-associative. The precedence and associativity rules are taken from the C programming language, except for the symbol ^, which is used in C for a different purpose. (Exponentiation can be invoked using either ^ or the function power.)

Token Operation Class Precedence Associates
namesymbol referenceoperand6n/a
(expression)expression groupingoperand6n/a
f(...)function callprefix6left
-negationunary5right
^powerbinary4left
*multiplicationbinary3left
/divisonbinary3left
+additionbinary2left
-subtractionbinary2left
,argument delimiterbinary1left
A table of the expression operators and their precedence in the text-string format for mathematical expressions used by SBML_parseFormula().

A program parsing a formula in an SBML model should assume that names appearing in the formula are the identifiers of Species, Parameter, Compartment, FunctionDefinition, Reaction (in SBML Levels 2 and 3), or SpeciesReference (in SBML Level 3 only) objects defined in a model. When a function call is involved, the syntax consists of a function identifier, followed by optional white space, followed by an opening parenthesis, followed by a sequence of zero or more arguments separated by commas (with each comma optionally preceded and/or followed by zero or more white space characters), followed by a closing parenthesis. There is an almost one-to-one mapping between the list of predefined functions available, and those defined in MathML. All of the MathML functions are recognized; this set is larger than the functions defined in SBML Level 1. In the subset of functions that overlap between MathML and SBML Level 1, there exist a few differences. The following table summarizes the differences between the predefined functions in SBML Level 1 and the MathML equivalents in SBML Levels 2 and  3:

Text string formula functions MathML equivalents in SBML Levels 2 and 3
acosarccos
asinarcsin
atanarctan
ceilceiling
logln
log10(x)log(x) or log(10, x)
pow(x, y)power(x, y)
sqr(x)power(x, 2)
sqrt(x)root(x) or root(2, x)
Table comparing the names of certain functions in the SBML text-string formula syntax and MathML. The left column shows the names of functions recognized by SBML_parseFormula(); the right column shows their equivalent function names in MathML 2.0, used in SBML Levels 2 and 3.
Note
Callers using SBML Level 3 are encouraged to use the facilities provided by libSBML's newer and more powerful Level 3-oriented formula parser and formatter. The entry points to this second system are SBML_parseL3Formula() and SBML_formulaToL3String(). The Level 1-oriented system (i.e., what is provided by SBML_formulaToString() and SBML_parseFormula()) is provided untouched for backwards compatibility.
See also
SBML_parseL3Formula()
SBML_parseL3FormulaWithSettings()
SBML_parseL3FormulaWithModel()
SBML_parseFormula()
SBML_formulaToL3StringWithSettings()
SBML_formulaToL3String()
SBML_formulaToString()
SBML_getDefaultL3ParserSettings()
Examples
createExampleSBML.cpp, printMath.cpp, qual_example1.cpp, translateL3Math.cpp, and translateMath.cpp.

Public Member Functions

int addChild (ASTNode *disownedChild, bool inRead=false)
 Adds the given node as a child of this ASTNode. More...
 
int addSemanticsAnnotation (XMLNode *disownedAnnotation)
 Adds the given XMLNode as a MathML <semantics> element to this ASTNode. More...
 
 ASTNode (ASTNodeType_t type=AST_UNKNOWN)
 Creates and returns a new ASTNode. More...
 
 ASTNode (const ASTNode &orig)
 Copy constructor; creates a deep copy of the given ASTNode. More...
 
 ASTNode (Token_t *token)
 Creates a new ASTNode from the given Token. More...
 
bool canonicalize ()
 Converts this ASTNode to a canonical form and returns true if successful, false otherwise. More...
 
void decompose ()
 This function allows decomposition of ASTNode into components such that we reduce the need for brackets. More...
 
ASTNodedeepCopy () const
 Creates a recursive copy of this node and all its children. More...
 
ASTNodederivative (const std::string &variable)
 Returns an ASTNode representing the derivative of this ASTNode with respect to the given variable. More...
 
bool exactlyEqual (const ASTNode &rhs)
 This function allows two ASTNodes to be compared for exact equivilance. More...
 
void fillListOfNodes (ASTNodePredicate predicate, List *lst) const
 Returns a list of nodes rooted at a given node and satisfying a given predicate. More...
 
int freeName ()
 Frees the name of this ASTNode and sets it to NULL. More...
 
ASTBasePlugin * getASTPlugin (ASTNodeType_t type)
 Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package that defines the given type. More...
 
const ASTBasePlugin * getASTPlugin (ASTNodeType_t type) const
 Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package that defines the given type. More...
 
ASTBasePlugin * getASTPlugin (const SBMLNamespaces *sbmlns)
 Returns a plug-in object (extension interface) for an SBML Level 3 package extension with the given sbmlns. More...
 
const ASTBasePlugin * getASTPlugin (const SBMLNamespaces *sbmlns) const
 Returns a plug-in object (extension interface) for an SBML Level 3 package extension with the given sbmlns. More...
 
ASTBasePlugin * getASTPlugin (const std::string &name, bool isCsymbol=false, bool strCmpIsCaseSensitive=false)
 Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package with the given constraints. More...
 
const ASTBasePlugin * getASTPlugin (const std::string &name, bool isCsymbol=false, bool strCmpIsCaseSensitive=false) const
 Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package with the given constraints. More...
 
char getCharacter () const
 Returns the value of this node as a single character. More...
 
ASTNodegetChild (unsigned int n) const
 Returns the child at index n of this node. More...
 
std::string getClass () const
 Returns the MathML class attribute value of this ASTNode. More...
 
XMLAttributesgetDefinitionURL () const
 Returns the MathML definitionURL attribute value. More...
 
std::string getDefinitionURLString () const
 Returns the MathML definitionURL attribute value as a string. More...
 
long getDenominator () const
 Returns the value of the denominator of this node. More...
 
long getExponent () const
 Returns the exponent value of this ASTNode. More...
 
std::string getId () const
 Returns the MathML id attribute value of this ASTNode. More...
 
long getInteger () const
 Returns the value of this node as an integer. More...
 
ASTNodegetLeftChild () const
 Returns the left child of this node. More...
 
ListgetListOfNodes (ASTNodePredicate predicate) const
 Returns a list of nodes satisfying a given predicate. More...
 
double getMantissa () const
 Returns the mantissa value of this node. More...
 
const char * getName () const
 Returns the value of this node as a string. More...
 
unsigned int getNumChildren () const
 Returns the number of children of this node. More...
 
long getNumerator () const
 Returns the value of the numerator of this node if of type AST_RATIONAL, or the numerical value of the node if of type AST_INTEGER; 0 otherwise. More...
 
unsigned int getNumSemanticsAnnotations () const
 Returns the number of MathML <semantics> element elements on this node. More...
 
const char * getOperatorName () const
 Returns the value of this operator node as a string. More...
 
SBasegetParentSBMLObject () const
 Returns the parent SBML object. More...
 
int getPrecedence () const
 Returns the precedence of this node in the infix math syntax of SBML Level 1. More...
 
double getReal () const
 Returns the real-numbered value of this node. More...
 
ASTNodegetRightChild () const
 Returns the right child of this node. More...
 
XMLNodegetSemanticsAnnotation (unsigned int n) const
 Returns the nth MathML <semantics> element on this ASTNode. More...
 
std::string getStyle () const
 Returns the MathML style attribute value of this ASTNode. More...
 
ASTNodeType_t getType () const
 Returns the type of this ASTNode. More...
 
std::string getUnits () const
 Returns the units of this ASTNode. More...
 
void * getUserData () const
 Returns the user data that has been previously set via setUserData(). More...
 
double getValue () const
 Returns the numerical value of this ASTNode. More...
 
bool hasCorrectNumberArguments () const
 Returns true if this ASTNode has the correct number of children for its type. More...
 
int hasTypeAndNumChildren (ASTNodeType_t type, unsigned int numchildren) const
 Returns true if this node is of type type and has numchildren number of children. More...
 
bool hasUnits () const
 Returns true (nonzero) if this node or any of its children nodes have the attribute sbml:units. More...
 
int insertChild (unsigned int n, ASTNode *disownedChild)
 Inserts the given ASTNode at point n in the list of children of this ASTNode. More...
 
bool isAvogadro () const
 Returns true (nonzero) if this node is the special symbol avogadro. More...
 
bool isBoolean () const
 Returns true if this node has a Boolean type. More...
 
bool isCiNumber () const
 Returns true (nonzero) if this node represents a MathML ci element representing a value not a function (e.g., true, Pi). More...
 
bool isConstant () const
 Returns true (nonzero) if this node represents a MathML constant (e.g., true, Pi). More...
 
bool isConstantNumber () const
 Returns true (nonzero) if this node represents a MathML constant with numeric value (e.g., Pi). More...
 
bool isCSymbolFunction () const
 Returns true (nonzero) if this node represents a MathML csymbol representing a function. More...
 
bool isFunction () const
 Returns true if this node represents a function. More...
 
bool isInfinity () const
 Returns true (nonzero) if this node represents the special IEEE 754 value infinity, false (zero) otherwise. More...
 
bool isInteger () const
 Returns true (nonzero) if this node contains an integer value, false (zero) otherwise. More...
 
bool isLambda () const
 Returns true (nonzero) if this node is a MathML <lambda>, false (zero) otherwise. More...
 
bool isLog10 () const
 Returns true (nonzero) if this node represents a log10 function, false (zero) otherwise. More...
 
bool isLogical () const
 Returns true (nonzero) if this node is a MathML logical operator. More...
 
bool isName () const
 Returns true if this node is a user-defined variable name or the symbols for time or Avogadro's constant. More...
 
bool isNaN () const
 Returns true (nonzero) if this node represents the special IEEE 754 value "not a number" (NaN), false (zero) otherwise. More...
 
bool isNegInfinity () const
 Returns true (nonzero) if this node represents the special IEEE 754 value "negative infinity", false (zero) otherwise. More...
 
bool isNumber () const
 Returns true (nonzero) if this node contains a number, false (zero) otherwise. More...
 
bool isOperator () const
 Returns true if this node is a mathematical operator. More...
 
bool isPiecewise () const
 Returns true (nonzero) if this node is the MathML <piecewise> construct. More...
 
bool isRational () const
 Returns true (nonzero) if this node represents a rational number. More...
 
bool isReal () const
 Returns true (nonzero) if this node can represent a real number, false (zero) otherwise. More...
 
bool isRelational () const
 Returns true if this node is a MathML relational operator. More...
 
bool isSetClass () const
 Returns true (nonzero) if this node has a value for the MathML attribute "class". More...
 
bool isSetId () const
 Returns true (nonzero) if this node has a value for the MathML attribute "id". More...
 
bool isSetParentSBMLObject () const
 Returns true if this node has a value for the parent SBML object. More...
 
bool isSetStyle () const
 Returns true (nonzero) if this node has a value for the MathML attribute "style". More...
 
bool isSetUnits () const
 Returns true (nonzero) if this node has the attribute sbml:units. More...
 
bool isSetUserData () const
 Returns true if this node has a user data object. More...
 
bool isSqrt () const
 Returns true (nonzero) if this node represents a square root function, false (zero) otherwise. More...
 
bool isUMinus () const
 Returns true (nonzero) if this node is a unary minus operator, false (zero) otherwise. More...
 
bool isUnknown () const
 Returns true (nonzero) if this node has an unknown type. More...
 
bool isUPlus () const
 Returns true (nonzero) if this node is a unary plus operator, false (zero) otherwise. More...
 
bool isUserFunction () const
 Returns true (nonzero) if this node represents a MathML user-defined function. More...
 
bool isWellFormedASTNode () const
 Returns true or false depending on whether this ASTNode is well-formed. More...
 
ASTNodeoperator= (const ASTNode &rhs)
 Assignment operator for ASTNode. More...
 
int prependChild (ASTNode *disownedChild)
 Adds the given node as a child of this ASTNode. More...
 
void reduceToBinary ()
 Reduces this ASTNode to a binary tree. More...
 
void refactor ()
 This function refactors an ASTNode to facilitate the use of the algorithm to construct a reaction network from a set of ordinary differential equations. More...
 
int removeChild (unsigned int n, bool delremoved=false)
 Removes the nth child of this ASTNode object. More...
 
virtual void renameSIdRefs (const std::string &oldid, const std::string &newid)
 Renames all the SIdRef attributes on this node and any child node. More...
 
virtual void renameUnitSIdRefs (const std::string &oldid, const std::string &newid)
 Renames all the UnitSIdRef attributes on this node and any child node. More...
 
void replaceArgument (const std::string &bvar, ASTNode *arg)
 Replaces occurrences of a given name with a given ASTNode. More...
 
void replaceArguments (const std::vector< std::string > &bvars, std::vector< ASTNode * > &args)
 Replaces occurrences of each given name with the corresponding ASTNode. More...
 
int replaceChild (unsigned int n, ASTNode *disownedChild, bool delreplaced=false)
 Replaces and optionally deletes the nth child of this ASTNode with the given ASTNode. More...
 
bool returnsBoolean (const Model *model=NULL) const
 Returns true (nonzero) if this node returns a Boolean type or false (zero) otherwise. More...
 
int setCharacter (char value)
 Sets the value of this ASTNode to the given character. More...
 
int setClass (const std::string &className)
 Sets the MathML attribute class of this ASTNode to className. More...
 
int setId (const std::string &id)
 Sets the MathML attribute id of this ASTNode. More...
 
int setName (const char *name)
 Sets the value of this ASTNode to the given name. More...
 
int setStyle (const std::string &style)
 Sets the MathML attribute style of this ASTNode to style. More...
 
int setType (ASTNodeType_t type)
 Sets the type of this ASTNode to the given type code. More...
 
int setUnits (const std::string &units)
 Sets the units of this ASTNode to units. More...
 
int setUserData (void *userData)
 Sets the user data of this node. More...
 
int setValue (double mantissa, long exponent)
 Sets the value of this ASTNode to the given real (double) in two parts: the mantissa and the exponent. More...
 
int setValue (double value)
 Sets the value of this ASTNode to the given real (double) and sets the node type to AST_REAL. More...
 
int setValue (int value)
 Sets the value of this ASTNode to the given integer and sets the node type to AST_INTEGER. More...
 
int setValue (long numerator, long denominator)
 Sets the value of this ASTNode to the given rational in two parts: the numerator and denominator. More...
 
int setValue (long value)
 Sets the value of this ASTNode to the given (long) integer and sets the node type to AST_INTEGER. More...
 
int swapChildren (ASTNode *that)
 Swaps the children of this ASTNode object with the children of the given ASTNode object. More...
 
int unsetClass ()
 Unsets the MathML class attribute of this ASTNode. More...
 
int unsetId ()
 Unsets the MathML id attribute of this ASTNode. More...
 
int unsetParentSBMLObject ()
 Unsets the parent SBML object. More...
 
int unsetStyle ()
 Unsets the MathML style attribute of this ASTNode. More...
 
int unsetUnits ()
 Unsets the units of this ASTNode. More...
 
int unsetUserData ()
 Unsets the user data of this node. More...
 
virtual ~ASTNode ()
 Destroys this ASTNode, including any child nodes. More...
 

Protected Member Functions

ASTNodecombineNumbers (std::vector< unsigned int > &numbers)
 
void convertRootToPower ()
 
void createNonBinaryTree ()
 
void createVectorOfChildTypes (std::vector< unsigned int > &numbers, std::vector< unsigned int > &names, std::vector< unsigned int > &others)
 
ASTNodederivativeDivide (const std::string &variable)
 
ASTNodederivativeExp (const std::string &variable)
 
ASTNodederivativeLn (const std::string &variable)
 
ASTNodederivativeLog (const std::string &variable)
 
ASTNodederivativeMinus (const std::string &variable)
 
ASTNodederivativePlus (const std::string &variable)
 
ASTNodederivativePower (const std::string &variable)
 
ASTNodederivativeTimes (const std::string &variable)
 
void encompassUnaryMinus ()
 
void refactorNumbers ()
 
bool reorderArguments (unsigned int level=0)
 
void simplify ()
 

Private Member Functions

void clearPlugins ()
 

Friends

class SBMLRateRuleConverter
 

Constructor & Destructor Documentation

◆ ASTNode() [1/3]

ASTNode::ASTNode ( ASTNodeType_t  type = AST_UNKNOWN)

Creates and returns a new ASTNode.

Unless the argument type is given, the returned node will by default have a type of AST_UNKNOWN. If the type isn't supplied when caling this constructor, the caller should set the node type to something else as soon as possible usingsetType().

Parameters
typean optional ASTNodeType_t code indicating the type of node to create.

◆ ASTNode() [2/3]

ASTNode::ASTNode ( Token_t token)

Creates a new ASTNode from the given Token.

The resulting ASTNode will contain the same data as the token.

Parameters
tokenthe token to use as a starting point for creating the ASTNode object.

◆ ASTNode() [3/3]

ASTNode::ASTNode ( const ASTNode orig)

Copy constructor; creates a deep copy of the given ASTNode.

Parameters
origthe ASTNode to be copied.

◆ ~ASTNode()

ASTNode::~ASTNode ( )
virtual

Destroys this ASTNode, including any child nodes.

Member Function Documentation

◆ addChild()

int ASTNode::addChild ( ASTNode disownedChild,
bool  inRead = false 
)

Adds the given node as a child of this ASTNode.

Child nodes are added in-order, from left to right.

Parameters
disownedChildthe ASTNode instance to add.
inReadfalse by default; may be set to true when reading XML where there may be a lambda function with no bvar arguments.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode::isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
prependChild(ASTNode* disownedChild)
replaceChild(unsigned int n, ASTNode* disownedChild, bool delreplaced)
insertChild(unsigned int n, ASTNode* disownedChild)
removeChild(unsigned int n)
isWellFormedASTNode()
Examples
createExampleSBML.cpp.

◆ addSemanticsAnnotation()

int ASTNode::addSemanticsAnnotation ( XMLNode disownedAnnotation)

Adds the given XMLNode as a MathML <semantics> element to this ASTNode.

The <semantics> element is a MathML 2.0 construct that can be used to associate additional information with a MathML construct. The construct can be used to decorate a MathML expressions with a sequence of one or more <annotation> or <annotation-xml> elements. Each such element contains a pair of items; the first is a symbol that acts as an attribute or key, and the second is the value associated with the attribute or key. Please refer to the MathML 2.0 documentation, particularly the Section 5.2, Semantic Annotations for more information about these constructs.
Parameters
disownedAnnotationthe annotation to add. Will become a child of the parent node.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Note
Although SBML permits the use of the MathML <semantics> annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these annotations are still poorly understood. If you wish to use this construct, we urge you to discuss possible uses and applications on the SBML discussion lists, particularly sbml-discuss and/or sbml-interoperability.
See also
getNumSemanticsAnnotations()
getSemanticsAnnotation()

◆ canonicalize()

bool ASTNode::canonicalize ( )

Converts this ASTNode to a canonical form and returns true if successful, false otherwise.

The rules determining the canonical form conversion are as follows:

  • If the node type is AST_NAME and the node name matches "ExponentialE", "Pi", "True" or "False" the node type is converted to the corresponding AST_CONSTANT_X type.
  • If the node type is an AST_FUNCTION and the node name matches an SBML (MathML) function name, logical operator name, or relational operator name, the node is converted to the corresponding AST_FUNCTION_X or AST_LOGICAL_X type.

SBML Level 1 function names are searched first; thus, for example, canonicalizing log will result in a node type of AST_FUNCTION_LN. (See the SBML Level 1 Version 2 Specification, Appendix C.)

Sometimes, canonicalization of a node results in a structural conversion of the node as a result of adding a child. For example, a node with the SBML Level 1 function name sqr and a single child node (the argument) will be transformed to a node of type AST_FUNCTION_POWER with two children. The first child will remain unchanged, but the second child will be an ASTNode of type AST_INTEGER and a value of 2. The function names that result in structural changes are: log10, sqr, and sqrt.

◆ clearPlugins()

void ASTNode::clearPlugins ( )
private

◆ combineNumbers()

ASTNode * ASTNode::combineNumbers ( std::vector< unsigned int > &  numbers)
protected

◆ convertRootToPower()

void ASTNode::convertRootToPower ( )
protected

◆ createNonBinaryTree()

void ASTNode::createNonBinaryTree ( )
protected

◆ createVectorOfChildTypes()

void ASTNode::createVectorOfChildTypes ( std::vector< unsigned int > &  numbers,
std::vector< unsigned int > &  names,
std::vector< unsigned int > &  others 
)
protected

◆ decompose()

void ASTNode::decompose ( )

This function allows decomposition of ASTNode into components such that we reduce the need for brackets.

Obviously an ASTNode does not have brackets but when written as a string these would become necessary.

The decomposition used here is such that if the top level function is multiply or divide then the arguments to these functions do not contain a plus element.

for example

(a + B) * c becomes ac + Bc

(5 + 3)/(a-4) becomes 8/(a-4)

(a + 4)/4 becomes 1 + a/4

◆ deepCopy()

ASTNode * ASTNode::deepCopy ( ) const

Creates a recursive copy of this node and all its children.

Returns
a copy of this ASTNode and all its children. The caller owns the returned ASTNode and is responsible for deleting it.

◆ derivative()

ASTNode * ASTNode::derivative ( const std::string &  variable)

Returns an ASTNode representing the derivative of this ASTNode with respect to the given variable.

e.g. if we have an ASTNode that represents 2*x^2 and we call the function derivative("x") on this node

this will return an ASTNode representing 4 * x since d(2*x^2)/dx = 4*x

◆ derivativeDivide()

ASTNode * ASTNode::derivativeDivide ( const std::string &  variable)
protected

◆ derivativeExp()

ASTNode * ASTNode::derivativeExp ( const std::string &  variable)
protected

◆ derivativeLn()

ASTNode * ASTNode::derivativeLn ( const std::string &  variable)
protected

◆ derivativeLog()

ASTNode * ASTNode::derivativeLog ( const std::string &  variable)
protected

◆ derivativeMinus()

ASTNode * ASTNode::derivativeMinus ( const std::string &  variable)
protected

◆ derivativePlus()

ASTNode * ASTNode::derivativePlus ( const std::string &  variable)
protected

◆ derivativePower()

ASTNode * ASTNode::derivativePower ( const std::string &  variable)
protected

◆ derivativeTimes()

ASTNode * ASTNode::derivativeTimes ( const std::string &  variable)
protected

◆ encompassUnaryMinus()

void ASTNode::encompassUnaryMinus ( )
protected

◆ exactlyEqual()

bool ASTNode::exactlyEqual ( const ASTNode rhs)

This function allows two ASTNodes to be compared for exact equivilance.

It returns a boolean - true if the ASTNodes are exactly the same, false otherwise.

Given that 'a+4' == 'a+4' this function will return true if two ASTNodes with PLUS as their operator and "a" as the left child and "4" as the right child are compared

Conversely 'a+4' != '4+a' i.e. the function will return false if the left and right children do not match.

◆ fillListOfNodes()

void ASTNode::fillListOfNodes ( ASTNodePredicate  predicate,
List lst 
) const

Returns a list of nodes rooted at a given node and satisfying a given predicate.

This method is identical to calling getListOfNodes(ASTNodePredicate predicate) const, except that instead of creating a new List object, it uses the one passed in as argument lst. This method a depth-first search of the tree rooted at this ASTNode object, and adds to the list lst the nodes for which the given function predicate(node) returns true (nonzero).

For portability between different programming languages, the predicate is passed in as a pointer to a function. The function definition must have the type ASTNodePredicate , which is defined as

int (*ASTNodePredicate) (const ASTNode_t *node);

where a return value of nonzero represents true and zero represents false.

Parameters
predicatethe predicate to use.
lstthe List to which ASTNode objects should be added.
See also
getListOfNodes()

◆ freeName()

int ASTNode::freeName ( )

Frees the name of this ASTNode and sets it to NULL.

This operation is only applicable to ASTNode objects corresponding to operators, numbers, or AST_UNKNOWN. This method has no effect on other types of nodes.

Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ getASTPlugin() [1/6]

ASTBasePlugin* ASTNode::getASTPlugin ( ASTNodeType_t  type)

Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package that defines the given type.

Parameters
typethe ASTNodeType_t that is defined by the given plugin.
Returns
the plug-in object (the libSBML extension interface) of a package extension that defines the given type, or NULL if none exist.

◆ getASTPlugin() [2/6]

const ASTBasePlugin* ASTNode::getASTPlugin ( ASTNodeType_t  type) const

Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package that defines the given type.

Parameters
typethe ASTNodeType_t that is defined by the given plugin.
Returns
the plug-in object (the libSBML extension interface) of a package extension that defines the given type, or NULL if none exist.

◆ getASTPlugin() [3/6]

ASTBasePlugin* ASTNode::getASTPlugin ( const SBMLNamespaces sbmlns)

Returns a plug-in object (extension interface) for an SBML Level 3 package extension with the given sbmlns.

Parameters
sbmlnsthe namespace of the plugin to return.
Returns
the plug-in object (the libSBML extension interface) of a package extension with the given package name or URI, or NULL if none exist.

◆ getASTPlugin() [4/6]

const ASTBasePlugin* ASTNode::getASTPlugin ( const SBMLNamespaces sbmlns) const

Returns a plug-in object (extension interface) for an SBML Level 3 package extension with the given sbmlns.

Parameters
sbmlnsthe namespace of the plugin to return.
Returns
the plug-in object (the libSBML extension interface) of a package extension with the given package name or URI, or NULL if none exist.

◆ getASTPlugin() [5/6]

ASTBasePlugin* ASTNode::getASTPlugin ( const std::string &  name,
bool  isCsymbol = false,
bool  strCmpIsCaseSensitive = false 
)

Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package with the given constraints.

Parameters
namethe type or csymbol defined by the returned plugin.
isCsymbolBoolean indicator of whether the name is a csymbol (if true) or type (if false).
strCmpIsCaseSensitivewhether to search for the matching type or csymbol in case-sensitve manner (if true) or case-insensitive manner (if false).
Returns
the plug-in object (the libSBML extension interface) of a package extension that defines the given name, or NULL if none exist.

◆ getASTPlugin() [6/6]

const ASTBasePlugin* ASTNode::getASTPlugin ( const std::string &  name,
bool  isCsymbol = false,
bool  strCmpIsCaseSensitive = false 
) const

Returns a plug-in object (extension interface) for an SBML Level 3 package extension for the package with the given constraints.

Parameters
namethe type or csymbol defined by the returned plugin.
isCsymbolBoolean indicator of whether the name is a csymbol (if true) or type (if false).
strCmpIsCaseSensitivewhether to search for the matching type or csymbol in case-sensitve manner (if true) or case-insensitive manner (if false).
Returns
the plug-in object (the libSBML extension interface) of a package extension that defines the given name, or NULL if none exist.

◆ getCharacter()

char ASTNode::getCharacter ( ) const

Returns the value of this node as a single character.

This function should be called only when getType() returns AST_PLUS, AST_MINUS, AST_TIMES, AST_DIVIDE or AST_POWER.

Returns
the value of this ASTNode as a single character

◆ getChild()

ASTNode * ASTNode::getChild ( unsigned int  n) const

Returns the child at index n of this node.

Parameters
nthe index of the child to get.
Returns
the nth child of this ASTNode or NULL if this node has no nth child (n > getNumChildren() - 1).
See also
getNumChildren()
getLeftChild()
getRightChild()
Examples
printMath.cpp.

◆ getClass()

std::string ASTNode::getClass ( ) const

Returns the MathML class attribute value of this ASTNode.

Returns
the MathML class of this ASTNode, or an empty string if it does not exist.
See also
isSetClass()
setClass()
unsetClass()

◆ getDefinitionURL()

XMLAttributes * ASTNode::getDefinitionURL ( ) const

Returns the MathML definitionURL attribute value.

Returns
the value of the definitionURL attribute, in the form of a libSBML XMLAttributes object.
See also
setDefinitionURL(XMLAttributes url)
setDefinitionURL(const std::string& url)
getDefinitionURLString()

◆ getDefinitionURLString()

std::string ASTNode::getDefinitionURLString ( ) const

Returns the MathML definitionURL attribute value as a string.

Returns
the value of the definitionURL attribute, as a string.
See also
getDefinitionURL()
setDefinitionURL(const std::string& url)
setDefinitionURL(XMLAttributes url)

◆ getDenominator()

long ASTNode::getDenominator ( ) const

Returns the value of the denominator of this node.

Returns
the value of the denominator of this ASTNode, or 1 (true) if this node is not of type AST_RATIONAL.
Note
This function should be called only when getType() returns AST_RATIONAL. It will return 1 if the node type is another type, but since 1 may be a valid value for the denominator of a rational number, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.
See also
getNumerator()

◆ getExponent()

long ASTNode::getExponent ( ) const

Returns the exponent value of this ASTNode.

Returns
the value of the exponent of this ASTNode, or 0 if this is not a type of node that has an exponent.
Note
This function should be called only when getType() returns AST_REAL_E. It will return 0 if the node type is another type, but since 0 may be a valid value, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.
See also
getMantissa()

◆ getId()

std::string ASTNode::getId ( ) const

Returns the MathML id attribute value of this ASTNode.

Returns
the MathML id of this ASTNode.
See also
isSetId()
setId(const std::string& id)
unsetId()

◆ getInteger()

long ASTNode::getInteger ( ) const

Returns the value of this node as an integer.

If this node type is AST_RATIONAL, this method returns the value of the numerator.

Returns
the value of this ASTNode as a (long) integer if type AST_INTEGER; the numerator if type AST_RATIONAL, and 0 otherwise.
Note
This function should be called only when getType() returns AST_INTEGER or AST_RATIONAL. It will return 0 if the node type is not one of these, but since 0 may be a valid value for integer, it is important to be sure that the node type is one of the expected types in order to understand if 0 is the actual value.
See also
getNumerator()
getDenominator()

◆ getLeftChild()

ASTNode * ASTNode::getLeftChild ( ) const

Returns the left child of this node.

Returns
the left child of this ASTNode. This is equivalent to calling getChild() with an argument of 0.
See also
getNumChildren()
getChild()
getRightChild()
Examples
createExampleSBML.cpp, and printMath.cpp.

◆ getListOfNodes()

List * ASTNode::getListOfNodes ( ASTNodePredicate  predicate) const

Returns a list of nodes satisfying a given predicate.

This performs a depth-first search of the tree rooted at this ASTNode object, and returns a List of nodes for which the given function predicate(node) returns true (nonzero).

For portability between different programming languages, the predicate is passed in as a pointer to a function. The function definition must have the type ASTNodePredicate, which is defined as

int (*ASTNodePredicate) (const ASTNode *node);

where a return value of nonzero represents true and zero represents false.

Parameters
predicatethe predicate to use.
Returns
the list of nodes for which the predicate returned true (nonzero). The List returned is owned by the caller and should be deleted after the caller is done using it. The ASTNode objects in the list; however, are not owned by the caller (as they still belong to the tree itself), and therefore should not be deleted.

◆ getMantissa()

double ASTNode::getMantissa ( ) const

Returns the mantissa value of this node.

If getType() returns AST_REAL, this method is identical to ASTNode::getReal().

Returns
the value of the mantissa of this ASTNode, or 0 if this node is not a type that has a real-numbered value.
Note
This function should be called only when getType() returns AST_REAL_E, AST_REAL or AST_NAME_AVOGADRO. It will return 0 if the node type is another type, but since 0 may be a valid value, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.
See also
getExponent()

◆ getName()

const char * ASTNode::getName ( ) const

Returns the value of this node as a string.

This function may be called on nodes that (1) are not operators, i.e., nodes for which isOperator() returns false, and (2) are not numbers, i.e., isNumber() returns NULL.

Returns
the value of this ASTNode as a string, or NULL if it is a node that does not have a name equivalent (e.g., if it is a number).

◆ getNumChildren()

unsigned int ASTNode::getNumChildren ( ) const

Returns the number of children of this node.

Returns
the number of children of this ASTNode, or 0 is this node has no children.
Examples
printMath.cpp.

◆ getNumerator()

long ASTNode::getNumerator ( ) const

Returns the value of the numerator of this node if of type AST_RATIONAL, or the numerical value of the node if of type AST_INTEGER; 0 otherwise.

This function should be called only when getType() returns AST_RATIONAL or AST_INTEGER. It will return 0 if the node type is another type, but since 0 may be a valid value for the denominator of a rational number or of an integer, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.

Returns
the value of the numerator of this ASTNode if AST_RATIONAL, the value if AST_INTEGER, or 0 otherwise.
See also
getDenominator()
getInteger()

◆ getNumSemanticsAnnotations()

unsigned int ASTNode::getNumSemanticsAnnotations ( ) const

Returns the number of MathML <semantics> element elements on this node.

The <semantics> element is a MathML 2.0 construct that can be used to associate additional information with a MathML construct. The construct can be used to decorate a MathML expressions with a sequence of one or more <annotation> or <annotation-xml> elements. Each such element contains a pair of items; the first is a symbol that acts as an attribute or key, and the second is the value associated with the attribute or key. Please refer to the MathML 2.0 documentation, particularly the Section 5.2, Semantic Annotations for more information about these constructs.
Returns
the number of annotations of this ASTNode.
Note
Although SBML permits the use of the MathML <semantics> annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these annotations are still poorly understood. If you wish to use this construct, we urge you to discuss possible uses and applications on the SBML discussion lists, particularly sbml-discuss and/or sbml-interoperability.
See also
addSemanticsAnnotation()
getSemanticsAnnotation()

◆ getOperatorName()

const char * ASTNode::getOperatorName ( ) const

Returns the value of this operator node as a string.

This function may be called on nodes that are operators, i.e., nodes for which isOperator() returns true.

Returns
the name of this operator ASTNode as a string (or NULL if not an operator).

◆ getParentSBMLObject()

SBase * ASTNode::getParentSBMLObject ( ) const

Returns the parent SBML object.

Returns
the parent SBML object of this ASTNode.
See also
isSetParentSBMLObject()
setParentSBMLObject()
unsetParentSBMLObject()

◆ getPrecedence()

int ASTNode::getPrecedence ( ) const

Returns the precedence of this node in the infix math syntax of SBML Level 1.

For more information about the infix syntax, see the discussion about text string formulas at the top of the documentation for ASTNode.

Returns
an integer indicating the precedence of this ASTNode

◆ getReal()

double ASTNode::getReal ( ) const

Returns the real-numbered value of this node.

This function performs the necessary arithmetic if the node type is AST_REAL_E (mantissa * 10exponent) or AST_RATIONAL (numerator / denominator).

Returns
the value of this ASTNode as a real (double), or 0 if this is not a node that holds a number.
Note
This function should be called only when this ASTNode has a numerical value type. It will return 0 if the node type is another type, but since 0 may be a valid value, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.

◆ getRightChild()

ASTNode * ASTNode::getRightChild ( ) const

Returns the right child of this node.

Returns
the right child of this ASTNode, or NULL if this node has no right child. If getNumChildren() > 1, then this is equivalent to:
getChild( getNumChildren() - 1 );
See also
getNumChildren()
getLeftChild()
getChild()
Examples
createExampleSBML.cpp.

◆ getSemanticsAnnotation()

XMLNode * ASTNode::getSemanticsAnnotation ( unsigned int  n) const

Returns the nth MathML <semantics> element on this ASTNode.

The <semantics> element is a MathML 2.0 construct that can be used to associate additional information with a MathML construct. The construct can be used to decorate a MathML expressions with a sequence of one or more <annotation> or <annotation-xml> elements. Each such element contains a pair of items; the first is a symbol that acts as an attribute or key, and the second is the value associated with the attribute or key. Please refer to the MathML 2.0 documentation, particularly the Section 5.2, Semantic Annotations for more information about these constructs.
Parameters
nthe index of the annotation to return. Callers should use ASTNode::getNumSemanticsAnnotations() to first find out how many annotations there are.
Returns
the nth annotation inside this ASTNode, or NULL if this node has no nth annotation (n > getNumSemanticsAnnotations() - 1).
Note
Although SBML permits the use of the MathML <semantics> annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these annotations are still poorly understood. If you wish to use this construct, we urge you to discuss possible uses and applications on the SBML discussion lists, particularly sbml-discuss and/or sbml-interoperability.
See also
getNumSemanticsAnnotations()
addSemanticsAnnotation()

◆ getStyle()

std::string ASTNode::getStyle ( ) const

Returns the MathML style attribute value of this ASTNode.

Returns
the MathML style of this ASTNode, or an empty string if it does not exist.
See also
isSetStyle()
setStyle(const std::string& id)
unsetStyle()

◆ getType()

ASTNodeType_t ASTNode::getType ( ) const

Returns the type of this ASTNode.

The value returned is one of the Core AST type codes such as AST_LAMBDA, AST_PLUS, etc.

Returns
the type of this ASTNode.

◆ getUnits()

std::string ASTNode::getUnits ( ) const

Returns the units of this ASTNode.

SBML Level 3 Version 1 introduced the ability to include an attribute sbml:units on MathML cn elements appearing in SBML mathematical formulas. The value of this attribute can be used to indicate the unit of measurement to be associated with the number in the content of the cn element. The value of this attribute must be the identifier of a unit of measurement defined by SBML or the enclosing Model. Here, the sbml portion is an XML namespace prefix that must be associated with the SBML namespace for SBML Level 3. The following example illustrates how this attribute can be used to define a number with value 10 and unit of measurement second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Returns
the units of this ASTNode.
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
See also
SBML_parseL3Formula()

◆ getUserData()

void * ASTNode::getUserData ( ) const

Returns the user data that has been previously set via setUserData().

Returns
the user data of this node, or NULL if no user data has been set.
See also
isSetUserData()
setUserData()
unsetUserData()

◆ getValue()

double ASTNode::getValue ( ) const

Returns the numerical value of this ASTNode.

Returns
the numerical value of this ASTNode, or NaN if this is not a type of node that has a numerical value.
Note
This function will return a numerical value (as a double) for any ASTNode_t that represents a number, a constant such as AST_CONSTANT_PI, AST_CONSTANT_E, or AST_NAME_AVOGADRO, or 1 for nodes of type AST_CONSTANT_TRUE and 0 for nodes of type AST_CONSTANT_FALSE. It does not evaluate the node in any way so, for example, it will not return the value of a named ASTNode_t or attempt to evaluate a function. This includes a node representing time i.e. nodes of type AST_NAME_TIME.

◆ hasCorrectNumberArguments()

bool ASTNode::hasCorrectNumberArguments ( ) const

Returns true if this ASTNode has the correct number of children for its type.

For example, an ASTNode with type AST_MINUS expects 1 or 2 child nodes.

Returns
true if this ASTNode has the appropriate number of children for its type, false otherwise.
Note
This function performs a check on the top-level node only. Child nodes are not checked.
See also
isWellFormedASTNode()

◆ hasTypeAndNumChildren()

int ASTNode::hasTypeAndNumChildren ( ASTNodeType_t  type,
unsigned int  numchildren 
) const

Returns true if this node is of type type and has numchildren number of children.

Designed for use in cases where it is useful to discover if the node is a unary not or unary minus, or a times node with no children, etc.

Returns
true if this ASTNode is has the specified type and number of children, false otherwise.

◆ hasUnits()

bool ASTNode::hasUnits ( ) const

Returns true (nonzero) if this node or any of its children nodes have the attribute sbml:units.

SBML Level 3 Version 1 introduced the ability to include an attribute sbml:units on MathML cn elements appearing in SBML mathematical formulas. The value of this attribute can be used to indicate the unit of measurement to be associated with the number in the content of the cn element. The value of this attribute must be the identifier of a unit of measurement defined by SBML or the enclosing Model. Here, the sbml portion is an XML namespace prefix that must be associated with the SBML namespace for SBML Level 3. The following example illustrates how this attribute can be used to define a number with value 10 and unit of measurement second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Returns
true if this ASTNode or its children has units associated with it, false otherwise.
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
See also
isSetUnits()
setUnits(const std::string& units)

◆ insertChild()

int ASTNode::insertChild ( unsigned int  n,
ASTNode disownedChild 
)

Inserts the given ASTNode at point n in the list of children of this ASTNode.

Parameters
nunsigned int the index of the ASTNode being added.
disownedChildASTNode to insert as the nth child.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode::isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild(ASTNode* disownedChild)
prependChild(ASTNode* disownedChild)
replaceChild(unsigned int n, ASTNode* disownedChild, bool delreplaced)
removeChild(unsigned int n)

◆ isAvogadro()

bool ASTNode::isAvogadro ( ) const

Returns true (nonzero) if this node is the special symbol avogadro.

The predicate returns false (zero) otherwise.

SBML Level 3 introduced a predefined MathML <csymbol> for the value of Avogadro's constant. LibSBML stores this internally as a node of type AST_NAME_AVOGADRO. This method returns true if this node has that type.

Returns
true if this ASTNode is the special symbol avogadro, false otherwise.
See also
SBML_parseL3Formula()

◆ isBoolean()

bool ASTNode::isBoolean ( ) const

Returns true if this node has a Boolean type.

The ASTNode objects that have Boolean types are the logical operators, relational operators, and the constants true or false.

Returns
true if this ASTNode has a Boolean type, false otherwise.

◆ isCiNumber()

bool ASTNode::isCiNumber ( ) const

Returns true (nonzero) if this node represents a MathML ci element representing a value not a function (e.g., true, Pi).

Returns
true if this ASTNode is a MathML ci element, false otherwise.

◆ isConstant()

bool ASTNode::isConstant ( ) const

Returns true (nonzero) if this node represents a MathML constant (e.g., true, Pi).

Returns
true if this ASTNode is a MathML constant, false otherwise.
Note
this function will also return true for nodes of type AST_NAME_AVOGADRO in SBML Level 3.

◆ isConstantNumber()

bool ASTNode::isConstantNumber ( ) const

Returns true (nonzero) if this node represents a MathML constant with numeric value (e.g., Pi).

Returns
true if this ASTNode is a MathML constant, false otherwise.
Note
this function will also return true for AST_NAME_AVOGADRO in SBML Level 3.

◆ isCSymbolFunction()

bool ASTNode::isCSymbolFunction ( ) const

Returns true (nonzero) if this node represents a MathML csymbol representing a function.

Returns
true if this ASTNode is a MathML csymbol function, false otherwise.

◆ isFunction()

bool ASTNode::isFunction ( ) const

Returns true if this node represents a function.

The three types of functions in SBML are MathML functions (e.g., abs()), SBML Level 1 functions (in the SBML Level 1 math syntax), and user-defined functions (using FunctionDefinition in SBML Level 2 and 3).

Returns
true if this ASTNode is a function, false otherwise.

◆ isInfinity()

bool ASTNode::isInfinity ( ) const

Returns true (nonzero) if this node represents the special IEEE 754 value infinity, false (zero) otherwise.

Returns
true if this ASTNode is the special IEEE 754 value infinity, false otherwise.

◆ isInteger()

bool ASTNode::isInteger ( ) const

Returns true (nonzero) if this node contains an integer value, false (zero) otherwise.

Returns
true if this ASTNode is of type AST_INTEGER, false otherwise.

◆ isLambda()

bool ASTNode::isLambda ( ) const

Returns true (nonzero) if this node is a MathML <lambda>, false (zero) otherwise.

Returns
true if this ASTNode is of type AST_LAMBDA, false otherwise.

◆ isLog10()

bool ASTNode::isLog10 ( ) const

Returns true (nonzero) if this node represents a log10 function, false (zero) otherwise.

More precisely, this predicate returns true if the node type is AST_FUNCTION_LOG with two children, the first of which is an AST_INTEGER equal to 10.

Returns
true if the given ASTNode represents a log10() function, false otherwise.
See also
SBML_parseL3Formula()

◆ isLogical()

bool ASTNode::isLogical ( ) const

Returns true (nonzero) if this node is a MathML logical operator.

The possible MathML logical operators in SBML core are and, or, not, xor, and (as of SBML Level 3 Version 2) implies. If the node represents a logical operator defined in a Level 3 package, it will also return true.

Returns
true if this ASTNode is a MathML logical operator, false otherwise.

◆ isName()

bool ASTNode::isName ( ) const

Returns true if this node is a user-defined variable name or the symbols for time or Avogadro's constant.

SBML Levels 2 and 3 provides <csymbol> definitions for "time" and "avogadro", which can be used to represent simulation time and Avogadro's constant in MathML. Note that this method does not return true for the other csymbol values defined by SBML, "delay", because the "delay" is a function and not a constant or variable. Similarly, this function returns false for the csymbol functions added by the 'Distributions' package.

Returns
true if this ASTNode is a user-defined variable name in SBML or the special symbols for time or Avogadro's constant. It returns false otherwise.

◆ isNaN()

bool ASTNode::isNaN ( ) const

Returns true (nonzero) if this node represents the special IEEE 754 value "not a number" (NaN), false (zero) otherwise.

Returns
true if this ASTNode is the special IEEE 754 NaN, false otherwise.

◆ isNegInfinity()

bool ASTNode::isNegInfinity ( ) const

Returns true (nonzero) if this node represents the special IEEE 754 value "negative infinity", false (zero) otherwise.

Returns
true if this ASTNode is the special IEEE 754 value negative infinity, false otherwise.

◆ isNumber()

bool ASTNode::isNumber ( ) const

Returns true (nonzero) if this node contains a number, false (zero) otherwise.

This is functionally equivalent to the following code:

isInteger() || isReal()
Returns
true if this ASTNode is a number, false otherwise.

◆ isOperator()

bool ASTNode::isOperator ( ) const

Returns true if this node is a mathematical operator.

The possible mathematical operators in the MathML syntax supported by SBML are +, -, *, / and ^ (power).

Returns
true if this ASTNode is an operator, false otherwise.

◆ isPiecewise()

bool ASTNode::isPiecewise ( ) const

Returns true (nonzero) if this node is the MathML <piecewise> construct.

Returns
true if this ASTNode is a MathML piecewise function, false (zero) otherwise.

◆ isRational()

bool ASTNode::isRational ( ) const

Returns true (nonzero) if this node represents a rational number.

Returns
true if this ASTNode is of type AST_RATIONAL, false (zero) otherwise.

◆ isReal()

bool ASTNode::isReal ( ) const

Returns true (nonzero) if this node can represent a real number, false (zero) otherwise.

More precisely, this node must be of one of the following types: AST_REAL, AST_REAL_E or AST_RATIONAL.

Returns
true if the value of this ASTNode can represented as a real number, false otherwise.

◆ isRelational()

bool ASTNode::isRelational ( ) const

Returns true if this node is a MathML relational operator.

The MathML relational operators are ==, >=, >, <, and !=.

Returns
true if this ASTNode is a MathML relational operator, false otherwise

◆ isSetClass()

bool ASTNode::isSetClass ( ) const

Returns true (nonzero) if this node has a value for the MathML attribute "class".

Returns
true if this ASTNode has an attribute class, false otherwise.
See also
isSetId()
isSetStyle()
setClass()
unsetClass()

◆ isSetId()

bool ASTNode::isSetId ( ) const

Returns true (nonzero) if this node has a value for the MathML attribute "id".

Returns
true if this ASTNode has an attribute id, false otherwise.
See also
isSetClass()
isSetStyle()
setId(const std::string& id)
unsetId()

◆ isSetParentSBMLObject()

bool ASTNode::isSetParentSBMLObject ( ) const

Returns true if this node has a value for the parent SBML object.

Returns
true if this ASTNode has an parent SBML object set, false otherwise.
See also
getParentSBMLObject()
setParentSBMLObject()
unsetParentSBMLObject()

◆ isSetStyle()

bool ASTNode::isSetStyle ( ) const

Returns true (nonzero) if this node has a value for the MathML attribute "style".

Returns
true if this ASTNode has an attribute style, false otherwise.
See also
isSetClass()
isSetId()
setStyle(const std::string& id)
unsetStyle()

◆ isSetUnits()

bool ASTNode::isSetUnits ( ) const

Returns true (nonzero) if this node has the attribute sbml:units.

SBML Level 3 Version 1 introduced the ability to include an attribute sbml:units on MathML cn elements appearing in SBML mathematical formulas. The value of this attribute can be used to indicate the unit of measurement to be associated with the number in the content of the cn element. The value of this attribute must be the identifier of a unit of measurement defined by SBML or the enclosing Model. Here, the sbml portion is an XML namespace prefix that must be associated with the SBML namespace for SBML Level 3. The following example illustrates how this attribute can be used to define a number with value 10 and unit of measurement second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Returns
true if this ASTNode has units associated with it, false otherwise.
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
See also
hasUnits()
setUnits(const std::string& units)

◆ isSetUserData()

bool ASTNode::isSetUserData ( ) const

Returns true if this node has a user data object.

Returns
true if this ASTNode has a user data object set, false otherwise.
See also
setUserData()
getUserData()
unsetUserData()

◆ isSqrt()

bool ASTNode::isSqrt ( ) const

Returns true (nonzero) if this node represents a square root function, false (zero) otherwise.

More precisely, the node type must be AST_FUNCTION_ROOT with two children, the first of which is an AST_INTEGER node having value equal to 2.

Returns
true if the given ASTNode represents a sqrt() function, false otherwise.

◆ isUMinus()

bool ASTNode::isUMinus ( ) const

Returns true (nonzero) if this node is a unary minus operator, false (zero) otherwise.

A node is defined as a unary minus node if it is of type AST_MINUS and has exactly one child.

For numbers, unary minus nodes can be "collapsed" by negating the number. In fact, SBML_parseFormula() does this during its parsing process, and SBML_parseL3Formula() has a configuration option that allows this behavior to be turned on or off. However, unary minus nodes for symbols (AST_NAME) cannot be "collapsed", so this predicate function is necessary.

Returns
true if this ASTNode is a unary minus, false otherwise.
See also
SBML_parseL3Formula()

◆ isUnknown()

bool ASTNode::isUnknown ( ) const

Returns true (nonzero) if this node has an unknown type.

"Unknown" nodes have the type AST_UNKNOWN. Nodes with unknown types will not appear in an ASTNode tree returned by libSBML based upon valid SBML input; the only situation in which a node with type AST_UNKNOWN may appear is immediately after having create a new, untyped node using the ASTNode constructor. Callers creating nodes should endeavor to set the type to a valid node type as soon as possible after creating new nodes.

Returns
true if this ASTNode is of type AST_UNKNOWN, false otherwise.

◆ isUPlus()

bool ASTNode::isUPlus ( ) const

Returns true (nonzero) if this node is a unary plus operator, false (zero) otherwise.

A node is defined as a unary minus node if it is of type AST_MINUS and has exactly one child.

Returns
true if this ASTNode is a unary plus, false otherwise.

◆ isUserFunction()

bool ASTNode::isUserFunction ( ) const

Returns true (nonzero) if this node represents a MathML user-defined function.

Returns
true if this ASTNode is a user-defined function, false otherwise.

◆ isWellFormedASTNode()

bool ASTNode::isWellFormedASTNode ( ) const

Returns true or false depending on whether this ASTNode is well-formed.

Note
An ASTNode may be well-formed, with each node and its children having the appropriate number of children for the given type, but may still be invalid in the context of its use within an SBML model.
Returns
true if this ASTNode is well-formed, false otherwise.
See also
hasCorrectNumberArguments()

◆ operator=()

ASTNode & ASTNode::operator= ( const ASTNode rhs)

Assignment operator for ASTNode.

Parameters
rhsthe object whose values are used as the basis of the assignment.

◆ prependChild()

int ASTNode::prependChild ( ASTNode disownedChild)

Adds the given node as a child of this ASTNode.

This method adds child nodes from right to left.

Parameters
disownedChildthe ASTNode instance to add. Will become a child of the parent node.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode::isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild(ASTNode* disownedChild)
replaceChild(unsigned int n, ASTNode* disownedChild, bool delreplaced)
insertChild(unsigned int n, ASTNode* disownedChild)
removeChild(unsigned int n)

◆ reduceToBinary()

void ASTNode::reduceToBinary ( )

Reduces this ASTNode to a binary tree.

Example: if this ASTNode is and(x, y, z), then the formula of the reduced node is and(and(x, y), z). The operation replaces the formula stored in the current ASTNode object.

◆ refactor()

void ASTNode::refactor ( )

This function refactors an ASTNode to facilitate the use of the algorithm to construct a reaction network from a set of ordinary differential equations.

It performs the following actions:

refactors any numerical ASTNodes so that any operation involving 2 or more numerical nodes is performed and becomes a single node eg (4 + 1 x 2) becomes (6)

encompases a unary minus into the numerical value of a node eg a node representing minus with a single child node representing 2 becomes a single node representing -2

refactors binary nodes, which are the default, into a non-binary representation eg a node representing plus with 2 children which each represent a plus with two numerical children will become a node representing plus with four numerical children

reorders the arguments of any operation so that numerical arguments come first, followed by nodes representing variables, followed by nodes representing functions eg a node (sin(a + 2) - 3 + b) becomes (-3 + b + sin(2 + a))

◆ refactorNumbers()

void ASTNode::refactorNumbers ( )
protected

◆ removeChild()

int ASTNode::removeChild ( unsigned int  n,
bool  delremoved = false 
)

Removes the nth child of this ASTNode object.

Parameters
nunsigned int the index of the child to remove.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode::isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild(ASTNode* disownedChild)
prependChild(ASTNode* disownedChild)
replaceChild(unsigned int n, ASTNode* disownedChild, bool delreplaced)
insertChild(unsigned int n, ASTNode* disownedChild)

◆ renameSIdRefs()

void ASTNode::renameSIdRefs ( const std::string &  oldid,
const std::string &  newid 
)
virtual

Renames all the SIdRef attributes on this node and any child node.

◆ renameUnitSIdRefs()

void ASTNode::renameUnitSIdRefs ( const std::string &  oldid,
const std::string &  newid 
)
virtual

Renames all the UnitSIdRef attributes on this node and any child node.

The only place UnitSIDRefs appear is in MathML <cn> elements, so the effects of this method are limited to that.

Parameters
oldidthe old identifier.
newidthe new identifier.

◆ reorderArguments()

bool ASTNode::reorderArguments ( unsigned int  level = 0)
protected

◆ replaceArgument()

void ASTNode::replaceArgument ( const std::string &  bvar,
ASTNode arg 
)

Replaces occurrences of a given name with a given ASTNode.

For example, if the formula in this ASTNode is x + y, and the function is called with bvar = "x" and arg = an ASTNode representing the real value 3. This method would substitute 3 for x within this ASTNode object, resulting in the formula 3 + y.

Parameters
bvara string representing the variable name to be substituted.
argan ASTNode representing the name/value/formula to use as a replacement.

◆ replaceArguments()

void ASTNode::replaceArguments ( const std::vector< std::string > &  bvars,
std::vector< ASTNode * > &  args 
)

Replaces occurrences of each given name with the corresponding ASTNode.

For example, if the formula in this ASTNode is x - y, and the function is called with bvars = {"x", "y"} and args = ASTNodes representing objects with names {"y", "x"}, the result would be y - x.

Parameters
bvarsa vector of strings representing the variable names to be substituted.
argsa vector of ASTNodes representing the name/value/formula to use as a replacement for each variable name

◆ replaceChild()

int ASTNode::replaceChild ( unsigned int  n,
ASTNode disownedChild,
bool  delreplaced = false 
)

Replaces and optionally deletes the nth child of this ASTNode with the given ASTNode.

Parameters
nunsigned int the index of the child to replace.
disownedChildASTNode to replace the nth child. Will become a child of the parent node.
delreplacedBoolean indicating whether to delete the replaced child.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode::isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild(ASTNode* disownedChild)
prependChild(ASTNode* disownedChild)
insertChild(unsigned int n, ASTNode* disownedChild)
removeChild(unsigned int n)

◆ returnsBoolean()

bool ASTNode::returnsBoolean ( const Model model = NULL) const

Returns true (nonzero) if this node returns a Boolean type or false (zero) otherwise.

This function looks at the whole ASTNode rather than just the top level of the ASTNode. Thus it will consider return values from piecewise statements. In addition, if this ASTNode uses a function call, the return value of the functionDefinition will be determined. Note that this is only possible where the ASTNode can trace its parent Model, that is, the ASTNode must represent the <math> element of some SBML object that has already been added to an instance of an SBMLDocument. If this is not the case, this function will return false unless isBoolean() returns true.

See also
isBoolean()
Returns
true if this ASTNode returns a Boolean, false otherwise.

◆ setCharacter()

int ASTNode::setCharacter ( char  value)

Sets the value of this ASTNode to the given character.

If character is one of +, -, *, / or ^, the node type will be set accordingly. For all other characters, the node type will be set to AST_UNKNOWN.

Parameters
valuethe character value to which the node's value should be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:

◆ setClass()

int ASTNode::setClass ( const std::string &  className)

Sets the MathML attribute class of this ASTNode to className.

Parameters
classNamestring representing the MathML class for this node.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:
See also
isSetClass()
getClass()
unsetClass()

◆ setId()

int ASTNode::setId ( const std::string &  id)

Sets the MathML attribute id of this ASTNode.

Parameters
idstring representing the identifier.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:
See also
isSetId()
getId()
unsetId()

◆ setName()

int ASTNode::setName ( const char *  name)

Sets the value of this ASTNode to the given name.

As a side effect, this ASTNode object's type will be reset to AST_NAME if (and only if) the ASTNode was previously an operator ( isOperator() == true), number ( isNumber() == true), or unknown. This allows names to be set for AST_FUNCTION nodes and the like.

Parameters
namethe string containing the name to which this node's value should be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:
Examples
createExampleSBML.cpp.

◆ setStyle()

int ASTNode::setStyle ( const std::string &  style)

Sets the MathML attribute style of this ASTNode to style.

Parameters
stylestring representing the identifier.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:
See also
isSetStyle()
getStyle()
unsetStyle()

◆ setType()

int ASTNode::setType ( ASTNodeType_t  type)

Sets the type of this ASTNode to the given type code.

Parameters
typethe type to which this node should be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Note
A side-effect of doing this is that any numerical values previously stored in this node are reset to zero.

◆ setUnits()

int ASTNode::setUnits ( const std::string &  units)

Sets the units of this ASTNode to units.

The units will be set only if this ASTNode object represents a MathML <cn> element, i.e., represents a number. Callers may use isNumber() to inquire whether the node is of that type.

SBML Level 3 Version 1 introduced the ability to include an attribute sbml:units on MathML cn elements appearing in SBML mathematical formulas. The value of this attribute can be used to indicate the unit of measurement to be associated with the number in the content of the cn element. The value of this attribute must be the identifier of a unit of measurement defined by SBML or the enclosing Model. Here, the sbml portion is an XML namespace prefix that must be associated with the SBML namespace for SBML Level 3. The following example illustrates how this attribute can be used to define a number with value 10 and unit of measurement second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Parameters
unitsstring representing the unit identifier.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
See also
isSetUnits()
hasUnits()

◆ setUserData()

int ASTNode::setUserData ( void *  userData)

Sets the user data of this node.

The user data can be used by the application developer to attach custom information to the node. In case of a deep copy, this attribute will passed as it is. The attribute will be never interpreted by this class.

Parameters
userDataspecifies the new user data.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
See also
isSetUserData()
getUserData()
unsetUserData()

◆ setValue() [1/5]

int ASTNode::setValue ( double  mantissa,
long  exponent 
)

Sets the value of this ASTNode to the given real (double) in two parts: the mantissa and the exponent.

The node type is set to AST_REAL_E.

Parameters
mantissathe mantissa of this node's real-numbered value.
exponentthe exponent of this node's real-numbered value.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:

◆ setValue() [2/5]

int ASTNode::setValue ( double  value)

Sets the value of this ASTNode to the given real (double) and sets the node type to AST_REAL.

This is functionally equivalent to:

setValue(value, 0);
Parameters
valuethe double format number to which this node's value should be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:

◆ setValue() [3/5]

int ASTNode::setValue ( int  value)

Sets the value of this ASTNode to the given integer and sets the node type to AST_INTEGER.

Parameters
valuethe integer to which this node's value should be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:

◆ setValue() [4/5]

int ASTNode::setValue ( long  numerator,
long  denominator 
)

Sets the value of this ASTNode to the given rational in two parts: the numerator and denominator.

The node type is set to AST_RATIONAL.

Parameters
numeratorthe numerator value of the rational.
denominatorthe denominator value of the rational.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:

◆ setValue() [5/5]

int ASTNode::setValue ( long  value)

Sets the value of this ASTNode to the given (long) integer and sets the node type to AST_INTEGER.

Parameters
valuethe integer to which this node's value should be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. This particular function only does one thing irrespective of user input or object state, and thus will only return a single value:

◆ simplify()

void ASTNode::simplify ( )
protected

◆ swapChildren()

int ASTNode::swapChildren ( ASTNode that)

Swaps the children of this ASTNode object with the children of the given ASTNode object.

Parameters
thatthe other node whose children should be used to replace this node's children.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ unsetClass()

int ASTNode::unsetClass ( )

Unsets the MathML class attribute of this ASTNode.

Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ unsetId()

int ASTNode::unsetId ( )

Unsets the MathML id attribute of this ASTNode.

Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ unsetParentSBMLObject()

int ASTNode::unsetParentSBMLObject ( )

Unsets the parent SBML object.

Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
See also
isSetParentSBMLObject()
getParentSBMLObject()
setParentSBMLObject()

◆ unsetStyle()

int ASTNode::unsetStyle ( )

Unsets the MathML style attribute of this ASTNode.

Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ unsetUnits()

int ASTNode::unsetUnits ( )

Unsets the units of this ASTNode.

Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ unsetUserData()

int ASTNode::unsetUserData ( )

Unsets the user data of this node.

The user data can be used by the application developer to attach custom information to the node. In case of a deep copy, this attribute will passed as it is. The attribute will be never interpreted by this class.

Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
See also
setUserData()
getUserData()
isSetUserData()

Friends And Related Function Documentation

◆ SBMLRateRuleConverter

friend class SBMLRateRuleConverter
friend