Isis 3 Programmer Reference
CubeInfixToPostfix.cpp
Go to the documentation of this file.
1 
23 #include "CubeInfixToPostfix.h"
24 #include "IException.h"
25 
26 using namespace std;
27 
28 namespace Isis {
34  CubeInfixToPostfix::CubeInfixToPostfix() {
35  initialize();
36  }
37 
45  void CubeInfixToPostfix::initialize() {
46  // List of the form funct(fN) where N is the file number
47  // For example pha(f1) returns the phase angle for f1
48  p_operators.push_back(new InfixFunction("cubemin", 1));
49  p_operators.push_back(new InfixFunction("cubemax", 1));
50  p_operators.push_back(new InfixFunction("cubeavg", 1));
51  p_operators.push_back(new InfixFunction("cubestd", 1));
52 
53  p_operators.push_back(new InfixFunction("pha", 1));
54  p_operators.push_back(new InfixFunction("ema", 1));
55  p_operators.push_back(new InfixFunction("ina", 1));
56 
57  p_operators.push_back(new InfixFunction("phal", 1));
58  p_operators.push_back(new InfixFunction("emal", 1));
59  p_operators.push_back(new InfixFunction("inal", 1));
60 
61  p_operators.push_back(new InfixFunction("phac", 1));
62  p_operators.push_back(new InfixFunction("emac", 1));
63  p_operators.push_back(new InfixFunction("inac", 1));
64 
65  p_operators.push_back(new InfixFunction("lat", 1));
66  p_operators.push_back(new InfixFunction("lon", 1));
67  p_operators.push_back(new InfixFunction("res", 1));
68  p_operators.push_back(new InfixFunction("radius", 1));
69  }
70 
79  bool CubeInfixToPostfix::isKnownSymbol(QString representation) {
80  for(int i = 0; i < p_operators.size(); i++) {
81  if(representation.compare(p_operators[i]->inputString()) == 0) {
82  return true;
83  }
84  }
85 
86  bool isFunction = (representation.size() > 1);
87  if(representation[0] == 'f') {
88  for(int i = 1; isFunction && i < representation.size(); i++) {
89  isFunction &= (representation[i] >= '0' && representation[i] <= '9');
90  }
91  }
92  else {
93  isFunction = false;
94  }
95 
96  return isFunction;
97  }
98 
99  InfixOperator *CubeInfixToPostfix::findOperator(QString representation) {
100  try {
101  return InfixToPostfix::findOperator(representation);
102  }
103  catch(IException &) {
104  }
105 
106  bool isFunction = (representation.size() > 1);
107  if(representation[0] == 'f') {
108  for(int i = 1; i < representation.size(); i++) {
109  isFunction &= (representation[i] >= '0' && representation[i] <= '9');
110  }
111  }
112  else {
113  isFunction = false;
114  }
115 
116  if(isFunction) {
117  p_operators.push_back(new InfixFunction(representation, 0));
118  return p_operators[p_operators.size()-1];
119  }
120 
121  throw IException(IException::User,
122  "The operator '" + representation + "' is not recognized.",
123  _FILEINFO_);
124  }
125 
126 
127 }; // end namespace Isis
Namespace for the standard library.
InfixOperator and InfixFunction are helper classes for InfixToPostfix.
InfixOperator and InfixFunction are helper classes for InfixToPostfix.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31