+++ /dev/null
-/*\r
- __________ \r
- _____ __ __\______ \_____ _______ ______ ____ _______ \r
- / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \\r
- | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/\r
- |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| \r
- \/ \/ \/ \/ \r
- Copyright (C) 2004-2011 Ingo Berg\r
-\r
- Permission is hereby granted, free of charge, to any person obtaining a copy of this \r
- software and associated documentation files (the "Software"), to deal in the Software\r
- without restriction, including without limitation the rights to use, copy, modify, \r
- merge, publish, distribute, sublicense, and/or sell copies of the Software, and to \r
- permit persons to whom the Software is furnished to do so, subject to the following conditions:\r
-\r
- The above copyright notice and this permission notice shall be included in all copies or \r
- substantial portions of the Software.\r
-\r
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT\r
- NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND \r
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, \r
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \r
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \r
-*/\r
-\r
-#ifndef MU_PARSER_STACK_H\r
-#define MU_PARSER_STACK_H\r
-\r
-#include <cassert>\r
-#include <string>\r
-#include <stack>\r
-#include <vector>\r
-\r
-#include "muParserError.h"\r
-#include "muParserToken.h"\r
-\r
-/** \file \r
- \brief This file defines the stack used by muparser.\r
-*/\r
-\r
-namespace mu\r
-{\r
-\r
- /** \brief Parser stack implementation. \r
-\r
- Stack implementation based on a std::stack. The behaviour of pop() had been\r
- slightly changed in order to get an error code if the stack is empty.\r
- The stack is used within the Parser both as a value stack and as an operator stack.\r
-\r
- \author (C) 2004-2011 Ingo Berg \r
- */\r
- template <typename TValueType>\r
- class ParserStack \r
- {\r
- private:\r
-\r
- /** \brief Type of the underlying stack implementation. */\r
- typedef std::stack<TValueType, std::vector<TValueType> > impl_type;\r
- \r
- impl_type m_Stack; ///< This is the actual stack.\r
-\r
- public: \r
- \r
- //---------------------------------------------------------------------------\r
- ParserStack()\r
- :m_Stack()\r
- {}\r
-\r
- //---------------------------------------------------------------------------\r
- virtual ~ParserStack()\r
- {}\r
-\r
- //---------------------------------------------------------------------------\r
- /** \brief Pop a value from the stack.\r
- \r
- Unlike the standard implementation this function will return the value that\r
- is going to be taken from the stack.\r
-\r
- \throw ParserException in case the stack is empty.\r
- \sa pop(int &a_iErrc)\r
- */\r
- TValueType pop()\r
- {\r
- if (empty())\r
- throw ParserError( _T("stack is empty.") );\r
-\r
- TValueType el = top();\r
- m_Stack.pop();\r
- return el;\r
- }\r
-\r
- /** \brief Push an object into the stack. \r
-\r
- \param a_Val object to push into the stack.\r
- \throw nothrow\r
- */\r
- void push(const TValueType& a_Val) \r
- { \r
- m_Stack.push(a_Val); \r
- }\r
-\r
- /** \brief Return the number of stored elements. */\r
- unsigned size() const\r
- { \r
- return (unsigned)m_Stack.size(); \r
- }\r
-\r
- /** \brief Returns true if stack is empty false otherwise. */\r
- bool empty() const\r
- {\r
- return m_Stack.empty(); \r
- }\r
- \r
- /** \brief Return reference to the top object in the stack. \r
- \r
- The top object is the one pushed most recently.\r
- */\r
- TValueType& top() \r
- { \r
- return m_Stack.top(); \r
- }\r
- };\r
-} // namespace MathUtils\r
-\r
-#endif\r