Isis 3 Programmer Reference
CubeInfixToPostfix.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7
8#include "CubeInfixToPostfix.h"
9#include "IException.h"
10
11using namespace std;
12
13namespace Isis {
22
31 // List of the form funct(fN) where N is the file number
32 // For example pha(f1) returns the phase angle for f1
33 p_operators.push_back(new InfixFunction("cubemin", 1));
34 p_operators.push_back(new InfixFunction("cubemax", 1));
35 p_operators.push_back(new InfixFunction("cubeavg", 1));
36 p_operators.push_back(new InfixFunction("cubestd", 1));
37
38 p_operators.push_back(new InfixFunction("pha", 1));
39 p_operators.push_back(new InfixFunction("ema", 1));
40 p_operators.push_back(new InfixFunction("ina", 1));
41
42 p_operators.push_back(new InfixFunction("phal", 1));
43 p_operators.push_back(new InfixFunction("emal", 1));
44 p_operators.push_back(new InfixFunction("inal", 1));
45
46 p_operators.push_back(new InfixFunction("phac", 1));
47 p_operators.push_back(new InfixFunction("emac", 1));
48 p_operators.push_back(new InfixFunction("inac", 1));
49
50 p_operators.push_back(new InfixFunction("lat", 1));
51 p_operators.push_back(new InfixFunction("lon", 1));
52 p_operators.push_back(new InfixFunction("res", 1));
53 p_operators.push_back(new InfixFunction("radius", 1));
54 }
55
64 bool CubeInfixToPostfix::isKnownSymbol(QString representation) {
65 for(int i = 0; i < p_operators.size(); i++) {
66 if(representation.compare(p_operators[i]->inputString()) == 0) {
67 return true;
68 }
69 }
70
71 bool isFunction = (representation.size() > 1);
72 if(representation[0] == 'f') {
73 for(int i = 1; isFunction && i < representation.size(); i++) {
74 isFunction &= (representation[i] >= '0' && representation[i] <= '9');
75 }
76 }
77 else {
78 isFunction = false;
79 }
80
81 return isFunction;
82 }
83
85 try {
86 return InfixToPostfix::findOperator(representation);
87 }
88 catch(IException &) {
89 }
90
91 bool isFunction = (representation.size() > 1);
92 if(representation[0] == 'f') {
93 for(int i = 1; i < representation.size(); i++) {
94 isFunction &= (representation[i] >= '0' && representation[i] <= '9');
95 }
96 }
97 else {
98 isFunction = false;
99 }
100
101 if(isFunction) {
102 p_operators.push_back(new InfixFunction(representation, 0));
103 return p_operators[p_operators.size()-1];
104 }
105
107 "The operator '" + representation + "' is not recognized.",
108 _FILEINFO_);
109 }
110
111
112}; // end namespace Isis
CubeInfixToPostfix()
Constructs a CubeInfixToPostfix converter.
bool isKnownSymbol(QString representation)
This method will return true if it believes the argument represents a valid function or operator.
InfixOperator * findOperator(QString representation)
This method will return a pointer to the operator represented by 'representation.
void initialize()
This method is used to create functions that are specific to cubes.
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
InfixOperator and InfixFunction are helper classes for InfixToPostfix.
InfixOperator and InfixFunction are helper classes for InfixToPostfix.
virtual InfixOperator * findOperator(QString representation)
This method will return a pointer to the operator represented by 'representation.
bool isFunction(QString representation)
This method will return true if 'representation' is a known function.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.