Isis Developer Reference
Isis::CubeInfixToPostfix Class Reference

Converter for math equations. More...

#include <CubeInfixToPostfix.h>

Inheritance diagram for Isis::CubeInfixToPostfix:
Inheritance graph
Collaboration diagram for Isis::CubeInfixToPostfix:
Collaboration graph

Public Member Functions

 CubeInfixToPostfix ()
 Constructs a CubeInfixToPostfix converter.
 
 ~CubeInfixToPostfix ()
 
QString convert (const QString &infix)
 This method converts infix to postfix.
 
QString tokenizeEquation (const QString &equation)
 This method will add spaces between all operators and numbers, making it possible to get each element of the equation one by one.
 

Protected Member Functions

bool isKnownSymbol (QString representation)
 This method will return true if it believes the argument represents a valid function or operator.
 
InfixOperatorfindOperator (QString representation)
 This method will return a pointer to the operator represented by 'representation.
 

Protected Attributes

QList< InfixOperator * > p_operators
 

Detailed Description

Converter for math equations.

This class converts infix equations to postfix

Author
2007-08-21 Steven Lambright

Constructor & Destructor Documentation

◆ CubeInfixToPostfix()

Isis::CubeInfixToPostfix::CubeInfixToPostfix ( )

Constructs a CubeInfixToPostfix converter.

Author
janderson (2/2/2012)

◆ ~CubeInfixToPostfix()

Isis::CubeInfixToPostfix::~CubeInfixToPostfix ( )
inline

Member Function Documentation

◆ convert()

QString Isis::InfixToPostfix::convert ( const QString & infix)
inherited

This method converts infix to postfix.

It uses an enhanced verion of the algorithm found on page 159 of "Data Structures & Algorithms in Java" Second Edition by Robert Lafore. First, we prep the equation with TokenizeEquation and then parse through it using the known-good algorithm.

Parameters
infixThe infix equation
Returns
IString The postfix equation

References _FILEINFO_, Isis::InfixToPostfix::findOperator(), Isis::InfixToPostfix::isKnownSymbol(), Isis::toDouble(), Isis::IString::Token(), Isis::InfixToPostfix::tokenizeEquation(), Isis::IString::ToQt(), and Isis::IException::User.

Referenced by Isis::InlineCalculator::toPostfix().

◆ findOperator()

InfixOperator * Isis::CubeInfixToPostfix::findOperator ( QString representation)
protectedvirtual

This method will return a pointer to the operator represented by 'representation.

' Because in this model a function is an operator, this will return a pointer to functions as well (in a base class pointer).

Parameters
representationThe symbolic representation of the operator, such as '+'
Returns
InfixOperator* A pointer to the operator object that contains known information about the operator

Reimplemented from Isis::InfixToPostfix.

References _FILEINFO_, Isis::InfixToPostfix::findOperator(), Isis::InfixToPostfix::p_operators, and Isis::IException::User.

◆ isKnownSymbol()

bool Isis::CubeInfixToPostfix::isKnownSymbol ( QString representation)
protectedvirtual

This method will return true if it believes the argument represents a valid function or operator.

Parameters
representationThe symbolic representation of the operator, such as 'sin'
Returns
bool True if it looks valid, false if it's not known

Reimplemented from Isis::InfixToPostfix.

References Isis::InfixToPostfix::p_operators.

◆ tokenizeEquation()

QString Isis::InfixToPostfix::tokenizeEquation ( const QString & equation)
inherited

This method will add spaces between all operators and numbers, making it possible to get each element of the equation one by one.

It will also parse out the function calls, adding parenthesis where needed so the user doesn't have to. The result is an equation ready for parsing (but NOT fully parenthesized, just enough to make sure our algorithm makes no mistakes).

Parameters
equationAn unformatted infix equation
Returns
IString A tokenized equation with additional parentheses

Referenced by Isis::InfixToPostfix::convert().

Member Data Documentation

◆ p_operators

QList<InfixOperator *> Isis::InfixToPostfix::p_operators
protectedinherited

The documentation for this class was generated from the following files: