libSBML C# API  libSBML 5.16.0 C# API
libsbmlcs.ASTNode Class Reference
Inheritance diagram for libsbmlcs.ASTNode:
[legend]

Detailed Description

{core}

Abstract Syntax Trees for mathematical expressions.

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. 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()

Public Member Functions

int addChild (ASTNode disownedChild)
 Adds the given node as a child of this ASTNode. More...
 
virtual void addPlugin (ASTBasePlugin plugin)
 
virtual void addPlugin (string package)
 
int addSemanticsAnnotation (XMLNode disownedAnnotation)
 Adds the given XMLNode as a MathML. More...
 
 ASTNode (int type)
 
 ASTNode ()
 
 ASTNode (SBMLNamespaces sbmlns, int type)
 
 ASTNode (SBMLNamespaces sbmlns)
 
 ASTNode (ASTNode orig)
 Copy constructor; creates a deep copy of the given ASTNode. More...
 
bool canonicalize ()
 Converts this ASTNode to a canonical form. More...
 
ASTBase deepCopy ()
 Creates a recursive copy of this node and all its children. More...
 
override void Dispose ()
 
override bool Equals (Object sb)
 
int freeName ()
 Frees the name of this ASTNode and sets it to null. More...
 
char getCharacter ()
 Returns the value of this node as a single character. More...
 
new ASTNode getChild (long n)
 Returns the child at index n of this node. More...
 
string getClass ()
 Returns the MathML class attribute value of this ASTNode. More...
 
XMLAttributes getDefinitionURL ()
 Returns the MathML definitionURL attribute value. More...
 
string getDefinitionURLString ()
 Returns the MathML definitionURL attribute value as a string. More...
 
int getDenominator ()
 Returns the value of the denominator of this node. More...
 
int getExponent ()
 Returns the exponent value of this ASTNode. More...
 
new int getExtendedType ()
 Returns the extended type of this ASTNode. More...
 
virtual ASTBase getFunction ()
 
override int GetHashCode ()
 
string getId ()
 Returns the MathML id attribute value of this ASTNode. More...
 
int getInteger ()
 Returns the value of this node as an integer. More...
 
ASTNode getLeftChild ()
 Returns the left child of this node. More...
 
ASTNodeList getListOfNodes ()
 
double getMantissa ()
 Returns the mantissa value of this node. More...
 
string getName ()
 Returns the value of this node as a string. More...
 
string getNameFromType (int type)
 
long getNumBvars ()
 
long getNumChildren ()
 Returns the number of children of this node. More...
 
int getNumerator ()
 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 (false) otherwise. More...
 
long getNumPiece ()
 
long getNumSemanticsAnnotations ()
 Returns the number of MathML. More...
 
string getOperatorName ()
 Returns the value of this operator node as a string. More...
 
SBase getParentSBMLObject ()
 Returns the parent SBML object. More...
 
int getPrecedence ()
 Returns the precedence of this node in the infix math syntax of SBML Level 1. More...
 
double getReal ()
 Returns the real-numbered value of this node. More...
 
ASTNode getRightChild ()
 Returns the right child of this node. More...
 
XMLNode getSemanticsAnnotation (long n)
 Returns the nth MathML. More...
 
string getStyle ()
 Returns the MathML style attribute value of this ASTNode. More...
 
int getType ()
 Returns the type of this ASTNode. More...
 
int getTypeFromName (string name)
 
string getUnits ()
 Returns the units of this ASTNode. More...
 
double getValue ()
 Returns the numerical value of this ASTNode. More...
 
bool hasCorrectNumberArguments ()
 Returns true if this ASTNode has the correct number of children for its type. More...
 
int hasTypeAndNumChildren (int type, long numchildren)
 Returns true if this node is of a certain type with a specific number of children. More...
 
bool hasUnits ()
 Returns true if this node or any of its children nodes have the attribute. More...
 
int insertChild (long n, ASTNode disownedChild)
 Inserts the given ASTNode node at a given point in the current ASTNode's list of children. More...
 
new bool isAvogadro ()
 Returns true if this node represents the predefined value for Avogadro's constant. More...
 
bool isBinaryFunction ()
 
new bool isBoolean ()
 Returns true if this node has a Boolean type. More...
 
bool isCiNumber ()
 
new bool isConstant ()
 Returns true if this node represents a MathML constant. More...
 
new bool isConstantNumber ()
 Returns true if this node represents a MathML constant numeric. More...
 
bool isCSymbolFunction ()
 
bool isCSymbolNumber ()
 
bool isExponential ()
 
new bool isFunction ()
 Returns true if this node represents a function. More...
 
bool isFunctionNode ()
 
bool isInfinity ()
 Returns true if this node represents the special IEEE 754 value for infinity. More...
 
new bool isInteger ()
 Returns true if this node of type AST_INTEGER. More...
 
new bool isLambda ()
 Returns true if this node is a MathML. More...
 
new bool isLog10 ()
 Returns true if this node represents a log10 function. More...
 
new bool isLogical ()
 Returns true if this node is a MathML logical operator. More...
 
new bool isName ()
 Returns true if this node is a user-defined variable name or the symbols for time or Avogadro's constant. More...
 
bool isNaN ()
 Returns true if this node represents the special IEEE 754 value 'not a number' (NaN). More...
 
bool isNaryFunction ()
 
bool isNegInfinity ()
 Returns true if this node represents the special IEEE 754 value 'negative infinity'. More...
 
new bool isNumber ()
 Returns true if this node contains a number. More...
 
bool isNumberNode ()
 
new bool isOperator ()
 Returns true if this node is a mathematical operator. More...
 
new bool isPiecewise ()
 Returns true if this node is the MathML. More...
 
new bool isQualifier ()
 Predicate returning true if this node is a MathML qualifier. More...
 
new bool isRational ()
 Returns true if this node represents a rational number. More...
 
new bool isReal ()
 Returns true if this node can represent a real number. More...
 
new bool isRelational ()
 Returns true if this node is a MathML relational operator. More...
 
new bool isSemantics ()
 Predicate returning true if this node is a MathML semantics node. More...
 
bool isSetClass ()
 Returns true if this node has a value for the MathML attribute class. More...
 
bool isSetId ()
 Returns true if this node has a value for the MathML attribute id. More...
 
bool isSetParentSBMLObject ()
 Returns true if this node has a value for the parent SBML object. More...
 
bool isSetStyle ()
 Returns true if this node has a value for the MathML attribute style. More...
 
bool isSetType ()
 
bool isSetUnits ()
 Returns true if this node has the attribute. More...
 
bool isSetUserData ()
 Returns true if this node has a user data object. More...
 
bool isSqrt ()
 Returns true if this node represents a square root function. More...
 
bool isTopLevelMathMLFunctionNodeTag (string name)
 
bool isTopLevelMathMLNumberNodeTag (string name)
 
bool isUMinus ()
 Returns true if this node is a unary minus operator. More...
 
bool isUnaryFunction ()
 
new bool isUnknown ()
 Returns true if this node has an unknown type. More...
 
bool isUPlus ()
 Returns true if this node is a unary plus operator. More...
 
bool isUserFunction ()
 
bool isWellFormedASTNode ()
 Returns true or false depending on whether this ASTNode is well-formed. More...
 
void loadASTPlugins (SBMLNamespaces sbmlns)
 
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...
 
int removeChild (long n)
 Removes the nth child of this ASTNode object. More...
 
new void renameSIdRefs (string oldid, string newid)
 Renames all the SIdRef attributes on this node and its child nodes. More...
 
new void renameUnitSIdRefs (string oldid, string newid)
 Renames all the UnitSIdRef attributes on this node and its child nodes. More...
 
void replaceArgument (string bvar, ASTNode arg)
 Replaces occurrences of a given name with a given ASTNode. More...
 
int replaceChild (long n, ASTNode disownedChild, bool delreplaced)
 Replaces the nth child of this ASTNode with the given ASTNode. More...
 
int replaceChild (long n, ASTNode disownedChild)
 Replaces the nth child of this ASTNode with the given ASTNode. More...
 
bool returnsBoolean (Model model)
 Returns true if this node returns a Boolean value. More...
 
bool returnsBoolean ()
 Returns true if this node returns a Boolean value. More...
 
int setCharacter (char value)
 Sets the value of this ASTNode to the given character. More...
 
int setClass (string className)
 Sets the MathML attribute class of this ASTNode. More...
 
int setDefinitionURL (XMLAttributes url)
 Sets the MathML attribute definitionURL. More...
 
int setDefinitionURL (string url)
 Sets the MathML attribute definitionURL. More...
 
int setId (string id)
 Sets the MathML attribute id of this ASTNode. More...
 
int setIsBvar (bool isbvar)
 
int setName (string name)
 Sets the value of this ASTNode to the given name. More...
 
int setPackageName (string name)
 
int setStyle (string style)
 Sets the MathML attribute style of this ASTNode. More...
 
int setType (int type)
 Sets the type of this ASTNode. More...
 
int setUnits (string units)
 Sets the units of this ASTNode to units. More...
 
int setValue (int value)
 Sets the value of this ASTNode to the given (long) integer. More...
 
int setValue (int numerator, int denominator)
 Sets the value of this ASTNode to the given rational. More...
 
int setValue (double value)
 Sets the value of this ASTNode to the given real (double). More...
 
int setValue (double mantissa, int exponent)
 Sets the value of this ASTNode to the given real (double) More...
 
int swapChildren (ASTNode that)
 Swaps the children of this node with the children of another node. 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...
 
bool usesL3V2MathConstructs ()
 
bool usesRateOf ()
 

Static Public Member Functions

static bool operator!= (ASTNode lhs, ASTNode rhs)
 
static bool operator== (ASTNode lhs, ASTNode rhs)
 

Protected Attributes

bool swigCMemOwn
 

Constructor & Destructor Documentation

◆ ASTNode() [1/5]

libsbmlcs.ASTNode.ASTNode ( int  type)

◆ ASTNode() [2/5]

libsbmlcs.ASTNode.ASTNode ( )

◆ ASTNode() [3/5]

libsbmlcs.ASTNode.ASTNode ( SBMLNamespaces  sbmlns,
int  type 
)

◆ ASTNode() [4/5]

libsbmlcs.ASTNode.ASTNode ( SBMLNamespaces  sbmlns)

◆ ASTNode() [5/5]

libsbmlcs.ASTNode.ASTNode ( ASTNode  orig)

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

Parameters
origthe ASTNode to be copied.

Member Function Documentation

◆ addChild()

int libsbmlcs.ASTNode.addChild ( ASTNode  disownedChild)

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. Will become a child of the parent node.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode objectmay 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 method ASTNode::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()

◆ addPlugin() [1/2]

virtual void libsbmlcs.ASTBase.addPlugin ( ASTBasePlugin  plugin)
virtualinherited

◆ addPlugin() [2/2]

virtual void libsbmlcs.ASTBase.addPlugin ( string  package)
virtualinherited

◆ addSemanticsAnnotation()

int libsbmlcs.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 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 libsbmlcs.ASTNode.canonicalize ( )

Converts this ASTNode to a canonical form.

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.

Returns
true if this node was successfully converted to canonical form, false otherwise.

◆ deepCopy()

ASTBase libsbmlcs.ASTNode.deepCopy ( )

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.

◆ Dispose()

override void libsbmlcs.ASTNode.Dispose ( )
virtual

Reimplemented from libsbmlcs.ASTBase.

◆ Equals()

override bool libsbmlcs.ASTNode.Equals ( Object  sb)

◆ freeName()

int libsbmlcs.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 possible values returned by this function are:

◆ getCharacter()

char libsbmlcs.ASTNode.getCharacter ( )

Returns the value of this node as a single character.

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

Returns
the value of this ASTNode as a single character.

◆ getChild()

new ASTNode libsbmlcs.ASTNode.getChild ( long  n)

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 > ASTNode::getNumChildren()- 1).
See also
getNumChildren()
getLeftChild()
getRightChild()

◆ getClass()

string libsbmlcs.ASTNode.getClass ( )

Returns the MathML class attribute value of this ASTNode.

Returns
the MathML class of this ASTNode, if any exists.
See also
isSetClass()
setClass()
unsetClass()

◆ getDefinitionURL()

XMLAttributes libsbmlcs.ASTNode.getDefinitionURL ( )

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(string url)
getDefinitionURLString()

◆ getDefinitionURLString()

string libsbmlcs.ASTNode.getDefinitionURLString ( )

Returns the MathML definitionURL attribute value as a string.

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

◆ getDenominator()

int libsbmlcs.ASTNode.getDenominator ( )

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 ASTNode::getType()returns AST_RATIONAL. It will return 1 (true) 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()

int libsbmlcs.ASTNode.getExponent ( )

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 ASTNode::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()

◆ getExtendedType()

new int libsbmlcs.ASTNode.getExtendedType ( )

Returns the extended type of this ASTNode.

The type may be either a core integer type codeor a value of a type code defined by an SBML Level 3 package.

Returns
the type of this ASTNode.
Note
When the ASTNode is of a type from a package, the value returned by ASTNode::getType() will be AST_ORIGINATES_IN_PACKAGE and getExtendedType() will return a package-specific type code. To find out the possible package-specific types (if any), please consult the documentation for the particular package.
See also
getType()

◆ getFunction()

virtual ASTBase libsbmlcs.ASTBase.getFunction ( )
virtualinherited

◆ GetHashCode()

override int libsbmlcs.ASTNode.GetHashCode ( )

◆ getId()

string libsbmlcs.ASTNode.getId ( )

Returns the MathML id attribute value of this ASTNode.

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

◆ getInteger()

int libsbmlcs.ASTNode.getInteger ( )

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 (false) otherwise.
Note
This function should be called only when ASTNode::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()

◆ getLeftChild()

ASTNode libsbmlcs.ASTNode.getLeftChild ( )

Returns the left child of this node.

Returns
the left child of this ASTNode. This is equivalent to calling ASTNode::getChild(unsigned int)with an argument of 0.
See also
getNumChildren()
getChild()
getRightChild()

◆ getListOfNodes()

ASTNodeList libsbmlcs.ASTNode.getListOfNodes ( )

◆ getMantissa()

double libsbmlcs.ASTNode.getMantissa ( )

Returns the mantissa value of this node.

If ASTNode::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 ASTNode::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()

string libsbmlcs.ASTNode.getName ( )

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 ASTNode::isOperator()returns false, and (2) are not numbers, i.e., ASTNode::isNumber()returns false.

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).

◆ getNameFromType()

string libsbmlcs.ASTBase.getNameFromType ( int  type)
inherited

◆ getNumBvars()

long libsbmlcs.ASTNode.getNumBvars ( )

◆ getNumChildren()

long libsbmlcs.ASTNode.getNumChildren ( )

Returns the number of children of this node.

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

◆ getNumerator()

int libsbmlcs.ASTNode.getNumerator ( )

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 (false) otherwise.

This function should be called only when ASTNode::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 (false) otherwise.
See also
getDenominator()
getInteger()

◆ getNumPiece()

long libsbmlcs.ASTNode.getNumPiece ( )

◆ getNumSemanticsAnnotations()

long libsbmlcs.ASTNode.getNumSemanticsAnnotations ( )

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()

string libsbmlcs.ASTNode.getOperatorName ( )

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 ASTNode::isOperator()returns true.

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

◆ getParentSBMLObject()

SBase libsbmlcs.ASTNode.getParentSBMLObject ( )

Returns the parent SBML object.

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

◆ getPrecedence()

int libsbmlcs.ASTNode.getPrecedence ( )

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 libsbmlcs.ASTNode.getReal ( )

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 libsbmlcs.ASTNode.getRightChild ( )

Returns the right child of this node.

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

◆ getSemanticsAnnotation()

XMLNode libsbmlcs.ASTNode.getSemanticsAnnotation ( long  n)

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 > ASTNode::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
addSemanticsAnnotation()
getNumSemanticsAnnotations()

◆ getStyle()

string libsbmlcs.ASTNode.getStyle ( )

Returns the MathML style attribute value of this ASTNode.

Returns
the MathML style of this ASTNode, if any exists.
See also
isSetStyle()
setStyle(string id)
unsetStyle()

◆ getType()

int libsbmlcs.ASTNode.getType ( )

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.
Note
The introduction of extensibility in SBML Level 3 brings with it a need to allow for the possibility of node types that are defined by plug-ins implementing SBML Level 3 packages. If a given ASTNode is a construct created by a package rather than libSBML Core, then ASTNode::getType() will return AST_ORIGINATES_IN_PACKAGE. Callers can then obtain the package-specific type by calling getExtendedType().
See also
getExtendedType()

◆ getTypeFromName()

int libsbmlcs.ASTBase.getTypeFromName ( string  name)
inherited

◆ getUnits()

string libsbmlcs.ASTNode.getUnits ( )

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()

◆ getValue()

double libsbmlcs.ASTNode.getValue ( )

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 libsbmlcs.ASTNode.hasCorrectNumberArguments ( )

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 libsbmlcs.ASTNode.hasTypeAndNumChildren ( int  type,
long  numchildren 
)

Returns true if this node is of a certain type with a specific 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.

Parameters
typethe type of ASTNode sought.
numchildrenthe number of child nodes sought.
Returns
true if this ASTNode is has the specified type and number of children, false otherwise.

◆ hasUnits()

bool libsbmlcs.ASTNode.hasUnits ( )

Returns true 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(string units)

◆ insertChild()

int libsbmlcs.ASTNode.insertChild ( long  n,
ASTNode  disownedChild 
)

Inserts the given ASTNode node at a given point in the current ASTNode's list of children.

Parameters
nunsigned int the index of the ASTNode being added.
disownedChildASTNode to insert as the nth child. Will become a child of the parent node.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode objectmay 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 method ASTNode::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()

new bool libsbmlcs.ASTNode.isAvogadro ( )

Returns true if this node represents the predefined value for Avogadro's constant.

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()

◆ isBinaryFunction()

bool libsbmlcs.ASTBase.isBinaryFunction ( )
inherited

◆ isBoolean()

new bool libsbmlcs.ASTNode.isBoolean ( )

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 libsbmlcs.ASTBase.isCiNumber ( )
inherited

◆ isConstant()

new bool libsbmlcs.ASTNode.isConstant ( )

Returns true if this node represents a MathML constant.

Examples of MathML constants include such things as 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()

new bool libsbmlcs.ASTNode.isConstantNumber ( )

Returns true if this node represents a MathML constant numeric.

Examples of MathML constants include such things as 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.

◆ isCSymbolFunction()

bool libsbmlcs.ASTBase.isCSymbolFunction ( )
inherited

◆ isCSymbolNumber()

bool libsbmlcs.ASTBase.isCSymbolNumber ( )
inherited

◆ isExponential()

bool libsbmlcs.ASTBase.isExponential ( )
inherited

◆ isFunction()

new bool libsbmlcs.ASTNode.isFunction ( )

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.

◆ isFunctionNode()

bool libsbmlcs.ASTBase.isFunctionNode ( )
inherited

◆ isInfinity()

bool libsbmlcs.ASTNode.isInfinity ( )

Returns true if this node represents the special IEEE 754 value for infinity.

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

◆ isInteger()

new bool libsbmlcs.ASTNode.isInteger ( )

Returns true if this node of type AST_INTEGER.

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

◆ isLambda()

new bool libsbmlcs.ASTNode.isLambda ( )

Returns true if this node is a MathML.

<lambda>.

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

◆ isLog10()

new bool libsbmlcs.ASTNode.isLog10 ( )

Returns true if this node represents a log10 function.

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()

new bool libsbmlcs.ASTNode.isLogical ( )

Returns true 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()

new bool libsbmlcs.ASTNode.isName ( )

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.

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 libsbmlcs.ASTNode.isNaN ( )

Returns true if this node represents the special IEEE 754 value 'not a number' (NaN).

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

◆ isNaryFunction()

bool libsbmlcs.ASTBase.isNaryFunction ( )
inherited

◆ isNegInfinity()

bool libsbmlcs.ASTNode.isNegInfinity ( )

Returns true if this node represents the special IEEE 754 value 'negative infinity'.

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

◆ isNumber()

new bool libsbmlcs.ASTNode.isNumber ( )

Returns true if this node contains a number.

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

◆ isNumberNode()

bool libsbmlcs.ASTBase.isNumberNode ( )
inherited

◆ isOperator()

new bool libsbmlcs.ASTNode.isOperator ( )

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()

new bool libsbmlcs.ASTNode.isPiecewise ( )

Returns true if this node is the MathML.

<piecewise> construct.

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

◆ isQualifier()

new bool libsbmlcs.ASTNode.isQualifier ( )

Predicate returning true if this node is a MathML qualifier.

The MathML qualifier node types are bvar, degree, base, piece, and otherwise.

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

◆ isRational()

new bool libsbmlcs.ASTNode.isRational ( )

Returns true if this node represents a rational number.

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

◆ isReal()

new bool libsbmlcs.ASTNode.isReal ( )

Returns true if this node can represent a real number.

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()

new bool libsbmlcs.ASTNode.isRelational ( )

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.

◆ isSemantics()

new bool libsbmlcs.ASTNode.isSemantics ( )

Predicate returning true if this node is a MathML semantics node.

Returns
true if this ASTNode is a MathML semantics node, false otherwise.

◆ isSetClass()

bool libsbmlcs.ASTNode.isSetClass ( )

Returns true 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 libsbmlcs.ASTNode.isSetId ( )

Returns true 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(string id)
unsetId()

◆ isSetParentSBMLObject()

bool libsbmlcs.ASTNode.isSetParentSBMLObject ( )

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()
unsetParentSBMLObject()

◆ isSetStyle()

bool libsbmlcs.ASTNode.isSetStyle ( )

Returns true 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(string id)
unsetStyle()

◆ isSetType()

bool libsbmlcs.ASTBase.isSetType ( )
inherited

◆ isSetUnits()

bool libsbmlcs.ASTNode.isSetUnits ( )

Returns true 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(string units)

◆ isSetUserData()

bool libsbmlcs.ASTNode.isSetUserData ( )

Returns true if this node has a user data object.

Returns
true if this ASTNode has a user data object set, false otherwise.

◆ isSqrt()

bool libsbmlcs.ASTNode.isSqrt ( )

Returns true if this node represents a square root function.

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.

◆ isTopLevelMathMLFunctionNodeTag()

bool libsbmlcs.ASTBase.isTopLevelMathMLFunctionNodeTag ( string  name)
inherited

◆ isTopLevelMathMLNumberNodeTag()

bool libsbmlcs.ASTBase.isTopLevelMathMLNumberNodeTag ( string  name)
inherited

◆ isUMinus()

bool libsbmlcs.ASTNode.isUMinus ( )

Returns true if this node is a unary minus operator.

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()

◆ isUnaryFunction()

bool libsbmlcs.ASTBase.isUnaryFunction ( )
inherited

◆ isUnknown()

new bool libsbmlcs.ASTNode.isUnknown ( )

Returns true 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 libsbmlcs.ASTNode.isUPlus ( )

Returns true if this node is a unary plus operator.

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

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

◆ isUserFunction()

bool libsbmlcs.ASTBase.isUserFunction ( )
inherited

◆ isWellFormedASTNode()

bool libsbmlcs.ASTNode.isWellFormedASTNode ( )

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()

◆ loadASTPlugins()

void libsbmlcs.ASTBase.loadASTPlugins ( SBMLNamespaces  sbmlns)
inherited

◆ operator!=()

static bool libsbmlcs.ASTNode.operator!= ( ASTNode  lhs,
ASTNode  rhs 
)
static

◆ operator==()

static bool libsbmlcs.ASTNode.operator== ( ASTNode  lhs,
ASTNode  rhs 
)
static

◆ prependChild()

int libsbmlcs.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 possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode objectmay 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 method ASTNode::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 libsbmlcs.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.

◆ removeChild()

int libsbmlcs.ASTNode.removeChild ( long  n)

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 possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode objectmay 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 method ASTNode::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()

new void libsbmlcs.ASTNode.renameSIdRefs ( string  oldid,
string  newid 
)

Renames all the SIdRef attributes on this node and its child nodes.

Parameters
oldidthe old identifier.
newidthe new identifier.

◆ renameUnitSIdRefs()

new void libsbmlcs.ASTNode.renameUnitSIdRefs ( string  oldid,
string  newid 
)

Renames all the UnitSIdRef attributes on this node and its child nodes.

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

Parameters
oldidthe old identifier.
newidthe new identifier.

◆ replaceArgument()

void libsbmlcs.ASTNode.replaceArgument ( 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 forula 3 + y.

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

◆ replaceChild() [1/2]

int libsbmlcs.ASTNode.replaceChild ( long  n,
ASTNode  disownedChild,
bool  delreplaced 
)

Replaces 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 possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode objectmay 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 method ASTNode::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)

◆ replaceChild() [2/2]

int libsbmlcs.ASTNode.replaceChild ( long  n,
ASTNode  disownedChild 
)

Replaces 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 possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode objectmay 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 method ASTNode::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() [1/2]

bool libsbmlcs.ASTNode.returnsBoolean ( Model  model)

Returns true if this node returns a Boolean value.

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 to a user-defined function, the return value of the corresponding FunctionDefinition object 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.

Parameters
modelthe Model to use as context.
See also
isBoolean()
Returns
true if this ASTNode returns a boolean, false otherwise.

◆ returnsBoolean() [2/2]

bool libsbmlcs.ASTNode.returnsBoolean ( )

Returns true if this node returns a Boolean value.

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 to a user-defined function, the return value of the corresponding FunctionDefinition object 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.

Parameters
modelthe Model to use as context.
See also
isBoolean()
Returns
true if this ASTNode returns a boolean, false otherwise.

◆ setCharacter()

int libsbmlcs.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 possible values returned by this function are:

◆ setClass()

int libsbmlcs.ASTNode.setClass ( string  className)

Sets the MathML attribute class of this ASTNode.

Parameters
classNamestring representing the MathML class for this node.
Returns
integer value indicating success/failure of the function. 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()

◆ setDefinitionURL() [1/2]

int libsbmlcs.ASTNode.setDefinitionURL ( XMLAttributes  url)

Sets the MathML attribute definitionURL.

Parameters
urlthe URL value for the definitionURL attribute.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
setDefinitionURL(string url)
getDefinitionURL()
getDefinitionURLString()

◆ setDefinitionURL() [2/2]

int libsbmlcs.ASTNode.setDefinitionURL ( string  url)

Sets the MathML attribute definitionURL.

Parameters
urlthe URL value for the definitionURL attribute.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
setDefinitionURL(XMLAttributes url)
getDefinitionURL()
getDefinitionURLString()

◆ setId()

int libsbmlcs.ASTNode.setId ( string  id)

Sets the MathML attribute id of this ASTNode.

Parameters
idstring representing the identifier.
Returns
integer value indicating success/failure of the function. 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()

◆ setIsBvar()

int libsbmlcs.ASTBase.setIsBvar ( bool  isbvar)
inherited

◆ setName()

int libsbmlcs.ASTNode.setName ( string  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 (i.e., ASTNode::isOperator()returns true), number (i.e., ASTNode::isNumber()returns 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 possible values returned by this function are:

◆ setPackageName()

int libsbmlcs.ASTBase.setPackageName ( string  name)
inherited

◆ setStyle()

int libsbmlcs.ASTNode.setStyle ( string  style)

Sets the MathML attribute style of this ASTNode.

Parameters
stylestring representing the identifier.
Returns
integer value indicating success/failure of the function. 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 libsbmlcs.ASTNode.setType ( int  type)

Sets the type of this ASTNode.

This uses integer type codes, which may come from the set of static integer constants whose names begin with the prefix AST_ or an enumeration of AST types in an SBML Level 3 package.

Parameters
typethe integer representing the type to which this node should be set.
Returns
integer value indicating success/failure of the function. 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.
See also
getType()

◆ setUnits()

int libsbmlcs.ASTNode.setUnits ( 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 ASTNode::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 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()

◆ setValue() [1/4]

int libsbmlcs.ASTNode.setValue ( int  value)

Sets the value of this ASTNode to the given (long) integer.

As a side effect, this operation 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 possible values returned by this function are:

◆ setValue() [2/4]

int libsbmlcs.ASTNode.setValue ( int  numerator,
int  denominator 
)

Sets the value of this ASTNode to the given rational.

As a side effect, this operation sets the node type 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 possible values returned by this function are:

◆ setValue() [3/4]

int libsbmlcs.ASTNode.setValue ( double  value)

Sets the value of this ASTNode to the given real (double).

As a side effect, this operation 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 possible values returned by this function are:

◆ setValue() [4/4]

int libsbmlcs.ASTNode.setValue ( double  mantissa,
int  exponent 
)

Sets the value of this ASTNode to the given real (double)

As a side effet, this operation sets the node type 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 possible values returned by this function are:

◆ swapChildren()

int libsbmlcs.ASTNode.swapChildren ( ASTNode  that)

Swaps the children of this node with the children of another node.

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 possible values returned by this function are:

◆ unsetClass()

int libsbmlcs.ASTNode.unsetClass ( )

Unsets the MathML class attribute of this ASTNode.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

◆ unsetId()

int libsbmlcs.ASTNode.unsetId ( )

Unsets the MathML id attribute of this ASTNode.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

◆ unsetParentSBMLObject()

int libsbmlcs.ASTNode.unsetParentSBMLObject ( )

Unsets the parent SBML object.

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

◆ unsetStyle()

int libsbmlcs.ASTNode.unsetStyle ( )

Unsets the MathML style attribute of this ASTNode.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

◆ unsetUnits()

int libsbmlcs.ASTNode.unsetUnits ( )

Unsets the units of this ASTNode.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

◆ unsetUserData()

int libsbmlcs.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 possible values returned by this function are:

◆ usesL3V2MathConstructs()

bool libsbmlcs.ASTNode.usesL3V2MathConstructs ( )

◆ usesRateOf()

bool libsbmlcs.ASTNode.usesRateOf ( )

Member Data Documentation

◆ swigCMemOwn

bool libsbmlcs.ASTBase.swigCMemOwn
protectedinherited