--------------------------------------------------------------------------- \brief Add a function or operator callback to the parser. */
| 367 | //--------------------------------------------------------------------------- |
| 368 | /** \brief Add a function or operator callback to the parser. */ |
| 369 | void ParserBase::AddCallback( |
| 370 | const string_type& a_strName, |
| 371 | const ParserCallback& a_Callback, |
| 372 | funmap_type& a_Storage, |
| 373 | const char_type* a_szCharSet) |
| 374 | { |
| 375 | if (!a_Callback.IsValid()) |
| 376 | Error(ecINVALID_FUN_PTR); |
| 377 | |
| 378 | const funmap_type* pFunMap = &a_Storage; |
| 379 | |
| 380 | // Check for conflicting operator or function names |
| 381 | if (pFunMap != &m_FunDef && m_FunDef.find(a_strName) != m_FunDef.end()) |
| 382 | Error(ecNAME_CONFLICT, -1, a_strName); |
| 383 | |
| 384 | if (pFunMap != &m_PostOprtDef && m_PostOprtDef.find(a_strName) != m_PostOprtDef.end()) |
| 385 | Error(ecNAME_CONFLICT, -1, a_strName); |
| 386 | |
| 387 | if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && m_InfixOprtDef.find(a_strName) != m_InfixOprtDef.end()) |
| 388 | Error(ecNAME_CONFLICT, -1, a_strName); |
| 389 | |
| 390 | if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && m_OprtDef.find(a_strName) != m_OprtDef.end()) |
| 391 | Error(ecNAME_CONFLICT, -1, a_strName); |
| 392 | |
| 393 | CheckOprt(a_strName, a_Callback, a_szCharSet); |
| 394 | a_Storage[a_strName] = a_Callback; |
| 395 | ReInit(); |
| 396 | } |
| 397 | |
| 398 | //--------------------------------------------------------------------------- |
| 399 | /** \brief Check if a name contains invalid characters. |