/usr/include/sbml/math/L3ParserSettings.h is in libsbml5-dev 5.10.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | /**
* @file L3ParserSettings.h
* @brief Definition of the level 3 infix-to-mathml parser settings.
* @author Lucian Smith
*
* <!--------------------------------------------------------------------------
* This file is part of libSBML. Please visit http://sbml.org for more
* information about SBML, and the latest version of libSBML.
*
* Copyright (C) 2013-2014 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
* 3. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2009-2013 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* Copyright (C) 2006-2008 by the California Institute of Technology,
* Pasadena, CA, USA
*
* Copyright (C) 2002-2005 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. Japan Science and Technology Agency, Japan
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation. A copy of the license agreement is provided
* in the file named "LICENSE.txt" included with this software distribution and
* also available online as http://sbml.org/software/libsbml/license.html
* ---------------------------------------------------------------------- -->
*
* @class L3ParserSettings
* @sbmlbrief{core} A helper class for controlling the behavior of the
* text-string formula parser.
*
* @htmlinclude not-sbml-warning.html
*
* The function
* @if clike SBML_parseL3FormulaWithSettings()@endif@if csharp SBML_parseL3FormulaWithSettings()@endif@if python libsbml.parseL3FormulaWithSettings()@endif@if java <code><a href="libsbml.html#parseL3FormulaWithSettings(java.lang.String, org.sbml.libsbml.L3ParserSettings)">libsbml.parseL3FormulaWithSettings(String formula, L3ParserSettings settings)</a></code>@endif@~,
* along with its variants
* @if clike SBML_parseFormula()@endif@if csharp SBML_parseFormula()@endif@if python libsbml.parseFormula()@endif@if java <code><a href="libsbml.html#parseFormula(java.lang.String)">libsbml.parseFormula(java.lang.String formula)</a></code>@endif@~
* and
* @if clike SBML_parseL3FormulaWithModel()@endif@if csharp SBML_parseL3FormulaWithModel()@endif@if python libsbml.parseL3FormulaWithModel()@endif@if java <code><a href="libsbml.html#parseL3FormulaWithModel(java.lang.String, org.sbml.libsbml.Model)">libsbml.parseL3FormulaWithModel(String formula, Model model)</a></code>@endif@~,
* are the interfaces to a parser for mathematical formulas expressed as
* text strings. The parser converts the text-string formulas into
* Abstract Syntax Trees (ASTs), represented in libSBML using ASTNode
* objects. Compared to the parser implemented by the function
* @if clike SBML_parseFormula()@endif@if csharp SBML_parseFormula()@endif@if python libsbml.parseFormula()@endif@if java <code><a href="libsbml.html#parseFormula(java.lang.String)">libsbml.parseFormula(java.lang.String formula)</a></code>@endif@~,
* which was designed primarily for converting the mathematical formula
* strings in SBML Level 1, the "L3" variant of the parser accepts an
* extended formula syntax. It also has a number of configurable behaviors.
* This class (L3ParserSettings) is an object used to communicate the
* configuration settings with callers.
*
* The following aspects of the parser are configurable:
* <ul>
* <li> The function @c log with a single argument ("<code>log(x)</code>")
* can be parsed as <code>log10(x)</code>, <code>ln(x)</code>, or treated
* as an error, as desired.
* <li> Unary minus signs can be collapsed or preserved; that is,
* sequential pairs of unary minuses (e.g., "<code>- -3</code>")
* can be removed from the input entirely and single unary minuses can be
* incorporated into the number node, or all minuses can be preserved in
* the AST node structure.
* <li> Parsing of units embedded in the input string can be turned on and
* off.
* <li> The string @c avogadro can be parsed as a MathML @em csymbol or
* as an identifier.
* <li> A Model object may optionally be provided to the parser using
* the variant function call @if clike SBML_parseL3FormulaWithModel()@endif@if csharp SBML_parseL3FormulaWithModel()@endif@if python libsbml.SBML_parseL3FormulaWithModel()@endif@if java <code><a href="libsbml.html#parseL3FormulaWithModel(java.lang.String, org.sbml.libsbml.Model)">libsbml.parseL3FormulaWithModel(String formula, Model model)</a></code>@endif@~.
* or stored in a L3ParserSettings object passed to the variant function
* @if clike SBML_parseL3FormulaWithSettings()@endif@if csharp SBML_parseL3FormulaWithSettings()@endif@if python libsbml.parseL3FormulaWithSettings()@endif@if java <code><a href="libsbml.html#parseL3FormulaWithSettings(java.lang.String, org.sbml.libsbml.L3ParserSettings)">libsbml.parseL3FormulaWithSettings(String formula, org.sbml.libsbml.L3ParserSettings settings)</a></code>@endif@~.
* When a Model object is provided, identifiers (values of type @c SId)
* from that model are used in preference to pre-defined MathML
* 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
* "<code>pi</code>", and the formula to be parsed is
* "<code>3*pi</code>", the MathML produced will contain the
* construct <code><ci> pi </ci></code> instead of the
* construct <code><pi/></code>.
* <li> Similarly, when a Model object is provided, @c 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
* "<code>sin</code>", that function will be used instead of the
* predefined MathML function <code><sin/></code>.
* </ul>
*
* To obtain the default configuration values, callers can use the function
* @if clike SBML_getDefaultL3ParserSettings()@endif@if csharp SBML_getDefaultL3ParserSettings()@endif@if python libsbml.SBML_getDefaultL3ParserSettings()@endif@if java <code><a href="libsbml.html#getDefaultL3ParserSettings()">libsbml.getDefaultL3ParserSettings()</a></code>@endif@~.
* To change the configuration, callers can create an L3ParserSettings
* object, set the desired characteristics using the methods
* provided, and pass that object to
* @if clike SBML_parseL3FormulaWithSettings()@endif@if csharp SBML_parseL3FormulaWithSettings()@endif@if python libsbml.parseL3FormulaWithSettings()@endif@if java <a href="libsbml.html#parseL3FormulaWithSettings(java.lang.String, org.sbml.libsbml.L3ParserSettings)"><code>libsbml.parseL3FormulaWithSettings(String formula, L3ParserSettings settings)</code></a>@endif@~.
*
* @if clike @see SBML_parseL3FormulaWithSettings()
* @see SBML_parseL3Formula()
* @see SBML_parseL3FormulaWithModel()
* @endif@~
* @if csharp @see SBML_parseL3FormulaWithSettings()
* @see SBML_parseL3Formula()
* @see SBML_parseL3FormulaWithModel()
* @endif@~
* @if python @see libsbml.parseL3FormulaWithSettings()
* @see libsbml.parseL3Formula()
* @see libsbml.parseL3FormulaWithModel()
* @endif@~
* @if java @see <code><a href="libsbml.html#parseL3FormulaWithSettings(java.lang.String, org.sbml.libsbml.L3ParserSettings)">libsbml.parseL3FormulaWithSettings(String formula, L3ParserSettings settings)</a></code>
* @see <code><a href="libsbml.html#parseL3Formula(java.lang.String)">libsbml.parseL3Formula(String formula)</a></code>
* @see <code><a href="libsbml.html#parseL3FormulaWithModel(java.lang.String, org.sbml.libsbml.Model)">parseL3FormulaWithModel(String formula, Model model)</a></code>
* @endif@~
*/
#ifndef L3ParserSettings_h
#define L3ParserSettings_h
#include <sbml/common/libsbml-namespace.h>
#include <sbml/common/extern.h>
#include <sbml/common/sbmlfwd.h>
/**
* @enum ParseLogType_t
* @brief Configuration values for handling @c log in formulas.
*
* The L3ParserSettings object can be used to modify the SBML L3 parser to translate the function <code>log(x)</code> three different ways, each settable with this type enum.
*
* @see L3ParserSettings
* @if clike @see SBML_parseL3FormulaWithSettings()
* @endif@~
* @if csharp @see SBML_parseL3FormulaWithSettings()
* @endif@~
* @if python @see libsbml.parseL3FormulaWithSettings()
* @endif@~
*/
typedef enum
{
L3P_PARSE_LOG_AS_LOG10 = 0,
/*!< Parse <code>log(x)</code> as the base-10 logarithm of @c x. */
L3P_PARSE_LOG_AS_LN = 1,
/*!< Parse <code>log(x)</code> as the natural logarithm of @c x. */
L3P_PARSE_LOG_AS_ERROR = 2
/*!< Refuse to parse <code>log(x)</code> at all, and set an error message
telling the user to use <code>log10(x)</code>, <code>ln(x)</code>,
or <code>log(base, x)</code> instead. */
} ParseLogType_t;
#define L3P_COLLAPSE_UNARY_MINUS true
/*!<
* Collapse unary minuses where possible.
* @see getParseCollapseMinus()
* @see setParseCollapseMinus()
*/
#define L3P_EXPAND_UNARY_MINUS false
/*!<
* Retain unary minuses in the AST representation.
* @see getParseCollapseMinus()
* @see setParseCollapseMinus()
*/
#define L3P_PARSE_UNITS true
/*!<
* Parse units in text-string formulas.
* @see setParseCollapseMinus()
* @see getParseCollapseMinus()
*/
#define L3P_NO_UNITS false
/*!<
* Do not recognize units in text-string formulas—treat them as errors.
* @see setParseCollapseMinus()
* @see getParseCollapseMinus()
*/
#define L3P_AVOGADRO_IS_CSYMBOL true
/*!<
* Recognize 'avogadro' as an SBML Level 3 symbol.
* @see getParseAvogadroCsymbol()
* @see setParseAvogadroCsymbol()
*/
#define L3P_AVOGADRO_IS_NAME false
/*!<
* Do not treat 'avogadro' specially—consider it a plain symbol name.
* @see getParseAvogadroCsymbol()
* @see setParseAvogadroCsymbol()
*/
#ifdef __cplusplus
LIBSBML_CPP_NAMESPACE_BEGIN
class Model;
class LIBSBML_EXTERN L3ParserSettings
{
private:
const Model* mModel;
ParseLogType_t mParselog;
bool mCollapseminus;
bool mParseunits;
bool mAvoCsymbol;
public:
/**
* Creates a new L3ParserSettings object with default values.
*
* This is the default constructor for the L3ParserSettings object. It
* sets the Model to @c NULL and other settings to @c
* L3P_PARSE_LOG_AS_LOG10, @c L3P_EXPAND_UNARY_MINUS, @c L3P_PARSE_UNITS,
* and @c L3P_AVOGADRO_IS_CSYMBOL.
*/
L3ParserSettings();
/**
* Creates a new L3ParserSettings object with specific values for all
* possible settings.
*
* @param model a Model object to be used for disambiguating identifiers
*
* @param parselog a flag that controls how the parser will handle
* the symbol @c log in formulas
*
* @param collapseminus a flag that controls how the parser will handle
* minus signs
*
* @param parseunits a flag that controls how the parser will handle
* apparent references to units of measurement associated with raw
* numbers in a formula
*
* @param avocsymbol a flag that controls how the parser will handle
* the appearance of the symbol @c avogadro in a formula
*
* @see getModel()
* @see setModel(@if java Model model@endif)
* @see unsetModel()
* @see getParseLog()
* @see setParseLog(@if java int type@endif)
* @see getParseUnits()
* @see setParseUnits(@if java boolean units@endif)
* @see getParseCollapseMinus()
* @see setParseCollapseMinus(@if java boolean collapseminus@endif)
* @see getParseAvogadroCsymbol()
* @see setParseAvogadroCsymbol(@if java boolean l2only@endif)
*/
L3ParserSettings(Model* model, ParseLogType_t parselog,
bool collapseminus, bool parseunits, bool avocsymbol);
/**
* Destroys this L3ParserSettings object.
*/
~L3ParserSettings();
/**
* Sets the model reference in this L3ParserSettings object.
*
* When a Model object is provided, identifiers (values of type @c SId)
* from that model are used in preference to pre-defined MathML
* 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
* "<code>pi</code>", and the formula to be parsed is
* "<code>3*pi</code>", the MathML produced will contain the
* construct <code><ci> pi </ci></code> instead of the
* construct <code><pi/></code>.
* Similarly, when a Model object is provided, @c 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
* "<code>sin</code>", that function will be used instead of the
* predefined MathML function <code><sin/></code>.
*
* @param model a Model object to be used for disambiguating identifiers
*
* @warning <span class="warning">This does @em not copy the Model object.
* This means that modifications made to the object after invoking this
* method may affect parsing behavior.</span>
*
* @see getModel()
* @see unsetModel()
*/
void setModel(const Model* model);
/**
* Returns the Model object referenced by this L3ParserSettings object.
*
* @see setModel(@if java Model model@endif)
* @see unsetModel()
*/
const Model* getModel() const;
/**
* Sets the Model reference in this L3ParserSettings object to @c NULL.
*
* @see setModel(@if java Model model@endif)
* @see getModel()
*/
void unsetModel();
/**
* Sets the behavior for handling @c log in mathematical formulas.
*
* The function @c log with a single argument
* ("<code>log(x)</code>") can be parsed as
* <code>log10(x)</code>, <code>ln(x)</code>, or treated as an error, as
* desired.
*
* @param type a constant, one of following three possibilities:
* @li @link ParseLogType_t#L3P_PARSE_LOG_AS_LOG10 L3P_PARSE_LOG_AS_LOG10@endlink
* @li @link ParseLogType_t#L3P_PARSE_LOG_AS_LN L3P_PARSE_LOG_AS_LN@endlink
* @li @link ParseLogType_t#L3P_PARSE_LOG_AS_ERROR L3P_PARSE_LOG_AS_ERROR@endlink
*
* @see getParseLog()
*/
void setParseLog(ParseLogType_t type);
/**
* Returns the current setting indicating what to do with formulas
* containing the function @c log with one argument.
*
* The function @c log with a single argument
* ("<code>log(x)</code>") can be parsed as
* <code>log10(x)</code>, <code>ln(x)</code>, or treated as an error, as
* desired.
*
* @return One of following three constants:
* @li @link ParseLogType_t#L3P_PARSE_LOG_AS_LOG10 L3P_PARSE_LOG_AS_LOG10@endlink
* @li @link ParseLogType_t#L3P_PARSE_LOG_AS_LN L3P_PARSE_LOG_AS_LN@endlink
* @li @link ParseLogType_t#L3P_PARSE_LOG_AS_ERROR L3P_PARSE_LOG_AS_ERROR@endlink
*
* @see setParseLog(@if java int type@endif)
*/
ParseLogType_t getParseLog() const;
/**
* 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., "<code>- -3</code>") 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 "<code>- 4.1</code>" can
* be turned into a single ASTNode of type @link ASTNodeType_t#AST_REAL
* AST_REAL@endlink with a value of <code>-4.1</code>, or it can be
* turned into a node of type @link ASTNodeType_t#AST_MINUS
* AST_MINUS@endlink having a child node of type @link
* ASTNodeType_t#AST_REAL AST_REAL@endlink. 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:
*
* @li @link ParseLogType_t#L3P_COLLAPSE_UNARY_MINUS
* L3P_COLLAPSE_UNARY_MINUS@endlink (value = @c true): collapse unary
* minuses where possible.
* @li @link ParseLogType_t#L3P_EXPAND_UNARY_MINUS
* L3P_EXPAND_UNARY_MINUS@endlink (value = @c false): do not collapse
* unary minuses, and instead translate each one into an AST node of type
* @link ASTNodeType_t#AST_MINUS AST_MINUS@endlink.
*
* @param collapseminus a boolean value (one of the constants
* @link ParseLogType_t#L3P_COLLAPSE_UNARY_MINUS
* L3P_COLLAPSE_UNARY_MINUS@endlink or
* @link ParseLogType_t#L3P_EXPAND_UNARY_MINUS
* L3P_EXPAND_UNARY_MINUS@endlink) indicating how unary minus signs in
* the input should be handled.
*
* @see getParseCollapseMinus()
*/
void setParseCollapseMinus(bool collapseminus);
/**
* Returns a flag indicating 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., "<code>- -3</code>") 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 "<code>- 4.1</code>" can
* be turned into a single ASTNode of type @link ASTNodeType_t#AST_REAL
* AST_REAL@endlink with a value of <code>-4.1</code>, or it can be
* turned into a node of type @link ASTNodeType_t#AST_MINUS
* AST_MINUS@endlink having a child node of type @link
* ASTNodeType_t#AST_REAL AST_REAL@endlink. 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:
*
* @li @link ParseLogType_t#L3P_COLLAPSE_UNARY_MINUS
* L3P_COLLAPSE_UNARY_MINUS@endlink (value = @c true): collapse unary
* minuses where possible.
* @li @link ParseLogType_t#L3P_EXPAND_UNARY_MINUS
* L3P_EXPAND_UNARY_MINUS@endlink (value = @c false): do not collapse
* unary minuses, and instead translate each one into an AST node of type
* @link ASTNodeType_t#AST_MINUS AST_MINUS@endlink.
*
* @return A boolean, one of @link
* ParseLogType_t#L3P_COLLAPSE_UNARY_MINUS
* L3P_COLLAPSE_UNARY_MINUS@endlink or @link
* ParseLogType_t#L3P_EXPAND_UNARY_MINUS L3P_EXPAND_UNARY_MINUS@endlink.
*
* @see setParseCollapseMinus(@if java boolean collapseminus@endif)
*/
bool getParseCollapseMinus() const;
/**
* Sets the parser's behavior in handling units associated with numbers
* in a mathematical formula.
*
* In SBML Level 2, there is no means of associating a unit of
* measurement with a pure number in a formula, while SBML Level 3
* does define a syntax for this. In Level 3, MathML
* <code><cn></code> elements can have an attribute named @c units
* placed in the SBML namespace, which can be used to indicate the units
* to be associated with the number. The text-string infix formula
* parser allows units to be placed after raw numbers; they are
* interpreted as unit identifiers for units defined by the SBML
* specification or in the containing Model object. Some examples
* include: "<code>4 mL</code>", "<code>2.01
* Hz</code>", "<code>3.1e-6 M</code>", and
* "<code>(5/8) inches</code>". To produce a valid SBML model,
* there must either exist a UnitDefinition corresponding to the
* identifier of the unit, or the unit must be defined in Table 2 of
* the SBML specification.
*
* @param units A boolean indicating whether to parse units:
* @li @link ParseLogType_t#L3P_PARSE_UNITS L3P_PARSE_UNITS@endlink
* (value = @c true): parse units in the text-string formula.
* @li @link ParseLogType_t#L3P_NO_UNITS L3P_NO_UNITS@endlink (value = @c
* false): treat units in the text-string formula as errors.
*
* @see getParseUnits()
*/
void setParseUnits(bool units);
/**
* Returns @c if the current settings allow units in text-string
* mathematical formulas.
*
* In SBML Level 2, there is no means of associating a unit of
* measurement with a pure number in a formula, while SBML Level 3
* does define a syntax for this. In Level 3, MathML
* <code><cn></code> elements can have an attribute named @c units
* placed in the SBML namespace, which can be used to indicate the units
* to be associated with the number. The text-string infix formula
* parser allows units to be placed after raw numbers; they are
* interpreted as unit identifiers for units defined by the SBML
* specification or in the containing Model object. Some examples
* include: "<code>4 mL</code>", "<code>2.01
* Hz</code>", "<code>3.1e-6 M</code>", and
* "<code>(5/8) inches</code>". To produce a valid SBML model,
* there must either exist a UnitDefinition corresponding to the
* identifier of the unit, or the unit must be defined in Table 2 of
* the SBML specification.
*
* Since SBML Level 2 does not have the ability to associate units with
* pure numbers, the value should be set to @c false when parsing text-string
* formulas intended for use in SBML Level 2 documents.
*
* @return A boolean indicating whether to parse units:
* @li @link ParseLogType_t#L3P_PARSE_UNITS L3P_PARSE_UNITS@endlink
* (value = @c true): parse units in the text-string formula.
* @li @link ParseLogType_t#L3P_NO_UNITS L3P_NO_UNITS@endlink (value = @c
* false): treat units in the text-string formula as errors.
*
* @see setParseUnits(@if java boolean units@endif)
*/
bool getParseUnits() const;
/**
* Sets the parser's behavior in handling the string @c avogadro in
* mathematical formulas.
*
* SBML Level 3 defines a symbol for representing the value of
* Avogadro's constant, but it is not defined in SBML Level 2. As a
* result, the text-string formula parser must behave differently
* depending on which SBML Level is being targeted. The argument to this
* method can be one of two values:
*
* @li @link ParseLogType_t#L3P_AVOGADRO_IS_CSYMBOL
* L3P_AVOGADRO_IS_CSYMBOL@endlink (value = @c true): tells the parser to
* translate the string @c avogadro (in any capitalization) into an AST
* node of type @link ASTNodeType_t#AST_NAME_AVOGADRO
* AST_NAME_AVOGADRO@endlink.
* @li @link ParseLogType_t#L3P_AVOGADRO_IS_NAME
* L3P_AVOGADRO_IS_NAME@endlink (value = @c false): tells the parser to
* translate the string @c avogadro into an AST of type @link
* ASTNodeType_t#AST_NAME AST_NAME@endlink.
*
* Since SBML Level 2 does not define a symbol for Avogadro's
* constant, the value should be set to @c false when parsing text-string
* formulas intended for use in SBML Level 2 documents.
*
* @param l2only a boolean value (one of the constants
* @link ParseLogType_t#L3P_AVOGADRO_IS_CSYMBOL
* L3P_AVOGADRO_IS_CSYMBOL@endlink or
* @link ParseLogType_t#L3P_AVOGADRO_IS_NAME
* L3P_AVOGADRO_IS_NAME@endlink) indicating how the string @c avogadro
* should be treated when encountered in a formula.
*
* @see getParseAvogadroCsymbol()
*/
void setParseAvogadroCsymbol(bool l2only);
/**
* Returns @c true if the current settings are oriented towards handling
* @c avogadro for SBML Level 3.
*
* SBML Level 3 defines a symbol for representing the value of
* Avogadro's constant, but it is not defined in SBML Level 2. As a
* result, the text-string formula parser must behave differently
* depending on which SBML Level is being targeted.
*
* @return A boolean indicating which mode is currently set; the value is
* one of the following possibilities:
* @li @link ParseLogType_t#L3P_AVOGADRO_IS_CSYMBOL
* L3P_AVOGADRO_IS_CSYMBOL@endlink (value = @c true): tells the parser to
* translate the string @c avogadro (in any capitalization) into an AST
* node of type @link ASTNodeType_t#AST_NAME_AVOGADRO
* AST_NAME_AVOGADRO@endlink.
* @li @link ParseLogType_t#L3P_AVOGADRO_IS_NAME
* L3P_AVOGADRO_IS_NAME@endlink (value = @c false): tells the parser to
* translate the string @c avogadro into an AST of type @link
* ASTNodeType_t#AST_NAME AST_NAME@endlink.
*
* @see setParseAvogadroCsymbol(@if java boolean l2only@endif)
*/
bool getParseAvogadroCsymbol() const;
};
LIBSBML_CPP_NAMESPACE_END
#endif /* __cplusplus */
#ifndef SWIG
LIBSBML_CPP_NAMESPACE_BEGIN
BEGIN_C_DECLS
/**
* Creates a new L3ParserSettings_t structure and returns a pointer to it
*
* @note This functions sets the Model* to NULL, and other settings to
* L3P_PARSE_LOG_AS_LOG10, L3P_EXPAND_UNARY_MINUS, L3P_PARSE_UNITS,
* and L3P_AVOGADRO_IS_CSYMBOL.
*
* @return a pointer to the newly created L3ParserSettings_t structure.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
L3ParserSettings_t *
L3ParserSettings_create ();
/**
* Frees the given L3ParserSettings_t structure.
*
* @param settings the L3ParserSettings_t to free
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
void
L3ParserSettings_free (L3ParserSettings_t * settings);
/**
* Sets the model associated with this L3ParserSettings_t structure
* to the provided pointer.
*
* @note A copy of the Model_t is not made, so modifications to the Model_t itself
* may affect future parsing.
*
* @param settings the L3ParserSettings_t structure on which to set the Model_t.
* @param model The Model_t structure to which infix strings are to be compared.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
void
L3ParserSettings_setModel (L3ParserSettings_t * settings, const Model_t * model);
/**
* Retrieves the model associated with this L3ParserSettings_t structure.
*
* @param settings the L3ParserSettings_t structure from which to get the Model_t.
*
* @return the Model_t structure associated with this L3ParserSettings_t structure.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
const Model_t *
L3ParserSettings_getModel (const L3ParserSettings_t * settings);
/**
* Unsets the model associated with this L3ParserSettings_t structure.
*
* @param settings the L3ParserSettings_t structure on which to unset the Model_t.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
void
L3ParserSettings_unsetModel (L3ParserSettings_t * settings);
/**
* Sets the log parsing option associated with this L3ParserSettings_t structure.
*
* This option allows the user to specify how the infix expression 'log(x)'
* is parsed in a MathML ASTNode. The options are:
* @li L3P_PARSE_LOG_AS_LOG10 (0)
* @li L3P_PARSE_LOG_AS_LN (1)
* @li L3P_PARSE_LOG_AS_ERROR (2)
*
* @param settings the L3ParserSettings_t structure on which to set the option.
* @param type ParseLogType_t log parsing option to associate with this
* L3ParserSettings_t structure.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
void
L3ParserSettings_setParseLog (L3ParserSettings_t * settings, ParseLogType_t type);
/**
* Retrieves the log parsing option associated with this L3ParserSettings_t structure.
*
* This option allows the user to specify how the infix expression 'log(x)'
* is parsed in a MathML ASTNode. The options are:
* @li L3P_PARSE_LOG_AS_LOG10 (0)
* @li L3P_PARSE_LOG_AS_LN (1)
* @li L3P_PARSE_LOG_AS_ERROR (2)
*
* @param settings the L3ParserSettings_t structure on which to set the Model_t.
*
* @return ParseLogType_t log parsing option to associate with this
* L3ParserSettings_t structure. Returns L3P_PARSE_LOG_AS_LOG10 (0) if @param settings
* is NULL.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
ParseLogType_t
L3ParserSettings_getParseLog (const L3ParserSettings_t * settings);
/**
* Sets the collapse minus option associated with this L3ParserSettings_t structure.
*
* This option allows the user to specify how the infix expression '-4'
* is parsed in a MathML ASTNode.
*
* @param settings the L3ParserSettings_t structure on which to set the option.
* @param flag an integer indicating whether unary minus should be collapsed
* (non-zero) or not (zero).
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
void
L3ParserSettings_setParseCollapseMinus (L3ParserSettings_t * settings, int flag);
/**
* Retrieves the collapse minus option associated with this L3ParserSettings_t structure.
*
* This option allows the user to specify how the infix expression '-4'
* is parsed in a MathML ASTNode.
*
* @param settings the L3ParserSettings_t structure from which to get the option.
*
* @return an integer indicating whether unary minus should be collapsed
* (non-zero) or not (zero). Returns zero (0) if @param settings
* is NULL.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
int
L3ParserSettings_getParseCollapseMinus (const L3ParserSettings_t * settings);
/**
* Sets the units option associated with this L3ParserSettings_t structure.
*
* @param settings the L3ParserSettings_t structure on which to set the option.
* @param flag an integer indicating whether numbers should be considered as
* a having units (non-zero) or not (zero).
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
void
L3ParserSettings_setParseUnits (L3ParserSettings_t * settings, int flag);
/**
* Retrieves the units option associated with this L3ParserSettings_t structure.
*
* @param settings the L3ParserSettings_t structure from which to get the option.
*
* @return an integer indicating whether numbers should be considered as
* a having units (non-zero) or not (zero). Returns zero (0) if @param settings
* is NULL.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
int
L3ParserSettings_getParseUnits (const L3ParserSettings_t * settings);
/**
* Sets the avogadro csymbol option associated with this L3ParserSettings_t structure.
*
* @param settings the L3ParserSettings_t structure on which to set the option.
* @param flag an integer indicating whether avogadro should be considered as
* a csymbol (non-zero) or not (zero).
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
void
L3ParserSettings_setParseAvogadroCsymbol (L3ParserSettings_t * settings, int flag);
/**
* Retrieves the avogadro csymbol option associated with this L3ParserSettings_t structure.
*
* @param settings the L3ParserSettings_t structure from which to get the option.
*
* @return an integer indicating whether avogadro should be considered as
* a csymbol (non-zero) or not (zero). Returns zero (0) if @param settings
* is NULL.
*
* @memberof L3ParserSettings_t
*/
LIBSBML_EXTERN
int
L3ParserSettings_getParseAvogadroCsymbol (const L3ParserSettings_t * settings);
END_C_DECLS
LIBSBML_CPP_NAMESPACE_END
#endif
#endif /* L3ParserSettings_h */
|