23 #ifndef INFIXTOPOSTFIX_H_
24 #define INFIXTOPOSTFIX_H_
64 QString
convert(
const QString &infix);
81 void closeParenthesis(QString &postfix, std::stack<InfixOperator> &theStack);
84 void checkArgument(QString funcName,
int argNum, QString argument);
96 InfixOperator(
int prec, QString inString,
bool isFunc =
false) {
98 m_inputString = inString;
99 m_outputString = inString;
100 m_isFunction = isFunc;
104 bool isFunc =
false) {
106 m_inputString = inString;
107 m_outputString = outString;
108 m_isFunction = isFunc;
111 const QString &inputString()
const {
112 return m_inputString;
115 const QString &outputString()
const {
116 return m_outputString;
119 int precedence()
const {
123 bool isFunction()
const {
130 QString m_inputString;
131 QString m_outputString;
147 m_numArguments = argCount;
150 InfixFunction(QString inString, QString outString,
int argCount) :
152 m_numArguments = argCount;
155 int argumentCount()
const {
156 return m_numArguments;
QString formatFunctionCalls(QString equation)
This method looks through equation for function calls, parenthesizes them, and calls itself again wit...
QString tokenizeEquation(const QString &equation)
This method will add spaces between all operators and numbers, making it possible to get each element...
bool isFunction(QString representation)
This method will return true if 'representation' is a known function.
QString convert(const QString &infix)
This method converts infix to postfix.
virtual InfixOperator * findOperator(QString representation)
This method will return a pointer to the operator represented by 'representation. ...
InfixOperator and InfixFunction are helper classes for InfixToPostfix.
InfixOperator and InfixFunction are helper classes for InfixToPostfix.
void uninitialize()
This cleans the known operators/functions list.
void addOperator(QString &postfix, const InfixOperator &op, std::stack< InfixOperator > &theStack)
This is straight from the algorithm found on page 159 of "Data Structures & Algorithms in Java" Secon...
Converter for math equations.
void closeParenthesis(QString &postfix, std::stack< InfixOperator > &theStack)
This is straight from the algorithm found on page 159 of "Data Structures & Algorithms in Java" Secon...
InfixToPostfix()
Constructor.
void initialize()
This populates the known operators/functions list.
QString cleanSpaces(QString equation)
This function takes a space-delimited string and removes empty delimiters.
virtual bool isKnownSymbol(QString representation)
This method will return true if it believes the argument represents a valid function or operator...