L3ParserSettings(L3ParserSettings source) : this(libsbmlPINVOKE.new_L3ParserSettings__SWIG_4(L3ParserSettings.getCPtr(source)), true) { if (libsbmlPINVOKE.SWIGPendingException.Pending) { throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); } }
internal static HandleRef getCPtrAndDisown(L3ParserSettings obj) { HandleRef ptr = new HandleRef(null, IntPtr.Zero); if (obj != null) { ptr = obj.swigCPtr; obj.swigCMemOwn = false; } return(ptr); }
internal static HandleRef getCPtr(L3ParserSettings obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
/** * Parses a text string as a mathematical formula using specific parser * settings and returns an AST representation of the result. * * This is identical to @sbmlfunction{parseL3Formula, String}, except * that this function uses the parser settings given in the argument @p * settings. The settings override the default parsing behavior. The * following parsing behaviors can be configured: * * * * @li A Model object may optionally be provided to use identifiers (values * of type @c SId) from the model in preference to pre-defined MathML symbols * 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 by the parser will * contain the construct <code><ci> pi </ci></code> instead of * the construct <code><pi/></code>. Another 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>. * @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 either collapsed or preserved; that is, the * parser can either (1) remove sequential pairs of unary minuses (e.g., * "<code>- -3</code>") from the input and incorporate single unary * minuses into the number node, or (2) preserve all minuses in the AST node * structure, turning them into ASTNode objects of type * @link libsbmlcs#AST_MINUS AST_MINUS@endlink. * @li The character sequence "<code>number id</code>" can be * interpreted as a numerical value @c number followed by units of measurement * indicated by @c id, or it can be treated as a syntax error. (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.) * @li The symbol @c avogadro can be parsed either as a MathML @em csymbol or * as a identifier. More specifically, "<code>avogadro</code>" can * be treated as an ASTNode of type * @link libsbmlcs#AST_NAME_AVOGADRO AST_NAME_AVOGADRO@endlink or of type * @link libsbmlcs#AST_NAME AST_NAME@endlink. * @li Strings that match built-in functions and constants can either be parsed * as a match regardless of capitalization, or may be required to be * all-lower-case to be considered a match. * @li LibSBML plug-ins implementing support for SBML Level 3 packages * may introduce extensions to the syntax understood by the parser. The * precise nature of the extensions will be documented by the individual * package plug-ins. An example of a possible extension is a notation for * vectors and arrays, introduced by the SBML Level 3 @em Arrays * package. * * * * For more details about the parser, please see the definition of * L3ParserSettings and @sbmlfunction{parseL3FormulaWithSettings, String\, * L3ParserSettings}. * * @param formula the mathematical formula expression to be parsed * * @param settings the settings to be used for this parser invocation * * @return the root node of an AST representing the mathematical formula, * or @c null if an error occurred while parsing the formula. When @c null * is returned, an error is recorded internally; information about the * error can be retrieved using @sbmlfunction{getLastParseL3Error,}. * * @see @sbmlfunction{parseL3Formula, String} * @see @sbmlfunction{parseL3FormulaWithSettings, String\, L3ParserSettings} * @see @sbmlfunction{parseL3FormulaWithModel, String\, Model} * @see @sbmlfunction{parseFormula, String} * @see @sbmlfunction{getLastParseL3Error,} * @see L3ParserSettings * * @if conly * @memberof ASTNode_t * @endif */ public static ASTNode parseL3FormulaWithSettings(string formula, L3ParserSettings settings) { IntPtr cPtr = libsbmlPINVOKE.parseL3FormulaWithSettings(formula, L3ParserSettings.getCPtr(settings)); ASTNode ret = (cPtr == IntPtr.Zero) ? null : new ASTNode(cPtr, true); return ret; }
/** * Converts an AST to a text string representation of a formula, using * specific formatter settings. * * This function behaves identically to @sbmlfunction{formulaToL3String, * ASTNode} but its behavior is controlled by two fields in the @p * settings object, namely: * * @li <em>parseunits</em> ('parse units'): If this field in the @p settings * object is set to <code>true</code> (the default), the function will * write out the units of any numerical ASTNodes that have them, * producing (for example) "<code>3 mL</code>", * "<code>(3/4) m</code>", or "<code>5.5e-10 * M</code>". If this is set to <code>false</code>, this function * will only write out the number itself ("<code>3</code>", * "<code>(3/4)</code>", and "<code>5.5e-10</code>", * in the previous examples). * @li <em>collapseminus</em> ('collapse minus'): If this field in the @p * settings object is set to <code>false</code> (the default), the * function will write out explicitly any doubly-nested unary minus * ASTNodes, producing (for example) "<code>- -x</code>" or * even "<code>- - - - -3.1</code>". If this is set to * <code>true</code>, the function will collapse the nodes before * producing the infix form, producing "<code>x</code>" and * "<code>-3.1</code>" in the previous examples. * * All the other settings of the L3ParserSettings object passed in as @p * settings will be ignored for the purposes of this function: the * <em>parselog</em> ('parse log') setting is ignored so that * "<code>log10(x)</code>", "<code>ln(x)</code>", and * "<code>log(x, y)</code>" are always produced; the * <em>avocsymbol</em> ('Avogadro csymbol') is irrelevant to the behavior * of this function; and nothing in the Model object set via the * <em>model</em> setting is used. * * @param tree the AST to be converted. * @param settings the L3ParserSettings object used to modify the behavior of * this function. * * @return the formula from the given AST as text string, with a syntax * oriented towards the capabilities defined in SBML Level 3. The * caller owns the returned string and is responsible for freeing it when it * is no longer needed. If @p tree is a null pointer, then a null pointer is * returned. * * @see @sbmlfunction{formulaToL3String, ASTNode} * @see @sbmlfunction{formulaToString, ASTNode} * @see @sbmlfunction{parseL3FormulaWithSettings, String\, L3ParserSettings} * @see @sbmlfunction{parseL3FormulaWithModel, String\, Model} * @see @sbmlfunction{parseFormula, String} * @see L3ParserSettings * @see @sbmlfunction{getDefaultL3ParserSettings,} * @see @sbmlfunction{getLastParseL3Error,} * * @if conly * @memberof ASTNode_t * @endif */ public static string formulaToL3StringWithSettings(ASTNode tree, L3ParserSettings settings) { string ret = libsbmlPINVOKE.formulaToL3StringWithSettings(ASTNode.getCPtr(tree), L3ParserSettings.getCPtr(settings)); return ret; }
internal static HandleRef getCPtrAndDisown(L3ParserSettings obj) { HandleRef ptr = new HandleRef(null, IntPtr.Zero); if (obj != null) { ptr = obj.swigCPtr; obj.swigCMemOwn = false; } return ptr; }
internal static HandleRef getCPtr(L3ParserSettings obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
/** * Copy constructor. */ public L3ParserSettings(L3ParserSettings source) : this(libsbmlPINVOKE.new_L3ParserSettings__SWIG_4(L3ParserSettings.getCPtr(source)), true) { if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); }