USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::CubeInfixToPostfix Class Reference
[Math]

#include <CubeInfixToPostfix.h>

Inheritance diagram for Isis::CubeInfixToPostfix:

Inheritance graph
[legend]
Collaboration diagram for Isis::CubeInfixToPostfix:

Collaboration graph
[legend]
List of all members.

Detailed Description

Converter for math equations.

This class converts infix equations to postfix

Author:
2007-08-21 Steven Lambright

For internal use only.

Definition at line 44 of file CubeInfixToPostfix.h.

Public Member Functions

 CubeInfixToPostfix ()
 ~CubeInfixToPostfix ()
iString Convert (const iString &infix)
 This method converts infix to postfix.
iString TokenizeEquation (const iString &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 (iString representation)
 This method will return true if it believes the argument represents a valid function or operator.
InfixOperatorFindOperator (iString representation)
 This method will return a pointer to the operator represented by 'representation.

Protected Attributes

QList< InfixOperator * > p_operators


Member Function Documentation

iString Isis::InfixToPostfix::Convert ( const iString 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:
infix The infix equation
Returns:
iString The postfix equation

Definition at line 144 of file InfixToPostfix.cpp.

References _FILEINFO_, Isis::InfixToPostfix::AddOperator(), Isis::InfixToPostfix::CleanSpaces(), Isis::iException::Clear(), Isis::InfixToPostfix::CloseParenthesis(), e, Isis::InfixToPostfix::FindOperator(), Isis::InfixToPostfix::IsFunction(), Isis::InfixToPostfix::IsKnownSymbol(), Isis::iException::Message(), Isis::iString::Remove(), Isis::iString::Token(), and Isis::InfixToPostfix::TokenizeEquation().

InfixOperator * Isis::CubeInfixToPostfix::FindOperator ( iString  representation  )  [protected, virtual]

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:
representation The 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.

Definition at line 58 of file CubeInfixToPostfix.cpp.

References _FILEINFO_, e, Isis::InfixToPostfix::FindOperator(), Isis::iException::Message(), and Isis::InfixToPostfix::p_operators.

bool Isis::CubeInfixToPostfix::IsKnownSymbol ( iString  representation  )  [protected, virtual]

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

Parameters:
representation The 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.

Definition at line 38 of file CubeInfixToPostfix.cpp.

References Isis::InfixToPostfix::p_operators.

iString Isis::InfixToPostfix::TokenizeEquation ( const iString 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:
equation An unformatted infix equation
Returns:
iString A tokenized equation with additional parentheses

Definition at line 369 of file InfixToPostfix.cpp.

References Isis::InfixToPostfix::CleanSpaces(), Isis::iString::DownCase(), and Isis::InfixToPostfix::FormatFunctionCalls().

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


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