--------------------------------------------------------------------------- \brief Add a user defined variable. \param [in] a_sName the variable name \param [in] a_pVar A pointer to the variable value. \post Will reset the Parser to string parsing mode. \throw ParserException in case the name contains invalid signs or a_pVar is nullptr. */
| 615 | \throw ParserException in case the name contains invalid signs or a_pVar is nullptr. |
| 616 | */ |
| 617 | void ParserBase::DefineVar(const string_type& a_sName, value_type* a_pVar) |
| 618 | { |
| 619 | if (a_pVar == 0) |
| 620 | Error(ecINVALID_VAR_PTR); |
| 621 | |
| 622 | if (a_sName.length() > MaxLenIdentifier) |
| 623 | Error(ecIDENTIFIER_TOO_LONG); |
| 624 | |
| 625 | // Test if a constant with that names already exists |
| 626 | if (m_ConstDef.find(a_sName) != m_ConstDef.end()) |
| 627 | Error(ecNAME_CONFLICT); |
| 628 | |
| 629 | CheckName(a_sName, ValidNameChars()); |
| 630 | m_VarDef[a_sName] = a_pVar; |
| 631 | ReInit(); |
| 632 | } |
| 633 | |
| 634 | //--------------------------------------------------------------------------- |
| 635 | /** \brief Add a user defined constant. |
no test coverage detected