libSBML Perl API  libSBML 5.19.7 Perl API
L3ParserSettings Class Reference

Detailed Description

@sbmlpackage{core}

Controls the behavior of the Level 3 formula parser.

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.

The function

Public Member Functions

bool getComparisonCaseSensitivity () const
 Returns true if the parser is configured to match built-in symbols in a case-insensitive way. More...
 
const ModelgetModel () const
 Returns the Model object referenced by this L3ParserSettings object. More...
 
bool getParseAvogadroCsymbol () const
 Indicates the current behavior set for handling avogadro for SBML Level 3. More...
 
bool getParseCollapseMinus () const
 Indicates the current behavior set for handling multiple unary minuses in formulas. More...
 
bool getParseL3v2Functions () const
 Indicates the current behavior set for handling whether to parse the functions added in L3v2 as that MathML or not. More...
 
ParseLogType_t getParseLog () const
 Indicates the current behavior set for handling the function log with one argument. More...
 
bool getParseModuloL3v2 () const
 Indicates the current behavior set for handling the % symbol in mathematical formulas. More...
 
bool getParsePackageMath (ExtendedMathType_t package) const
 Indicates the current behavior set for handling whether to parse the functions added in the given package as that MathML or not. More...
 
bool getParseUnits () const
 Indicates the current behavior set for handling units in text-string mathematical formulas. More...
 
 L3ParserSettings ()
 Creates a new L3ParserSettings object with default values. More...
 
 L3ParserSettings (const L3ParserSettings &source)
 Copy constructor. More...
 
 L3ParserSettings (Model *model, ParseLogType_t parselog, bool collapseminus, bool parseunits, bool avocsymbol, bool caseSensitive=false, SBMLNamespaces *sbmlns=NULL, bool moduloL3v2=false, bool l3v2functions=false)
 Creates a new L3ParserSettings object with specific values for all possible settings. More...
 
L3ParserSettingsoperator= (const L3ParserSettings &source)
 Assignment operator. More...
 
void setComparisonCaseSensitivity (bool strcmp)
 Sets the parser's behavior with respect to case sensitivity for recognizing predefined symbols. More...
 
void setModel (const Model *model)
 Sets the model reference in this L3ParserSettings object. More...
 
void setParseAvogadroCsymbol (bool l2only)
 Sets the parser's behavior in handling the symbol avogadro in mathematical formulas. More...
 
void setParseCollapseMinus (bool collapseminus)
 Sets the behavior for handling unary minuses appearing in mathematical formulas. More...
 
void setParseL3v2Functions (bool l3v2functions)
 Sets the behavior for handling functions added in SBML L3v2. More...
 
void setParseLog (ParseLogType_t type)
 Sets the behavior for handling log in mathematical formulas. More...
 
void setParseModuloL3v2 (bool modulol3v2)
 Sets the behavior for handling the % symbol in mathematical formulas. More...
 
void setParsePackageMath (ExtendedMathType_t package, bool parsepackage)
 Sets the behavior for handling functions added in SBML packages. More...
 
void setParseUnits (bool units)
 Sets the parser's behavior in handling units associated with numbers in a mathematical formula. More...
 
void unsetModel ()
 Unsets the Model reference in this L3ParserSettings object. More...
 
virtual ~L3ParserSettings ()
 Destroys this L3ParserSettings object. More...
 

Constructor & Destructor Documentation

◆ L3ParserSettings() [1/3]

L3ParserSettings::L3ParserSettings ( )

Creates a new L3ParserSettings object with default values.

This is the default constructor for the L3ParserSettings object. It sets the stored Model object to NULL and sets the following field values in the L3ParserSettings object:

  • parseunits ("parse units") is set to

◆ L3ParserSettings() [2/3]

L3ParserSettings::L3ParserSettings ( Model model,
ParseLogType_t  parselog,
bool  collapseminus,
bool  parseunits,
bool  avocsymbol,
bool  caseSensitive = false,
SBMLNamespaces sbmlns = NULL,
bool  moduloL3v2 = false,
bool  l3v2functions = false 
)

Creates a new L3ParserSettings object with specific values for all possible settings.

Parameters
modela Model object to be used for disambiguating identifiers encountered by

◆ L3ParserSettings() [3/3]

L3ParserSettings::L3ParserSettings ( const L3ParserSettings source)

Copy constructor.

Parameters
sourcethe instance to copy.

◆ ~L3ParserSettings()

L3ParserSettings::~L3ParserSettings ( )
virtual

Destroys this L3ParserSettings object.

Member Function Documentation

◆ getComparisonCaseSensitivity()

bool L3ParserSettings::getComparisonCaseSensitivity ( ) const

Returns true if the parser is configured to match built-in symbols in a case-insensitive way.

Returns
true if matches are done in a case-sensitive manner, and false if the parser will recognize built-in functions and constants regardless of case,.
See also
setComparisonCaseSensitivity()

◆ getModel()

const Model * L3ParserSettings::getModel ( ) const

Returns the Model object referenced by this L3ParserSettings object.

When a Model object is provided, identifiers (values of type SId) from that model are used in preference to pre-defined MathML symbol definitions. More precisely, the Model entities whose identifiers will shadow identical symbols in the mathematical formula are: Species, Compartment, Parameter, Reaction, and SpeciesReference. For instance, if the parser is given a Model containing a Species with the identifier "pi", and the formula to be parsed is "3*pi", the MathML produced will contain the construct <ci> pi </ci> instead of the construct <pi/>. Similarly, when a Model object is provided, SId values of user-defined functions present in the Model will be used preferentially over pre-defined MathML functions. For example, if the passed-in Model contains a FunctionDefinition with the identifier "sin", that function will be used instead of the predefined MathML function <sin/>.
See also
setModel()
unsetModel()

◆ getParseAvogadroCsymbol()

bool L3ParserSettings::getParseAvogadroCsymbol ( ) const

Indicates the current behavior set for handling avogadro for SBML Level 3.

This method returns the current setting of the avogadro-handling behavior in this L3ParserSettings object. The possible values are as follows:

Returns
A boolean indicating which mode is currently set; one of

◆ getParseCollapseMinus()

bool L3ParserSettings::getParseCollapseMinus ( ) const

Indicates the current behavior set for handling multiple unary minuses in formulas.

This setting affects two behaviors. First, pairs of multiple unary minuses in a row (e.g., "- -3") can be collapsed and ignored in the input, or the multiple minuses can be preserved in the AST node tree that is generated by the parser. Second, minus signs in front of numbers can be collapsed into the number node itself; for example, a "- 4.1" can be turned into a single ASTNode of type
Returns
A boolean indicating the behavior currently set. The possible values are as follows:
See also
setParseCollapseMinus()

◆ getParseL3v2Functions()

bool L3ParserSettings::getParseL3v2Functions ( ) const

Indicates the current behavior set for handling whether to parse the functions added in L3v2 as that MathML or not.

Returns
A boolean indicating the behavior currently set. The possible values are as follows:
See also
setParseL3v2Functions()

◆ getParseLog()

ParseLogType_t L3ParserSettings::getParseLog ( ) const

Indicates the current behavior set for handling the function log with one argument.

The function log with a single argument ("log(x)") can be parsed as log10(x), ln(x), or treated as an error, as desired. These three possible behaviors are indicated, respectively, by the values

◆ getParseModuloL3v2()

bool L3ParserSettings::getParseModuloL3v2 ( ) const

Indicates the current behavior set for handling the % symbol in mathematical formulas.

Returns
A boolean indicating the behavior currently set. The possible values are as follows:
See also
setParseModuloL3v2()

◆ getParsePackageMath()

bool L3ParserSettings::getParsePackageMath ( ExtendedMathType_t  package) const

Indicates the current behavior set for handling whether to parse the functions added in the given package as that MathML or not.

Parameters
packagean ExtendedMathType_t indicating the extended math package to be set.
Returns
A boolean indicating the behavior currently set. The possible values are as follows:
See also
setParsePackageMath()

◆ getParseUnits()

bool L3ParserSettings::getParseUnits ( ) const

Indicates the current behavior set for handling units in text-string mathematical formulas.

Since SBML Level 2 does not have the ability to associate units with pure numbers, the value should be expected to be false (

◆ operator=()

L3ParserSettings & L3ParserSettings::operator= ( const L3ParserSettings source)

Assignment operator.

◆ setComparisonCaseSensitivity()

void L3ParserSettings::setComparisonCaseSensitivity ( bool  strcmp)

Sets the parser's behavior with respect to case sensitivity for recognizing predefined symbols.

Parameters
strcmpa boolean indicating whether to be case sensitive (if true) or be case insensitive (if false).
See also
getComparisonCaseSensitivity()

◆ setModel()

void L3ParserSettings::setModel ( const Model model)

Sets the model reference in this L3ParserSettings object.

When a Model object is provided, identifiers (values of type SId) from that model are used in preference to pre-defined MathML symbol definitions. More precisely, the Model entities whose identifiers will shadow identical symbols in the mathematical formula are: Species, Compartment, Parameter, Reaction, and SpeciesReference. For instance, if the parser is given a Model containing a Species with the identifier "pi", and the formula to be parsed is "3*pi", the MathML produced will contain the construct <ci> pi </ci> instead of the construct <pi/>. Similarly, when a Model object is provided, SId values of user-defined functions present in the Model will be used preferentially over pre-defined MathML functions. For example, if the passed-in Model contains a FunctionDefinition with the identifier "sin", that function will be used instead of the predefined MathML function <sin/>.
Parameters
modela Model object to be used for disambiguating identifiers.
Warning
This does not copy the Model object. This means that modifications made to the Model after invoking this method may affect parsing behavior, because the parser will query the current contents of the model.
See also
getModel()
unsetModel()

◆ setParseAvogadroCsymbol()

void L3ParserSettings::setParseAvogadroCsymbol ( bool  l2only)

Sets the parser's behavior in handling the symbol avogadro in mathematical formulas.

This method allows callers to set the avogadro-handling behavior in this L3ParserSettings object. The possible values of l2only are as follows:

Since SBML Level 2 does not define a symbol for Avogadro's constant, the value should be set to

◆ setParseCollapseMinus()

void L3ParserSettings::setParseCollapseMinus ( bool  collapseminus)

Sets the behavior for handling unary minuses appearing in mathematical formulas.

This setting affects two behaviors. First, pairs of multiple unary minuses in a row (e.g., "- -3") can be collapsed and ignored in the input, or the multiple minuses can be preserved in the AST node tree that is generated by the parser. Second, minus signs in front of numbers can be collapsed into the number node itself; for example, a "- 4.1" can be turned into a single ASTNode of type

This method lets you tell the parser which behavior to use—either collapse minuses or always preserve them. The two possibilities are represented using the following constants:

Parameters
collapseminusa boolean value (one of the constants

◆ setParseL3v2Functions()

void L3ParserSettings::setParseL3v2Functions ( bool  l3v2functions)

Sets the behavior for handling functions added in SBML L3v2.

This method lets you tell the parser which behavior to use—either to parse the functions added in L3v2 as their built-in counterparts, or as generic functions with that name (to be defined by SBML as function definitions). The two possibilities are represented using the following constants:

Parameters
l3v2functionsa boolean value (one of the constants

◆ setParseLog()

void L3ParserSettings::setParseLog ( ParseLogType_t  type)

Sets the behavior for handling log in mathematical formulas.

The function log with a single argument ("log(x)") can be parsed as log10(x), ln(x), or treated as an error. These three behaviors are set, respectively, by using the value

◆ setParseModuloL3v2()

void L3ParserSettings::setParseModuloL3v2 ( bool  modulol3v2)

Sets the behavior for handling the % symbol in mathematical formulas.

This method lets you tell the parser which behavior to use—either parse % as the 'rem' function or as a piecewise function with the same interpretation. The two possibilities are represented using the following constants:

Parameters
modulol3v2a boolean value (one of the constants

◆ setParsePackageMath()

void L3ParserSettings::setParsePackageMath ( ExtendedMathType_t  package,
bool  parsepackage 
)

Sets the behavior for handling functions added in SBML packages.

This method lets you tell the parser which behavior to use—either to parse the functions added in a given package as their built-in counterparts, or as generic functions with that name (to be defined by SBML as function definitions). The two possibilities are represented using the following constants:

Parameters
packagean ExtendedMathType_t indicating the extended math package to be queried.
parsepackagea boolean value (one of the constants

◆ setParseUnits()

void L3ParserSettings::setParseUnits ( bool  units)

Sets the parser's behavior in handling units associated with numbers in a mathematical formula.

This method sets the formula parser's behavior with respect to units.

Parameters
unitsa boolean indicating whether to parse units. The possible values are as follows:
See also
getParseUnits()

◆ unsetModel()

void L3ParserSettings::unsetModel ( )

Unsets the Model reference in this L3ParserSettings object.

The effect of calling this method is to set the stored model value to NULL.

See also
setModel()
getModel()