This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
dmspine64backup/Parser.h

266 lines
4.3 KiB
C
Raw Normal View History

2015-09-22 23:27:34 -05:00
#include <string> // std::string
#include <iostream> // std::cout
#include <sstream> // std::stringstream
#include <vector>
#include <string>
2015-09-25 00:30:09 -05:00
#include "DBEngine.h"
2015-09-22 23:27:34 -05:00
using namespace std;
2015-09-25 00:30:09 -05:00
class PRelation
2015-09-22 23:27:34 -05:00
{
string name;
2015-09-25 00:30:09 -05:00
public:
2015-10-06 19:24:59 -05:00
PRelation() { name = "~"; }
PRelation(string str) { name = str; }
void setPRelation(string str) { name = str; }
string getName() { return name; }
2015-09-22 23:44:51 -05:00
};
2015-09-22 23:27:34 -05:00
2015-09-25 00:30:09 -05:00
class PAttribute
{
string name;
string type;
bool key;
2015-09-25 00:30:09 -05:00
int size;
public:
2015-10-06 19:24:59 -05:00
PAttribute() {
2015-09-25 00:30:09 -05:00
name = "~";
type = "~";
key = false;
2015-09-25 00:30:09 -05:00
size = 0;
}
2015-10-06 19:24:59 -05:00
PAttribute(string str, string t) {
2015-09-25 00:30:09 -05:00
name = str;
type = t;
key = false;
2015-09-25 00:30:09 -05:00
size = 0;
}
2015-10-06 19:24:59 -05:00
PAttribute(string str, string t, int s) {
2015-09-25 00:30:09 -05:00
name = str;
type = t;
key = false;
2015-09-25 00:30:09 -05:00
size = s;
}
2015-10-06 19:24:59 -05:00
void setPAttributeName(string str) { name = str; }
void setPAttributeType(string t) { type = t; }
void setPAttributeKey() { key = true; }
void setPAttributeSize(int s) { size = s; }
string getPAttribute() { return name; }
string getPAttributeType() { return type; }
bool getPAttributeKey() { return key; }
int getPAttributeSize() { return size; }
2015-09-25 00:30:09 -05:00
};
2015-09-22 23:27:34 -05:00
2015-09-25 00:30:09 -05:00
class PUnion
2015-09-22 23:27:34 -05:00
{
string Un1;
string Un2;
2015-09-25 00:30:09 -05:00
public:
2015-10-06 19:24:59 -05:00
PUnion() {
2015-09-25 00:30:09 -05:00
Un1 = "~";
Un2 = "~";
}
2015-10-06 19:24:59 -05:00
PUnion(string s1, string s2) {
2015-09-25 00:30:09 -05:00
Un1 = s1;
Un2 = s2;
}
2015-10-06 19:24:59 -05:00
string getPUnion() {
2015-09-25 00:30:09 -05:00
return "Union of " + Un1 + " and " + Un2;
}
2015-09-22 23:44:51 -05:00
};
2015-09-22 23:27:34 -05:00
2015-09-25 00:30:09 -05:00
class PProduct
2015-09-22 23:27:34 -05:00
{
string Pr1;
string Pr2;
2015-09-25 00:30:09 -05:00
public:
2015-10-06 19:24:59 -05:00
PProduct() {
2015-09-25 00:30:09 -05:00
Pr1 = "~";
Pr2 = "~";
}
2015-10-06 19:24:59 -05:00
PProduct(string s1, string s2) {
2015-09-25 00:30:09 -05:00
Pr1 = s1;
Pr2 = s2;
}
2015-10-06 19:24:59 -05:00
string getPProduct() {
2015-09-25 00:30:09 -05:00
return "Product of " + Pr1 + " and " + Pr2;
}
2015-09-22 23:44:51 -05:00
};
2015-09-22 23:27:34 -05:00
2015-09-25 00:30:09 -05:00
class PDifference
2015-09-22 23:27:34 -05:00
{
string D1;
string D2;
2015-09-25 00:30:09 -05:00
public:
2015-10-06 19:24:59 -05:00
PDifference() {
2015-09-25 00:30:09 -05:00
D1 = "~";
D2 = "~";
}
2015-10-06 19:24:59 -05:00
PDifference(string s1, string s2) {
2015-09-25 00:30:09 -05:00
D1 = s1;
D2 = s2;
}
2015-10-06 19:24:59 -05:00
string getPDifference() {
2015-09-25 00:30:09 -05:00
return "Difference of " + D1 + " and " + D2;
}
2015-09-22 23:44:51 -05:00
};
2015-09-22 23:27:34 -05:00
2015-09-25 00:30:09 -05:00
class PRenaming
2015-09-22 23:27:34 -05:00
{
string newName;
string oldName;
2015-09-25 00:30:09 -05:00
public:
2015-10-06 19:24:59 -05:00
PRenaming() {
2015-09-25 00:30:09 -05:00
newName = "~";
oldName = "~";
}
2015-10-06 19:24:59 -05:00
PRenaming(string s1, string s2) {
2015-09-25 00:30:09 -05:00
newName = s1;
oldName = s2;
}
2015-10-06 19:24:59 -05:00
string doRename() {
2015-09-25 00:30:09 -05:00
return "Renaming " + oldName + " to " + newName;
}
2015-09-22 23:44:51 -05:00
};
2015-09-22 23:27:34 -05:00
2015-09-25 00:30:09 -05:00
class PProjection
2015-09-22 23:27:34 -05:00
{
string newName;
string oldName;
2015-09-25 00:30:09 -05:00
public:
2015-10-06 19:24:59 -05:00
PProjection() {
2015-09-25 00:30:09 -05:00
newName = "~";
oldName = "~";
}
2015-10-06 19:24:59 -05:00
PProjection(string s1, string s2) {
2015-09-25 00:30:09 -05:00
newName = s1;
oldName = s2;
}
2015-10-06 19:24:59 -05:00
string doPProjection() {
2015-09-25 00:30:09 -05:00
return "Projecting " + oldName + " onto " + newName;
}
2015-09-22 23:44:51 -05:00
};
2015-09-22 23:27:34 -05:00
2015-09-25 00:30:09 -05:00
class POperand
2015-09-22 23:27:34 -05:00
{
string op;
2015-09-22 23:44:51 -05:00
public:
2015-10-06 19:24:59 -05:00
POperand() { op = "~"; }
POperand(string str) { op = str; }
void setPOperand(string str) { op = str; }
string getPOperand() { return op; }
2015-09-22 23:44:51 -05:00
};
2015-09-25 00:30:09 -05:00
class POp
2015-09-22 23:27:34 -05:00
{
string op;
2015-09-22 23:44:51 -05:00
public:
2015-10-06 19:24:59 -05:00
POp() { op = "~"; }
POp(string str) { op = str; }
void setPOp(string str) { op = str; }
string getPOp() { return op; }
2015-09-22 23:44:51 -05:00
};
2015-09-25 00:30:09 -05:00
class PComparison
2015-09-22 23:27:34 -05:00
{
2015-09-25 00:30:09 -05:00
POp op;
POperand operand1;
POperand operand2;
2015-09-22 23:27:34 -05:00
2015-09-22 23:44:51 -05:00
public:
2015-10-06 19:24:59 -05:00
PComparison() {
2015-09-25 00:30:09 -05:00
op.setPOp("~");
operand1.setPOperand("~");
operand2.setPOperand("~");
2015-09-22 23:44:51 -05:00
}
2015-10-06 19:24:59 -05:00
PComparison(string str1, string str2, string str3) {
2015-09-25 00:30:09 -05:00
operand1.setPOperand(str1);
op.setPOp(str2);
operand2.setPOperand(str3);
2015-09-22 23:44:51 -05:00
}
2015-10-06 19:24:59 -05:00
void setPComparison(string str1, string str2, string str3) {
2015-09-26 23:24:24 -05:00
operand1.setPOperand(str1);
op.setPOp(str2);
operand2.setPOperand(str3);
}
2015-10-06 19:24:59 -05:00
string getPComparison() {
2015-09-25 00:30:09 -05:00
return operand1.getPOperand() + " " + op.getPOp() + " " + operand2.getPOperand();
2015-09-22 23:44:51 -05:00
}
};
2015-09-25 00:30:09 -05:00
class PConjunction
2015-09-22 23:27:34 -05:00
{
string conj;
2015-09-22 23:44:51 -05:00
public:
2015-10-06 19:24:59 -05:00
PConjunction() { conj = "~"; }
PConjunction(string str) { conj = str; }
void setPConjunction(string str) { conj = str; }
string getPConjunction() { return conj; }
2015-09-22 23:44:51 -05:00
};
2015-09-25 00:30:09 -05:00
class PCondition
2015-09-22 23:27:34 -05:00
{
string cond;
2015-09-22 23:44:51 -05:00
public:
2015-09-25 00:30:09 -05:00
2015-10-06 19:24:59 -05:00
PCondition() { cond = "~"; }
PCondition(string str) { cond = str; }
void setPCondition(string str) { cond = str; }
string getPCondition() { return cond; }
2015-09-22 23:44:51 -05:00
};
2015-09-25 00:30:09 -05:00
class PSelection
2015-09-22 23:27:34 -05:00
{
string select;
2015-09-22 23:44:51 -05:00
public:
2015-10-06 19:24:59 -05:00
PSelection() { select = "~"; }
PSelection(string str) { select = str; }
string getPSelection() { return select; }
2015-09-22 23:44:51 -05:00
};
2015-09-25 00:30:09 -05:00
class PExpression
{
PRelation rel;
PSelection sel;
PProjection proj;
PRenaming ren;
PUnion un;
PDifference diff;
PProduct prod;
string temp;
public:
2015-10-06 19:24:59 -05:00
PExpression() { select = "~"; }
PExpression(string str) { temp = str; }
void setPExpression(string str) { temp = str; }
string getPExpression() { return temp; }
2015-09-25 00:30:09 -05:00
};
void parse(string s, DBEngine &e);